I have an Arduino UNO and HUZZAH ESP8266 module. I need to send data between Arduino UNO and ESP module via Software Serial. Right now I have the ESP module write data and Arduino UNO display data, but not working. When I run the Arduino UNO and open its Serial Monitor, nothing is printed using below source code.
- ESP8266 RX PIN connected to Arduino UNO PIN 2.
- ESP8266 TX PIN connected to Arduino UNO PIN 3.
- Using the FTDI cable that came with HUZZAH ESP8266 to power this module. I just individually connected the RX and TX pins to the ARDUINO PIN 2 and 3 as mentioned above.
Any ideas what why not working? Below is code for both modules. Thanks,
Arduino UNO
#include <SoftwareSerial.h>SoftwareSerial ESPserial(2, 3); // RX | TXvoid setup(void){ //Start hardware Serial communication Serial.begin(115200); //Start the software serial for communication with the ESP8266 component ESPserial.begin(57600); }void loop(void){if (ESPserial.available()){ Serial.println("ESP available!!!"); Serial.println(ESPserial.read());}}HUZZAH ESP8266
#include <ESP8266WiFi.h>#include <SoftwareSerial.h>SoftwareSerial ESPserial(2, 3); // RX | TXvoid setup(void){ //Start the software serial for communication with the Arduino UNO component ESPserial.begin(57600); //TODO: setup Wifi}void loop(void){ ESPserial.write("This message generated by ESP module."); delay(500);}- What is the Arduino Pin 2 ?Rrz0– Rrz02018-01-06 20:22:25 +00:00CommentedJan 6, 2018 at 20:22
- RX on the Arduino should be connected to TX on the esp and vice versa, looks like you have RX connected to RX...Ron Beyer– Ron Beyer2018-01-06 20:24:42 +00:00CommentedJan 6, 2018 at 20:24
- The Arduino pin 2 is digital.Marquinio– Marquinio2018-01-06 20:24:43 +00:00CommentedJan 6, 2018 at 20:24
- @Marquinio yes but is it TX or RX?Rrz0– Rrz02018-01-06 20:26:56 +00:00CommentedJan 6, 2018 at 20:26
3 Answers3
Make sure that:
- RX pin on the Arduino UNO is connected to the TX pin on the ESP8266.
- TX pin on the Arduino UNO is connected to the RX pin on the ESP8266.
- Baud rate should be set to the same value from both the Arduino and ESP8266.
I don't know about your arduino but looking at this schematic, your RX and TX should be swapped.
- This is a very common mistake which at first may not seem obvious.John Smith– John Smith2018-01-06 21:05:14 +00:00CommentedJan 6, 2018 at 21:05
- 3Yes this fixed my problem. The ESP now gets data which seems to be in bytes. I will try to figure out how to send/read readable strings, but thats another story. My electronics knowledge is very limited, thanks.Marquinio– Marquinio2018-01-07 00:28:46 +00:00CommentedJan 7, 2018 at 0:28
Adding to the above answer. UNO's TX is at 5V , while ESP8266 's RX is at 3.3V, as it is a 3.3V module. So its better to use a resistive divider to bring UNO' TX to 3.3V and then feed to ESP's RX, instead of directly connecting them eachother.
- 1And conversely, the 3.3V TX pin of the ESP8266 is usually enough to drive the Uno's 5V RX pin.linhartr22– linhartr222018-01-12 02:21:19 +00:00CommentedJan 12, 2018 at 2:21
//ESP
#include "SoftwareSerial.h"SoftwareSerial ArduinoUno(D2,D3); //Rx, Txvoid setup() {Serial.begin(9600);ArduinoUno.begin(4800);pinMode(D2, INPUT);pinMode(D3, OUTPUT);}void loop() {}/******************************************************************************///UNO
#include "SoftwareSerial.h"SoftwareSerial ArduinoUno(3,2); //Rx, Txvoid setup() {Serial.begin(9600);ArduinoUno.begin(4800);}void loop() { if(ArduinoUno.available() > 0){ //float val = ArduinoUno.parseFloat(); Serial.println(ArduinoUno.read()); } delay(30);}- format your code properly (CTRL+K)MichaelT– MichaelT2019-03-02 11:24:05 +00:00CommentedMar 2, 2019 at 11:24
Explore related questions
See similar questions with these tags.




