This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to use hardware UART of MSP430G2553 to communicate with ESP8266

Other Parts Discussed in Thread: MSP430G2553, MSP-EXP430FR5969

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 is as follows:

#include <SoftwareSerial.h>
 
SoftwareSerial esp8266(2,3); // make RX msp430g2553 line is pin 2, make TX msp430g2553 line is pin 3.
                             // 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?

  • One mistake i did in above post ..
    actually pins i am using for software UART are 5,6 not 2,3.

    I have edited the code which was for the arduino uno from internet

    Thank you.
  • Hi Umesh,

    The backchannel UART on the MSP-EXP430G2 LaunchPad that communicates with a host PC through the eZ430 and mini-USB connection is limited to a baud rate of 9600 as well. This is a hardware limitation of the eZ430 and not the MSP430G2553's USCI peripheral, which is capable of 115200 baud. Any other LaunchPads that use the newer eZ-FET hardware, like the MSP-EXP430F5529 or MSP-EXP430FR5969 among others, are also capable of 115200 baud rates through the PC and available USB connection. According to ESP8266 documentation, the baud rate depends on the firmware version: newer versions use 9600 baud rate while older versions used 57600 or 115200 baud rates. It does not appear that this baud rate can be altered.

    Regards,
    Ryan
  • Thanks  Ryan,

    I will update the firmware of my esp to newer one.

**Attention** This is a public forum