0

I have a serial communication issue between a Arduino Uno and a NodeMCU (ESP8266 12f) that I do not understand.

The setup is the following. Arduino uno powered by USB cable plugged on computer with :

  • RESET to ground to bypass anycode on it
  • TX and RX (hardware serial) connected to the TX and RX of the NodeMCU

NodeMCU powered by USB cable plugged on computer with :

  • EN to 3.3v
  • I have a Reset button on the NodeMCU so it's not plugged
  • GPIO0 and GPI015 not plugged

Between both, there is a level shifter to account for the voltage difference

The problem is the following. When I connect Arduino IDE on the Arduino serial with baud rate 115200 and hit the reset button on the NodeMCU, I get the usual init garbage followed by "ready", so communication works this way. When I send "AT" through the arduino serial monitor, I get nothing in responses (the arduino serial TX led flashes properly though)

I have tried and tested several things

  • I plugged arduino TX to RX, the echo works, so no issue with arduino serial PINs
  • I plugged the 3.3v end of the level shifter corresponding to Arduino's TX to arduino's RX : echo works, and the reverse is true, so level shifter works like a charm
  • I tested the voltage on both ends of the level shifter, it is absolutly as expected 5V and 3.3v
  • I tested the nodeMCU in arduino ide serial monitor, I get the same garbage + "ready" after nodemcu's reset but this time, all AT commands work from nodeMCU serial monitor.
  • I connected NodeMCU rx to tx and the echo works fine in serial monitor connected on NodeMCU directly (via USB on NodeMCU) so NodeMCU serial PINs work
  • I tested with two NodeMCU to be sure I did not have a weird issue with one NodeMCU

I haven't tried to connect the arduino and nodemcu rx/tx directly cause I don't want to fry the nodemcu. I haven't flashed the NodeMCU, haven't changed the firmware, so on either side (Arduino grounded on reset and NodeMCU as it was out of factory), it does not seem possible that it is a programming issue.

Oh, one last thing, there will probably be someone wondering why I do not get rid of the arduino alltogether. Well, two reasons :

  • I have a relay board in 5V and no separate 5V power supply for now.
  • I hate being bothered by such a baffling issue and simply walking away.

[Edit] To be sure there wasn't a weird interaction between hardware serial used for comm with NodeMCU and used for Arduino-PC comm, I decided to switch to soft serial for the communication with the NodeMCU connected on pins 8/9 with the following code :

#include <SoftwareSerial.h>
SoftwareSerial mySerial(9,8);
  
void setup() {
  mySerial.begin(9600);
  Serial.begin(9600); 
}

void loop() {
  char myc = mySerial.read();
  if (myc != -1) {
    Serial.print(myc);
  }

  char c = Serial.read();
  if (c != -1) {
    mySerial.print(c);
  }
}

And surprisingly, it works.

But why didn't it work with everything wired through the hardware serial ?

I mean, if the data comes from NodeMCU to the computer through arduino, why doesn't it work in reverse from comp to NodeMCU through arduino hardware serial ?

2
  • The normal rule is that when you connect two serial devices together, TX of one device is connected to RX of the other device etc. However, when you use the Uno in a sort of pass through mode (as a USB/UART adaptor) then TX goes to TX and RX to RX. This is because, for example, the Uno pin labelled TX is the TX of its ATmega328P and the RX of its USB chip. How did you wire it ?
    – 6v6gt
    Jun 18 at 4:47
  • 2
    <skohhh khhhh> I find your lack of common ground disturbing.
    – timemage
    Jun 18 at 19:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.