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 boards or another serial communicating device. RX receives serial data and TX sends the serial data to other board or device.
Step 1: Required Components
Arduino UNO Board x 2
Jumper Wires
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 boards. One for the sender and other for the receiver.
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. Learn more information about Serial.write.
Code for Receiver Arduino
This is code for the 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, the received the data from sender Arduino using Serial.readBytes. Learn more information about Serial.read.
Step 4: Upload the code to Arduino
Upload the code to the sender Arduino code to one board and receiver Arduino Board code to another 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 the program on it.
Arduino: 1.6.5 (Windows 8.1), Board: “Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)”
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega C:\Users\Owner\AppData\Local\Temp\build8801446510065506591.tmp\Sender.cpp -o C:\Users\Owner\AppData\Local\Temp\build8801446510065506591.tmp\Sender.cpp.o
Sender.ino:1:17: error: initializer-string for array of chars is too long [-fpermissive]
initializer-string for array of chars is too long [-fpermissive]
Sorry for the issue. Try the new code. It will work correctly.
Where is the new code
Can sensor readings be transmitted from one Arduino to the other in this way?
Yes, any variable data can be transmitted using this method.
I have followed your tutorial but I when I check serial monitor of the “receiver” I have no output. Any ideas on what I could be doing wrong? The “sender” is outputting hello. But reciever Uno is blank.
Switch around USB cords for sender and receiver
My sender serial monitor is correct, my “reciever” has no output. Any ideas what I could have got wrong?
Please connect TX pin of sender Arduino to RX Pin of receiver Arduino. For more details please share your screenshots to [email protected]
My serial monitor shows:
oouoo
oouo⸮
⸮ouoo
oouoo
o⸮uoo
oou⸮⸮
⸮ouoo
⸮ouoo
o⸮]⸮⸮
⸮⸮
ouo⸮o
uoooo
uooo⸮
⸮⸮⸮⸮
Hello,
It looks like the issue of Baud rate. Is it the same for both? Also once check for the Serial Monitor Baud rate.
Is there a way to transmit on the TX1,RX2 pins and the other one on the Arduino Mega??
Can you describe it again? We didn’t get what you are trying to say is.
I also get output like sender will print hello but receiver output blank .
i connect tx to rx and rx to tx
what should i do next?
Switch around sender and receiver USB ports
can you please tell me that how can I upload my code with this communication code.i mean im using ultrasonic sensors and voice modules using two arduinos so that if sensor detects any obstacle then it will say turn left or right… so its not possible using one arduino how can i communicate it with two arduinosss.. plzz help me its very urgent.
How we can send sensor data from arduino sender to receiver?
Using serial communication transfer the data between two
data files using Arduino
I was following your instruction above. Then i try to sending little bit longer word. The receiver was receiving the word, but when sender sending the word again some character has missing. Can you help with this issue?
How would you implement it when using a flex sensor in one arduino and a servo in the other. Im trying to make it work using the serial command but to no avail
Anyone interested in doing Arduino to Arduino serial communication, check out this library that handles all of the difficult parsing for you (it even includes delimiting, Consistent Overhead Byte Stuffing (COBS), and Cyclic Redundancy Checking (CRC)): https://github.com/PowerBroker2/SerialTransfer
I need to Send a Data from one arduino to another, after the second arduino read this Data, it will resolve a math equation and I need to send the result of this equation back to the first arduino.
is it possible by TX/RX communication?
You can easily do this with help from this library: https://github.com/PowerBroker2/SerialTransfer
How to use the received data as a integer. And send a data as a integer. Or can we use char as a integer. Please reply
Hi, thanks for the tutorial. I’ve tried and it works.
How about if i want to send an integer array over serial from one arduino to other arduino? is that possible?
Thanks !
Can I merge two arduino uno board by serial communication to increase I/O pins to control 4 dc motors and 4 servo motors simultaneously?
Is it possible do do this with an Arduino Uno and a Particle Photon board? Thanks.
thank you very much..! all the methods u suggested are very much useful ,as i have to write chemical reactions frequently..
Thanks for the wonderful article. Thanks for sharing