umesh 1 Posted January 20, 2016 Share Posted January 20, 2016 Hello I am trying to send data to browser using wifi module ESP8266 with MSP430G2553 launchpad. ESP8266 work on 3.3V and MSP430G2553 also. So here i connected ESP8266 directly to the launchpad. connections are- Tx of ESP to Rx of Launchpad Rx of ESP to Tx of Launchpad VCC to Vcc Gnd to Gnd CH_PD to 3.3V and i got code for energia from this forum only. code is as follows #define SSID "friends" #define PASS "walchand" #define DST_IP "things.ubidots.com" #define idvariable "569fc4ba76254229c49896a6" // replace with your Ubidots Variable ID #define token "aIdUatYb4QqgntExGmdi6xIllonUaY3AxwJjs5UzCCVib9reI1dI2XFEnfeX" // replace with your Ubidots token int len; void setup() { // Open serial communications and wait for port to open: char cmd[254]; Serial.begin(9600); Serial.setTimeout(5000); //test if the module is ready Serial.println("AT+RST"); delay(1000); if (Serial.find("ready")) { Serial.println("Module is ready"); } else { Serial.println("Module have no response."); while (1); } delay (1000); //connect to the wifi boolean connected = false; for (int i = 0; i < 5; i++) { if (connectWiFi()) { connected = true; break; } } if (!connected) { while (1); } delay(5000); Serial.println("AT+CIPMUX=0"); } void loop() { int value = analogRead(A0); //you can change ir to another pin int num=0; String var = "{\"value\":"+ String(value) + "}"; num = var.length(); String cmd = "AT+CIPSTART=\"TCP\",\""; cmd += DST_IP; cmd += "\",80"; Serial.println(cmd); if (Serial.find("Error")) return; len=strlen ("POST /api/v1.6/datasources/"); len=len+strlen (idvariable); len=len+strlen ("/values HTTP/1.1\nContent-Type: application/json\nContent-Length: "); char numlenght[4]; // this will hold the length of num which is the length of the JSON element sprintf(numlenght, "%d", num); // saw this clever code off the net; works yay len=len+strlen (numlenght); len=len + num; //fixed length of the string that will print as Content-Length: in the POST len=len+strlen ("\nX-Auth-Token: "); len=len+strlen (token); len=len+strlen ("\nHost: things.ubidots.com\n\n"); len=len+strlen ("\n\n"); Serial.print("AT+CIPSEND="); Serial.println (len); //lenght of the entire data POST for the CIPSEND command of ESP2866 //Serial.println(cmd.length()); if (Serial.find(">")) { //Serial.print(">"); } else { Serial.println("AT+CIPCLOSE"); delay(1000); return; } Serial.print ("POST /api/v1.6/variables/"); Serial.print (idvariable); Serial.print ("/values HTTP/1.1\nContent-Type: application/json\nContent-Length: "); Serial.print (num); Serial.print ("\nX-Auth-Token: "); Serial.print (token); Serial.print ("\nHost: things.ubidots.com\n\n"); Serial.print (var); Serial.println ("\n\n"); delay(9000); //Serial.find("+IPD"); clear the input buffer after the web site responds to the POST while (Serial.available()) { char c = Serial.read(); } delay(1000); } boolean connectWiFi() { Serial.println("AT+CWMODE=1"); String cmd = "AT+CWJAP=\""; cmd += SSID; cmd += "\",\""; cmd += PASS; cmd += "\""; Serial.println(cmd); delay(2000); if (Serial.find("OK")) { return true; } else { return false; } } when i trying to connect to wifi then it is not working properly it display only .. AT+RSTModule have no response. So what can be the problem?? And one more thing is that blue LED on ESP is not blinking continuously. LIJsselstein 1 Quote Link to post Share on other sites
energia 485 Posted January 20, 2016 Share Posted January 20, 2016 Have you tried connecting the ESP8266 directly to your PC using an FTDI or other serial cable to make sure that it is responding correctly? Quote Link to post Share on other sites
Rei Vilo 695 Posted January 20, 2016 Share Posted January 20, 2016 The ESP8266 requires up to 380 mA. Check the voltage regulator of the LaunchPad can provide so much power. The consequence may result in a burned voltage regulator. Check also the USB port of the computer, it may be limited to 100 mA. USB ports on modern computers can provide up to 500 mA, although some are limited by software. gsutton 1 Quote Link to post Share on other sites
USWaterRockets 57 Posted January 20, 2016 Share Posted January 20, 2016 I suspect you may have to check the jumpers on the upper right of the Launchpad. By default I believe they ship with the TX and RX jumpers going in up/down like this || for compatibility with the software UART driver from the original MSP430G2231 launchpad. To use the hardware UART, you want the jumpers to be set horizontally, like this = Alternatively, you can just swap the TX and RX lines going to the wifi module, and give that a try. gsutton 1 Quote Link to post Share on other sites
USWaterRockets 57 Posted January 20, 2016 Share Posted January 20, 2016 The ESP8266 requires up to 380 mA. Check the voltage regulator of the LaunchPad can provide so much power. The consequence may result in a burned voltage regulator. Check also the USB port of the computer, it may be limited to 100 mA. USB ports on modern computers can provide up to 500 mA, although some are limited by software. The Launchpad can supply quite a bit of current for a few minutes, until the regulator goes into overtemp shutdown, and I would assume the wifi module does not draw the full current on power-up. It may not enable the transmitter until given a command, so it could actually be drawing very little current. You suggestion may avoid future issues for the OP, if it draws a lot of current it could eventually overheat the regulator and mysteriously reset or shut down, so it's a great suggestion to keep an eye on the current consumption of the setup and make sure this does not become an issue. Quote Link to post Share on other sites
Rei Vilo 695 Posted January 20, 2016 Share Posted January 20, 2016 According to the schematics of the MSP430 LaunchPad, the voltage regulator is a TPS77301 and rated as 250mA. See the datasheet at Single Output LDO, 250mA, Adjustable (1.5 to 5.5V), Fast Transient Response, SVS. So use an external 3.3V power source for the ESP8266. Quote Link to post Share on other sites
Fmilburn 445 Posted January 20, 2016 Share Posted January 20, 2016 According to the schematics of the MSP430 LaunchPad, the voltage regulator is a TPS77301 and rated as 250mA. See the datasheet at Single Output LDO, 250mA, Adjustable (1.5 to 5.5V), Fast Transient Response, SVS. So use an external 3.3V power source for the ESP8266. My admittedly limited experience with the ESP8266 supports your recommendation. I could not get reliable performance without using an external power supply. Quote Link to post Share on other sites
umesh 1 Posted January 22, 2016 Author Share Posted January 22, 2016 Yes i tried connecting esp directly to pc and its working fine. I was able to send data to browser without any problem. But it is not working with MSP430 launchpad. Now i will try by giving sufficient power to esp8266. Quote Link to post Share on other sites
umesh 1 Posted January 22, 2016 Author Share Posted January 22, 2016 i got the code from below link and they said that code working finely with no bugs. http://forum.43oh.com/topic/5903-esp8266-iot-on-the-cheap/ They didn't mention any power related issue. So really can it be only power supply issue? or baud rate mismatch? I update the esp8266 firmware also to operate with Arduino board Quote Link to post Share on other sites
energia 485 Posted January 25, 2016 Share Posted January 25, 2016 @@umesh can you please try an external power supply. It seems that @@Fmilburn had issues with the LaunchPad not supplying enough power to support the esp8266. umesh 1 Quote Link to post Share on other sites
umesh 1 Posted February 1, 2016 Author Share Posted February 1, 2016 Hello,Whether we have to add some libraries of ESP8266 to the energia or not?if yes then which are those?When i using above code then it compiles and loaded finely but not giving response. It prints AT+RST on serial monitor. Quote Link to post Share on other sites
al1fch 5 Posted February 1, 2016 Share Posted February 1, 2016 Hello 9600 bauds was OK for 'old' AT firmwares, check Serial.begin(115200) for 'recent' ESPxx modules. +only 250mA avaliable -> some Vss drop oup during strong radio +20dBm TX pulses, may cause 'unwanted' resets + so called "3V3" is 3.55V on my two MSP2553 Launchpad, OK but 'high end' for ESP8266 chip (3.6V) Fmilburn and umesh 2 Quote Link to post Share on other sites
umesh 1 Posted February 2, 2016 Author Share Posted February 2, 2016 Hello everybody,I have solved the power supply problem for ESP8266. I have given 3.3V 500mA power externally to esp8266. But now i facing the problem to communicate msp430g2553 with esp8266. I made the connections as follows:Tx of ESP to Rx of LaunchpadRx of ESP to Tx of LaunchpadVCC to VccGnd to GndCH_PD to 3.3VGPIO0 to 3.3 Vand i uploaded blank sketch i.e. Bare minimum from example, but i didn't get any response for AT commands. What should i make changes in order to get proper response.When i reset the esp then garbage value is shown on serial monitor. I have checked by changing all possible baud rates as well as swap TX and RX pins.Thanks and regards Quote Link to post Share on other sites
yosh 121 Posted February 2, 2016 Share Posted February 2, 2016 You cannot use rx tx pins for communication with ESP and computer (serial monitor) at the same time. Try using software serial instead for one connection .... energia and umesh 2 Quote Link to post Share on other sites
umesh 1 Posted February 9, 2016 Author Share Posted February 9, 2016 Hello everybody, Now i am able to communicate MSP430G2553 with ESP8266 and ESP8266 is giving response for AT commands.I am using software UART to communicate with ESP and hardware UART for debugging. So unfortunately it is printing garbage characters. I think it can be the problem of baud rate mismatch. ESP8266 default baud rate is 115200 and software UART is supports upto 9600. The code for checking AT command response taken from internet is as follows: #include <SoftwareSerial.h> SoftwareSerial esp8266(5,6); // make RX msp430g2553 line is pin 5, make TX msp430g2553 line is pin 6. // This means that you need to connect the TX line from the esp to the msp430g2553's pin 2 // and the RX line from the esp to the msp430g2553's pin 3 void setup() { Serial.begin(9600); esp8266.begin(115200); // your esp's baud rate might be different } void loop() { if(esp8266.available()) // check if the esp is sending a message { while(esp8266.available()) { // The esp has data so display its output to the serial window char c = esp8266.read(); // read the next character. Serial.write(c); } } if(Serial.available()) { // the following delay is required because otherwise the msp430g2553 will read the first letter of the command but not the rest // In other words without the delay if you use AT+RST, for example, the msp430g2553 will read the letter A send it, then read the rest and send it // but we want to send everything at the same time. delay(1000); String command=""; while(Serial.available()) // read the command character by character { // read one character command+=(char)Serial.read(); } esp8266.println(command); // send the read character to the esp8266 } } So how can i use hardware UART to communicate with esp. Or how can i change baudrate of esp to 9600? Thank you. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.