Go Down

Topic: Two arduino communication (serial) (Read 760 times) previous topic - next topic


Mar 19, 2013, 10:02 pm Last Edit: Mar 19, 2013, 10:10 pm by lutecky Reason: 1
I'm looking for and I can't find the library for serial two-way communication between the Arduino's. I need to send a few bytes of data to a second arduino, interpret them and send a reply, which will also be interpreted...


So why do you need a libary to do that?


Mar 19, 2013, 10:29 pm Last Edit: Mar 19, 2013, 10:30 pm by Erdin Reason: 1
If you have Arduino boards with a single serial port (Uno, Nano, mini) you can use SoftwareSerial, http://arduino.cc/en/Reference/SoftwareSerial
Create a TX and RX on both boards with SoftwareSerial, and connect TX to RX, and RX to TX. Don't use pin 0 or 1 (RX and TX for serial monitor and upload), and maybe also not 13(led). That's all.

If you have a Mega, you have more serial ports, Serial1 and more.
If you have a Leonardo or Micro, use the Serial1 port on pin 0 and 1.
For the Mega, Leonardo and Micro, use the standard Serial library, http://arduino.cc/en/Reference/serial


So why do you need a libary to do that?

I have arduino uno (1) and mega (2) and I make connections:
1(rx) - 2(tx)
1(tx) - 2(rx)
1(5v) - 2(5v)
1(gnd) - 2(gnd)

In 1 I wrie:
void setup(){
void loop{

And in second arduino:
void setup(){
void loop{

When I connect second arduino to usb and open console I see nothing. Rx/tx leds dont blink...


The RX and TX LEDs are not controlled by the data input and output of the arduino. They are controlled by the USB host, so if you have not got them connected to a computer you will not see them blink.

Read the how to use this forum sticky before trying to post any more code.


When I connect second arduino to usb and open console I see nothing.

Because there are no Serial.print() statements on the second Arduino.

Using the one serial port, do you want to talk to the PC or the other Arduino? Yes is not the correct answer.
The art of getting good answers lies in asking good questions.


PaulS is right. You should first think about what you want to do.
I prefer do keep the normal serial port for the Arduino serial monitor and to upload sketches.
To communicate between the both, use other serial ports.
The Mega has extra serial ports, and the Uno could use SoftwareSerial.

If you want serious advice, please upload the complete sketches between code tags. Also let us know which pins you are using, perhaps you could make a photo of it.


You should consider the Wire library as well.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131