Issue with Serial communication with ESP8266

Hello everyone,

I kindly ask for guidance as I feel I am stuck on a simple project. I am trying to make an Arduino UNOr3 talk to a ESP8266 via Serial. Almost all tutorial I see online use custom pins with SoftwareSerial. Unfortunately I run out of digital pins so I can only use RX/TX.

I understand that RX/TX are used by USB communication so I usually follow this workflow:

  1. unplug ESP8266
  2. connect USB to PC and upload sketch
  3. unplug USB
  4. plug ESP8266
  5. plug a usb-wall-socket charger directly for power

Afaik, the above procedure should let me use the RX/TX as I please.. but I can't seem to send/receive anything..or so it seems. Also:

  1. afaik RX/TX on the UNOr3 should work with 115200 no problem
  2. if I put the UNOr3 in "reset" mode, I am able to talk to the ESP module from my PC SerialMonitor. See below for proof that the ESP module works.
  3. the ESP unit has a blu led that blinks when it sends data. When I power it up, I see it blinking (i.e. it's sending a "ready"), but when I expect it to send an "OK" to my "AT" command, I don't see the led blinking.

I am working with a super simple code:

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.print("AT\r\n"); // this should get an "OK" from the esp module
  delay(1000);
  char* reply = Serial.readString().c_str();
  print_text_on_lcd(reply);
}

void loop() {}

ESP Module while talking directly with PC:

AT

OK

AT+GMR

AT version:1.3.0.0(Jul 14 2016 18:54:01)
SDK version:2.0.0(5a875ba)
Farylink Technology Co., Ltd. v1.0.0.2
May 11 2017 22:23:58
OK

So, my question is, why don't a get a reply from the ESP unit? Any help or guidance is much appreciated!

Thanks!

It's because of point 2 :wink: When the Uno is in reset you should NOT be able to talk to the ESP from the computer.

Because if that's the case the TX from the ESP is connected to the RX from the PC. And for the Uno to talk to the PC it's TX is also connected to the RX of the PC. Which means you now have the TX of the ESP connected to the TX of the Uno. Aka, swap TX and RX :wink:

But I would just swap roles, make the more powerfull ESP be the one with the main program and maybe use a Uno/Pro Mini as a slave (via I2C or something). :slight_smile:

joe-rduino:
I am working with a super simple code:

For informed help, post your complete code. Not snippets.

septillion:
It's because of point 2 :wink: When the Uno is in reset you should NOT be able to talk to the ESP from the computer.

Because if that's the case the TX from the ESP is connected to the RX from the PC. And for the Uno to talk to the PC it's TX is also connected to the RX of the PC. Which means you now have the TX of the ESP connected to the TX of the Uno. Aka, swap TX and RX :wink:

But I would just swap roles, make the more powerfull ESP be the one with the main program and maybe use a Uno/Pro Mini as a slave (via I2C or something). :slight_smile:

You solved it, RX/TX were inverted!
Thanks a lot!

Good it works now! :slight_smile: