NodeMCU does not receive data via UART
Posted: Fri Feb 24, 2017 4:49 pm
Hello,
I'm using a nodemcu and an arduino mega in order to exchange data and then send the data to a server.
After a little bit of tweaking I was able to send data from nodemcu to mega, and I can see the data arriving without any problems.
The thing is that when I try to send data from mega to nodemcu, the data doesn't arrive. And I mean that it physically doesn't get to the board.
I connect the output of the mega's uart3 to 3 10k resistors and reduce the siganl from 5V to 3V3 approximately. When I don't connect the nodemcu I can see the data in an oscilloscope. My byte is there @3V3. But as soon as I connect the pin to the nodemcu It goes to 0V and there is no more signal. It was connected in Rx pin of nodemcu.
Naturally I thought that maybe the CH30 usb-serial converter is driving the pin to 0V or maybe some software on my computer is doing it. So I used the Serial.swap function in order to use TX2 and RX2 instead of TX0 and RX0.
Again I can easily get the data from nodemcu, but I can't send data to nodemcu. The same thing happens, it goes to 0V as soon as I connect it to nodemcu. Obviously the TX and RX are both working as they should, or else I wouldn't be able to flash new firmwares nor debug the output via serial port.
I'm thinking that there must be something wrong with my code.
As you can see it's extremely simple. Wait until data arrives and send it back, but data never arrives.
I'm using a nodemcu and an arduino mega in order to exchange data and then send the data to a server.
After a little bit of tweaking I was able to send data from nodemcu to mega, and I can see the data arriving without any problems.
The thing is that when I try to send data from mega to nodemcu, the data doesn't arrive. And I mean that it physically doesn't get to the board.
I connect the output of the mega's uart3 to 3 10k resistors and reduce the siganl from 5V to 3V3 approximately. When I don't connect the nodemcu I can see the data in an oscilloscope. My byte is there @3V3. But as soon as I connect the pin to the nodemcu It goes to 0V and there is no more signal. It was connected in Rx pin of nodemcu.
Naturally I thought that maybe the CH30 usb-serial converter is driving the pin to 0V or maybe some software on my computer is doing it. So I used the Serial.swap function in order to use TX2 and RX2 instead of TX0 and RX0.
Again I can easily get the data from nodemcu, but I can't send data to nodemcu. The same thing happens, it goes to 0V as soon as I connect it to nodemcu. Obviously the TX and RX are both working as they should, or else I wouldn't be able to flash new firmwares nor debug the output via serial port.
I'm thinking that there must be something wrong with my code.
Code: Select all
void setup() {
Serial.begin(9600);
Serial.swap();
}
void loop() {
if(Serial.available()) {
uint8_t data = Serial.read();
Serial.write(data);
}
}
As you can see it's extremely simple. Wait until data arrives and send it back, but data never arrives.