Aug 09, 2019  Read about 'serial communication between arduino' on element14.com. I have two arduinos connected serially meaga and uno i have a numbers 0 to 255 in the uno i should be able to read the numbers 0 to 255 from the uno to. Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the board). Don’t connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.

Software Serial Example

Arduino and Genuino boards have built in support for serial communication on pins 0 and 1, but what if you need more serial ports? The SoftwareSerial Library has been developed to allow serial communication to take place on the other digital pins of your boards, using software to replicate the functionality of the hardwired RX and TX lines. This can be extremely helpful when the need arises to communicate with two serial enabled devices, or to talk with just one device while leaving the main serial port open for debugging purpose.

Arduino Uno To Arduino Uno Serial Communication

In the example below, digital pins 10 and 11 on your Arduino or Genuino boards are used as virtual RX and TX serial lines. The virtual RX pin is set up to listen for anything coming in on via the main serial line, and to then echo that data out the virtual TX line. Conversely, anything received on the virtual RX is sent out over the hardware TX.

Hardware Required

  • Arduino or Genuino Board

Circuit

Serial

There is no circuit for this example. Make sure that your Arduino or Genuino board is attached to your computer via USB to enable serial communication through the serial monitor window of the Arduino Software (IDE).

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematics

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Code

Serial Communication Between Two Arduino

See also

  • TwoPortReceive – Two serial ports that receive data switching from one to the other one when a special character is received.
  • MultiSerialMega - Use two of the serial ports available on the Arduino and Genuino Mega.
  • Serial Call Response - Send multiple vairables using a call-and-response (handshaking) method.
  • Serial Call Response ASCII - Send multiple variables using a call-and-response (handshaking) method, and ASCII-encode the values before sending.


Last revision 2018/05/17 by SM

Arduino Software Serial Tutorial

Description

Arduino To Arduino Serial Communication Protocol

Used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART), and some have several.

BoardUSB CDC nameSerial pinsSerial1 pinsSerial2 pinsSerial3 pins

Uno, Nano, Mini

0(RX), 1(TX)

Mega

0(RX), 1(TX)

19(RX), 18(TX)

17(RX), 16(TX)

15(RX), 14(TX)

Leonardo, Micro, Yún

Serial

0(RX), 1(TX)

Uno WiFi Rev.2

Connected to USB

0(RX), 1(TX)

Connected to NINA

MKR boards

Serial

13(RX), 14(TX)

Zero

SerialUSB (Native USB Port only)

Connected to Programming Port

0(RX), 1(TX)

Due

SerialUSB (Native USB Port only)

0(RX), 1(TX)

19(RX), 18(TX)

17(RX), 16(TX)

15(RX), 14(TX)

101

Serial

0(RX), 1(TX)

On Uno, Nano, Mini, and Mega, pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board.

Arduino To Arduino Serial Communication Library

You can use the Arduino environment’s built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to begin().

Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the board). Don’t connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.

To use these extra serial ports to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega’s USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device’s RX pin, the RX to your device’s TX pin, and the ground of your Mega to your device’s ground.