Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

1- Serial (UART) communications

- Consider you need to communicate with another device

- Arduino comes with built-in communication protocols

- TX: Transmit data


- RX: Receive data

- When computer is connected to Arduino UNO via USB, it communicates through


Pin 0 (RX) and Pin 1 (TX).

- If USB connection is not used, Pin 0 and Pin 1 can be used communicate with
other devices such as GPS device, etc.

- This connection is a single serial interface which means communication can be


performed at one given time between the devices.
1- Serial (UART) communications
- Arduino Mega have multiple RX and TX pins, therefore multiple
serial communication can be performed at the same time.
2- I2C or TWI communications
- It is a fast serial interface that allows devices to be connected in
a chain (operates like a bus).

- Arduino IDE which is the environment that we use to program


Arduino comes with a special library that makes the use of this
protocol very simple.

- SDA line is also implemented on pin A4, and SCL is implemented


on pin A5.
2- I2C (TWI) communications
- I2C: Inter-integrated Circuit
- TWI: Two Wire Interface

- At every clock tick, a new bit is sent through the data line.

- Every sensor or device connected to Arduino must have a unique address.


- So that the Master sends data to a specific device.

- The master can send data to all other devices at the same time and that is called
as broadcast.

- If you want to send data to a specific device, use the addressing scheme and
simply a number.

- SDA line is also implemented on pin A4, and SCL is implemented on pin A5.
- Data flows in one direction at a time.
3 – SPI (Serial Peripheral Interface)
- Much faster communication compared to TWI
- SPI is full duplex.

- Full duplex communication allows for two devices to


communicate so that information flows towards both directions
at the same time.

- SPI communication is full duplex, while I2C or TWI is half duplex.

- In SPI, there are 4 wires, in stead of 2.


3 – SPI (Serial Peripheral Interface)
- SS: Slave select
- SCK: Clock
- MOSI: Data line, Master Out Slave In
- MISO: Data line, Master In Slave Out
- If multiple sensors or devices are connected to Arduino using
SPI protocol, the data and clock lines can be shared, but a
unique slave select (SS) line must be used for each connected
device.
3 – SPI (Serial Peripheral Interface)
- Arduino will be able to talk a SPI device once at a time.

- Although you have multiple such devices, only one of those


devices can communicate with the Arduino at one time.

- SS (slave select) lines are used to turn on and off one of SPI
slaves.

- Set the line you want to communicate high (On), and set all the
other to low (Off).

- SPI library is implemented in Arduino IDE.

You might also like