Learn the Serial communication between two Arduino. How Serial read and write works. Serial Communication between two Arduino UNO Board is given in this article. You can perform this on any two Arduino Board or other serial communicating device. RX recieves serial data and TX sends the serial data to other board or device.
Step 1: Required Components
Step 2: Circuit Time
Make a circuit as per the given diagram. Connect both the RX and TX pins of Arduino vice versa (first Arduino’s TX pin to another’s RX pin and first Arduino’s RX pin to another’s TX pin). Also common the ground pin of both Arduino.
Step 3: Code Time
There are two codes for two Arduino board. One for sender and other for reciever.
Code for Sender Arduino
This is code for Sender Arduino Board. First, initialize a string with data “Hello”. In setup, the Serial Monitor is begun at 9600 Baud. In the loop, sent the data to receiver Arduino using Serial.write. For more information about Serial.write, click here.
Code for Receiver Arduino
This is code for Receiver Arduino Board. First, initialize a blank string to store serial received data. In setup, the Serial Monitor is begun at 9600 Baud. In the loop, received the data from sender Arduino using Serial.readBytes. For more information about serial.read, click here.
Step 4: Upload the code to Arduino
Upload the code to the sender Arduino code to one board and receiver Arduino Board code to other device. Make a circuit as per the given diagram after uploading code. It will transmit “Hello” from one Arduino to another Arduino board or other device. You can transmit your data or variable like this.
Learn about uploading code to Arduino Board.
Note: If it shows error while uploading code to Arduino. Then, disconnect the connection between Arduino and try to upload program on it.