Realbasic Serial Communication Arduino
One of the most basic communication protocols in electronics is the Universal Asynchronous Receive Transmit (UART) serial protocol. The UART protocol allows for two devices to communicate with each other. The protocol requires two wires between the devices that are communicating; one for each direction of communication. Each device has an independent transmit and receive module. These modules do not have to be in time with each other (i.e. asynchronous). When a device transmits, it sends data as a series (i.e. serially) of pulses. Each pulse represents one bit of data, so a byte (8 bits) of data is sent as eight pulses on the wire. These pulses are sent with a particular, predefined timing called a baud rate that must be understood by both devices.
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.
Hardware
- RS-485 Serial Communication. RS-485 is an asynchronous serial communication protocol which doesn’t not require clock. It uses a technique called differential signal to transfer binary data from one device to another. It provides a Half-Duplex communication when using two wires and Full-Duplex requires 4 fours wires. Connecting RS-485 with Arduino.
- Aideepen 2pcs HC-05 Wireless Bluetooth Serial Transceiver Pass-Through Module Slave and Master 6 Pin Serial Communication for Arduino. 4.1 out of 5 stars 37. Get it as soon as Mon, Sep 16. FREE Shipping on orders over $25 shipped by Amazon. Only 17 left in stock - order soon.
For two devices to communicate with UART serial, three wires have to connect them. The first two are communication wires. The transmit (TX) of the first has to connect to the receive (RX) of the second and the TX of the seconds to the RX of the first. The third wire is ground. The devices have to have a common ground reference, or the pulses may not be going from 0V to 5V. It might look like -5V to 0V, which would not register as pulses to the other device.
The TX and RX pins of an Arduino board are pins D0 and D1. They are labeled TX and RX, and they are connected to the UART-USB bridge of the Arduino board. This means that, when the board is connected to the computer through USB, the UART of the Arduino board is already wired to a virtual serial port on the computer (i.e. COM3). This allows the board to send and receive serial data with a serial terminal on the computer.
Arduino IDE
Setup
In order to use UART serial in the Arduino IDE, you have to initialize the serial module. The default setup only requires calling the Serial.begin() function. Serial.begin() requires that your desired baud rate be put into the function as an argument.
2 4 | Serial.print(array1);// Will transmit the values 4, 8, 16, 23, and 42 Serial.print('CAT');// Will transmit the ASCII values for 'C', 'A', and 'T' (67, 65, 84) |

Serial.println()
This is exactly the same as the Serial.print() command except that it adds a new line/carriage return character to the end of the string of bytes.
2 | receivedByte=Serial.read();// Returns the first byte from the serial buffer |
Serial.available()
Returns the number of bytes that are currently available in the serial buffer.