1

I am new to Arduino & ESP modules, here am trying to communicate with ESP-01 via Arduino UNO. I have gone through multiple websites for initial setup. But when i upload my code to UNO, ESP is not responding back.Below is the code i have used.

#include<SoftwareSerial.h>
SoftwareSerial ESP(0,1); // RX, TX
//ESP RX-->1(UNO) TX-->0(UNO)

void setup() {
// Open serial communications and wait for port to open:

    Serial.begin(9600);
    while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
    }

   // Serial.println("Goodnight moon!");

    // set the data rate for the SoftwareSerial port
    ESP.begin(9600);

}

void loop() {
      ESP.write("AT\r\n"); //Normally ESP responds to AT command with "OK"
    while (ESP.available()) {
        char inData = ESP.read();
        Serial.println("Got reponse from ESP8266: ");
        Serial.write(inData);
    }


}

Source: Link of the url

My observation on this is

  1. ESP is blinking blue light when i reset UNO
  2. UNO TX onboard LED is blinking
  3. when i am trying to do Serial.println("Goodnight moon!"); it is printing
  4. Serial.println("Got reponse from ESP8266: "); Serial.write(inData); is not printing

My questions are:

  1. Is there any need to flash ESP with Firmware or is it default enabled.(i have 3 esp's with me all of them not responding with above code)
  2. If no need then what is the possible mistake i am doing.

Here is the screenshot https://i.stack.imgur.com/mOklg.png

Note: I haven't used breadboard for connection, directly connected UNO-TX -> ESP RX and UNO-RX -> ESP TX, 3.3v VCC and ground.In the above screenshot on upload nothing prints, only when i type something "Got reponse from ESP8266: " is printing

3 Answers 3

1

Hi all i found out the solution after a long struggle. issue was with the ch_pd as per the ESP documentation ch_pd has to be active high that means it has to get 3.3v, only then it will communicate.

soon after that all my problems got cleared.thank you

0
SoftwareSerial ESP(0,1); // RX, TX

Pins 0 and 1 are hardware serial on the Uno, used with the Serial object, these pins are used to communicate with your computer (e.g. Serial Monitor) via the USB-serial chip on the Uno.

There is absolutely no reason you should ever use SoftwareSerial with pins 0 and 1. If you want to use software serial then connect the ESP8266 to pins other than 0 and 1. Otherwise don't use SoftwareSerial at all, but be aware that using Serial to communicate with the ESP8266 and with the computer is problematic and can also cause issues when you try to upload to your Uno.

2
  • if i dont use SoftwareSerial how am i supposed to communicate with esp?my assumption is SoftwareSerial is a library to communicate with ESP.
    – 3bu1
    Jun 22, 2017 at 10:12
  • SoftwareSerial is a library that allows you to do serial communication on pins that don't support hardware serial. Please take the time to study and understand arduino.cc/en/Reference/SoftwareSerial
    – per1234
    Jun 22, 2017 at 11:17
0

There's a good chance your ESP and SoftwareSerial baud rates are not matched. The last handful of ESP-01s I bought came with default baud rates 115200. You may need to change yours to 9600 baud to use with SoftwareSerial. See my answer to a similar question.

Update:

tried all the available baud rates....!!Still the same issue..

Three possible issues come to mind:

  1. Your terminal program must be at the same baud rate you set the ESP to.

  2. SoftwareSerial is pretty much limited to a max of 9600 baud, although it can usually transmit successfully at 115200.

  3. The serial connections must be cross-wired - Rx->Tx and Tx->Rx.

I think you had addressed 3) when you were trying to use pins 0 & 1, at least, as I read your comments. Together, 1) and 2) mean you'll need to use SS at 115200 to change the ESP's baud rate to 9600, then change SS to 9600 to carry on any further.

Also try moving the ESP.write("AT\r\n"); command to the setup() function. As your code is written, anytime the while loop finds no character waiting, the while loop will end and the loop() function will exit and restart, sending a new command to the ESP. Your code might never get a chance to print anything at all.

1
  • tried all the available baud rates....!!Still the same issue...
    – 3bu1
    Jun 22, 2017 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.