Arduino (ARD) does not read data from NODEMCU (NDU)
I want the Arduino to exchange data with a UDP / TCP server. I connected the ARD to the NDU via a serial port (ARD TX - RX NDU, ARD RX - TX NDU), I connected the Transmit line from the Arduino via a voltage divider to the receiving line of the NDU. In Arduino, I uploaded a terminal emulation program. I use SoftwareSerial to communicate with NDM. The Arduino does not receive data from the NDU. I tested the same program with MEGA 2560 and the result is the same - wrong.
That's why I connected the Arduino to a USB Serial TTL adapter. This combination works perfectly. I also connected the NDU to a USB serial TTL port. And this combination works flawlessly.
When I connect ARD to NDU and enter an empty program in ARD, then the ARD Serial Monitor exchanges data with the NDU module.
When ARD is connected to MDU I have proved that NDU receives correct data from ARD. The TX line of the NDU, which is connected to the RX line of the ARD, I connected in parallel with a special USB TTL adapter. I found that the MDU was sending correct responses to commands from the Arduino. I send AT commands to the NDU module. I don't know why the Arduino can't read data from the NDU module.
I searched this forum and did not encounter a similar problem. Any idea, suggestion is welcome, Thank you.
trajan:
I connected the ARD to the NDU via a serial port (ARD TX - RX NDU, ARD RX - TX NDU), I connected the Transmit line from the Arduino via a voltage divider to the receiving line of the NDU
I have no experience with using the AT-firmware. I took an initial look into it and found it difficult to use.
So I started to use nodeMCU-boards as the "new Arduino" itself.
As you have a nodeMCU (and not only this tiny ESP8266-01) You could do the same.
A nodeMCU-board has quite some IO-pins itself and it can be programmed with the Arduino-IDE just as Arduinons itself.
Depending on your project this might be an alternative.
Even if you want to keep the Arduino another possabilitiy is to write your own program on the nodeMCU doing all the Wifi UDP-stuff and still send all the data over a serial interface.
I guess somewhere on the internet the "original" AT-formware can be found to do a rollback from "your own-nodeMCU-program" to AT-Firmware but I don't know where.
So if you describe what you want to do in the end it will be much easier to comment if switching from AT-firmware to "Arduino-IDE-Firmware" would be a good option
I connected the Transmit line from the Arduino via a voltage divider to the receiving line of the NDU.
but i thought that the RX0 (GPIO3) pin is 5v tolerant on a nodeMCU (being the only one that is though) ? I clearly recall having some issues when using a voltage divider. I ended up doing something with a diode (i didn't trust the 5v Tolerant thing) i just can't remember what exactly. Probably something like this.
1K for the resistor is a guess, The value may be to small for the signal to go low enough, but the rx-pin can never be higher than 3.3v
I searched this forum and did not encounter a similar problem.
We should complain to Google (i'll put it on the list, can't seem to find the 5v tolerant thing anywhere either)
What Stefan is saying is true, for a project you probably don't need the Uno, but as an exercise you should get this to work as well.
StefanL38:
I have no experience with using the AT-firmware. I took an initial look into it and found it difficult to use.
[...]
Even if you want to keep the Arduino another possabilitiy is to write your own program on the nodeMCU doing all the Wifi UDP-stuff and still send all the data over a serial interface.
I guess somewhere on the internet the "original" AT-formware can be found to do a rollback from "your own-nodeMCU-program" to AT-Firmware but I don't know where.
Indeed, I found that the AT interface has hidden undocumented timing requirements. I did actually make a great clock system that way, I modified a native SNTP sketch written for the ESP so that time info could be requested from the serial port. That worked much better than the AT command method, which only worked after a lot of hair tearing (after I tried to make the standard Arduino AT command based sketch non-blocking).
I have also successfully re-flashed ESP firmware, although it's such a pain that now I would just buy another one if I needed that.
Some people say, why not ditch the Arduino and just use the ESP itself? I do that too now, with an ESP32 but sometimes there are I/O or realtime hardware requirements that are more easily done with two processors - an ESP and an Arduino. It depends on what you're doing.
I treat all pins on an ESP as non-5V tolerant until I ever see authoritative evidence to the contrary. There's a lot of talk floating around but nothing from Espressif.
You mention SoftwareSerial and you mention ARD Rx and ARD Tx. If you really connected it to pins 0 and 1 and are using e.g. an Uno/Nano or Mega), those pins are the hardware serial pins and the advise is to stay away from them as they are used for the serial communication over USB on most boards (both for serial.print and uploads). SoftwareSerial should be on different pins.
You don't mention which Arduino you're using; you do mention the Mega. For the Mega, use one of the other serial ports (Serial1/2/3) and test.
I have never seen anyone successfully use the ESP8266 as a WiFi shield for the Arduino. If you need WiFi, why not simply use a board that has WiFi?
I actually do that as well, using an Arduino (nano or pro-mini) for DMX reception and as a WS281x Led controller, with the ESP acting as a UI for settings and as a 2nd manual control. Not with the use of AT-commands though.
I have also successfully re-flashed ESP firmware, although it's such a pain that now I would just buy another one if I needed that.
I have a text file that explains to me how to do that if i ever wanted to again, though i can't imagine i ever will again.
I treat all pins on an ESP as non-5V tolerant until I ever see authoritative evidence to the contrary.
Yep me too, though as i said i have seen documentation stating that the RX0 pin of a nodeMCU is 5v tolerant (only on a nodeMCU and only that pin ! ), i just can't re-produce it, and i've had issues using the primary Serial port for reception the way i normally do on an ESP-01. It was in a thread started by someone who also had the same issue (again i cannot find that thread) here.) the RX pin is just connected straight to an Arduino pin (and i remember having done that with a positive result. here it tells you about exactly the same issue that you are having and the direct connecting solution. The thing was that when i use a voltage divider to connect to the UART2 The one that becomes available after Serial.swap() it did work !
I have solved the problem and I want to share the solution with you. It will probably be useful to some of you. The solution to the problem is unusual and has only confirmed the definition of theory and practice. The theory is when everything is clear to you, but your device does not work (my case). The practice is when your device works but you don't know why (my case),
I solved the problem when I removed the voltage divider and connected the transmit line from the Arduino directly to the NODEMCU receiving line (although this is not recommended). Let me remind you that the problem was not on the receiving side of NODEMC but on the receiving side of Arduino.
Although I have solved the problem, I have no explanation for the solution. If any of you know the explanation it would be good to share it with us.
Is that really adding anything ? I am still pretty sure that there is a circuit, like the onei already posted, on the RX pin of the nodeMCU. and all i did was double up on it.