Learn Serial communication between ESP8266 and Arduino. Transmit data between two ESP8266 and Arduino using RX/TX lines. How Software Serial read and write works. You can perform it on any ESP8266 and Arduino Board.
First, learn about the SoftwareSerial Library of Arduino IDE. SoftwareSerial allows serial communication on other digital pins using software to replicate the functionality. Here we are using SoftwareSerial to start Serial at 9600 Baud. In general case, the serial will start at 115200 Baud Rate because ESP8266 works on that rate.
Step 1: Required Components
Step 2: Circuit Time
Make a circuit as per the given diagram after uploading the program. Connect the RX pin of ESP8266 to the TX pin of Arduino and TX pin of ESP8266 to the RX pin of Arduino. Also, common both Grounds of ESP8266 and Arduino as per diagram.
Step 3: Code Time
These are two codes for ESP8266 and Arduino board.
Code for Sender ESP8266
This is code for Sender ESP8266. First included the SoftwareSerial Library and started SoftwareSerial at RX and TX pin. (pin no 3 and 1) In Setup, SoftwareSerial is started at 9600 Baud. In the loop, written ‘123’ to the Serial.
Code for Receiver Arduino
This is code for Receiver Arduino. First declared a variable to store received data. In Setup, Serial Begin at 9600 Baud. In the loop, read the serial data and store it in a variable.
Step 4: Upload the code
Upload the code to ESP8266 and Arduino Board. Make a circuit as per the given diagram after uploading code. ‘123’ will be transmitted from Sender ESP8266 to Receiver Arduino. You can transmit your data or variable like this.
Learn more about Serial Communication in Arduino.