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.
Send Serial Data to Host Using Arduino Hardware: In this model, the Arduino hardware sends data to your computer over the serial port 0 (USB port) of the Arduino hardware. This model is configured to run in Normal mode. In this mode, the model is deployed on the Arduino hardware.
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.
I want to interface Arduino Uno and ESP8266 for IoT project where i have to control the device from webpage,but before that i wanted to check the above code for Arduino to ESP8266 by Serial Communication.So interfaced Arduino Uno with ESP8266 and powered ESP8266 with External adapter with 3.3V, ESP8266 baud rate is 115200 and in the code i.
Using the Hardware Serial Ports The Teensy boards have 1 to 6 hardware serial ports, which may be used to connect to serial devices, like GPS receivers, XBee & ESP Wifi modules, Modbus controllers, serial interface displays and many other serial devices.
In this example, the baud rate of Serial 1 baud rate is set because the TX1 and RX1 pins correspond to the Serial port 1 of the Arduino hardware. If you are using any other serial port pins for communication, specify the baud rate of the corresponding serial port. Click OK to close the dialog box.
Hardware Required
Arduino or Genuino Board
Circuit
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
Arduino With 2 Hardware Serial Ports
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.