An Arduino’s magic happens when it communicates with the world around it. We humans can communicate using different languages or gestures. Similarly, machines like the Arduino boards communicate using specific communication protocols. In this post, we are going to learn about these communication protocols for an Arduino. Both wired and wireless. Additionally, we will take a look at all the functions, applications, advantages, and disadvantages of the top 5 wireless communication protocols.
What are the methods of communicating with an Arduino?
Communication is an important process for transmitting and receiving data from and to the Arduino while doing projects. Moreover, there are hundreds of protocols available for performing this data exchange between an Arduino and other devices by using both wired and wireless pathways.
We can classify all these protocols into two broad categories:
- Parallel communication
- Serial communication
What is parallel communication?
Parallel communication transfers multiple bits simultaneously. Because of this, they can transfer a large amount of data by using large chunks of 0’s and 1’s. For short distance data transmission, the best option is to use parallel communication using input and output ports. Furthermore, it will work up to several meters.
In the case of long-distance communication, we do not use parallel communication. To overcome this disadvantage of parallel communication, we can use serial communication.
What is serial communication?
In serial communication, we send off one bit at a time through a communication channel or a computer bus. Serial communication is slower than parallel communication. However, it’s simpler to implement. Moreover, it uses fewer pins. Many serial communication protocols work on as less as two wires.
As we learned in our embedded systems course, pin real estate is a significant factor when we design systems. And we need to make sure that our job gets done without requiring a lot of pins. Hence, serial communication is often chosen over parallel communication in small scale Arduino projects.
What is wired serial communication?
There are serial communication protocols that use physical wires to connect with peripheral devices like sensors or Arduino shields. All of these protocols can again be broadly classified as asynchronous and synchronous.
Recall from our microprocessor course; any digital system generally needs a clock to sync all the elements up to. In that case, the devices are said to be communicating synchronously. In asynchronous communication, a clock is not present. Instead, other methods are used to ensure that the communicating devices are on the same page with regards to transmitting and receiving messages. We will take a look at these methods shortly.
For all practical purposes, know this. Synchronous communication is very dependable but requires extra wires. Asynchronous communication has some overhead in terms of making sure the participants understand each other. But it saves up on pin real estate.
Let’s take a look at the following standard communication protocols.
What is UART?
UART is abbreviated as Universal Asynchronous Receive Transmit. It is a serial protocol. It allows two devices to communicate with each other. Hence, it requires two arguments that represent both the directions of data communication.
All devices have their transmitters and receiver. They are asynchronous and can send data as a series of pulses serially. Moreover, A pulse can represent one bit of the data. Arduino can send these pulses with a fixed baud rate that both the devices should be able to understand.
There are three wires to be connected.
First two wires are for communication.
Then, The transmitter of the master can be connected with the receiver of the slave (any peripheral device that is controlled by a processing unit is known as a slave)
The receiver of the Arduino can be connected with the transmitter of the device.
The third wire can be connected with the ground.
Some of the factors that determine the UART communication are:
It is defined as the rate of data transmission in the channel. The default baud rate is generally 9600 bps. This means that the device is communicating at a speed of 9600 bits per second.
In UART, data is sent in a data frame that is also known as packets. It includes the main data together with some information to ensure accurate communication.
What are the advantages of the UART communication protocol?
- UART has a low hardware complexity.
- It doesn’t require software addressing.
- This protocol is widely used in 9-pin connector
What are the disadvantages of the UART communication protocol?
- It supports communication only between two devices.
- In the UART protocol, the data rate is fixed.
What is SPI?
SPI is abbreviated as Serial Peripheral Interface. It is asynchronous as well as serial data protocol. What does that mean? While Arduino uses SPI to communicate with other devices quickly. But the restriction is it will work only in short-range communication. Why? Isn’t serial meant for long-distance?
Usually, an SPI connection is run by a microcontroller that controls other peripheral devices. For example, in the Arduino Uno, the SPI communication protocol is handled by its microcontroller. Hence, it contains four lines that are common for all peripheral devices.
- MISO – It is abbreviated as Master In Slave Out. It is the line that sends data to the Arduino.
- MOSI – Stands for Master Out Slave In. Master Output and Slave Input. So this is the line that takes the Master’s output and gives it as input to the slave.
- SCK – Which is abbreviated as Serial Clock that produces clock pulses. This is used to synchronize data transmission from Arduino.
- SS – that is abbreviated as Slave Select. It can be used by the Arduino to enable and disable a particular peripheral device.
When the SS pin is low as 0, the peripheral will start to communicate with the Arduino. Whereas, it will ignore the Arduino instructions when it is high (1).
SPI lines in Arduino Uno and mega board.
SS (slave pin)
SS (master pin)
|Arduino Uno||11 or ICSP-4||12 or ICSP-1||13 or ICSP-3||10||–||5V|
|Arduino Mega||51 or ICSP-4||50 or ICSP-1||52 or ICSP-3||53||–||5V|
What are the advantages of the SPI protocol?
- SPI protocol is more flexible for bit transmission
- Hardware interfacing is straightforward
- SPI protocol is very much faster than asynchronous serial
- you can connect multiple slaves
- It helps full-duplex communication
- It doesn’t need any transceiver
What are the disadvantages of the SPI protocol?
- SPI protocol requires more pins
- You can’t add nodes dynamically
- This protocol supports only one master device
- SPI protocol doesn’t have any error checking mechanism
What is I2C?
In short-range communication, we can use I2C communication. It contains a synchronized clock pulse. It is mainly used for communication with various sensor devices that can fetch the data to the Arduino. Where I2C is abbreviated as Inter-Integrated Circuits.
Arduino pin for I2C line
For I2C communication, we can use the Wire library. It has many built-in functions that will help with I2C communication with peripheral devices.
What are the advantages of the I2C communication protocol?
- I2C is more flexible
- You can use chip addressing. That you can easily add components to the bus.
- Less complexity and the design is elementary
- It has better error handling mechanism
- I2c protocol is readily adaptable
What are the disadvantages of the I2C communication protocol?
- I2C always has an address conflict due to chip addressing
- Speed is limited
- It requires more space
What is Ethernet?
Ethernet is the facility to connect the Arduino with the Internet. It requires a special library. The Arduino board can serve as either a server that host and accepts incoming network connections or a client that making outgoing connections
The ethernet protocol is available as a module and also as a shield for establishing an internet connection to the Arduino.
What are the advantages of the Ethernet communication protocol?
- Comparatively low cost
- All nodes have equal privileges
- Ethernet protocol doesn’t need any hubs or switches
- It requires little maintenance and administration
- More robust to external noise
What are the disadvantages of the Ethernet communication protocol?
- Ethernet provides nondeterministic service
- It doesn’t give priority for packets
- This protocol doesn’t help in a client-server architecture
- It is not useful in traffic-intensive projects
- The receiver doesn’t send any acknowledgement after receiving the packets.
- Difficult to troubleshoot the problem
What is Wireless serial communication?
Serial wireless communication helps to transfer the data wirelessly, without any physical contact with the device that receives.
Some of the wireless protocols are mentioned below,
What are the top 5 wireless protocols for communicating with an Arduino?
Among various wireless protocols, the top 5 protocols for wireless serial communication are given below,
What is Wi-Fi?
Today we communicate with each other using mobile phones which is a wireless communication device. Hence, it helps us to communicate with our friends at any place and at any time. How about sharing a data to a machine from a distance wirelessly. Whereas, it is possible the Wi-Fi protocol. You will need a library file named SoftwareSerial.h for working with this protocol.
ESP8266 is an UART-Wi-fi module used for establishing Wi-fi serial communication. That can be controlled from your local network or the internet. Hence, ESP8266 is a device that uses wi-fi technology to send and receive data wirelessly, particularly for Arduino purposes. While it uses radiofrequency to send and receive data, it can work both as an access point and also as a station.
It is functioned by using Wi-fi that one of the wireless communication technology. Wi-Fi is a family of radio technologies commonly used for wireless local area networking (WLAN) of devices. Wi-Fi is abbreviated as “Wireless Fidelity”. Above all, It uses radio waves to provide network connectivity without the use of any cables or wires. It must have three components that are radio signals, antenna, and router.
The antenna transmits the radio waves and routers that signals take up by Wi-Fi receivers. Therefore, it can communicate with both 2.4 GHz devices and 5 GHz devices.
- It gives Internet Access to your Arduino board.
- It provides hotspots
- Wi-Fi controlled remote car.
- It enables direct computer-to-computer communications
- Furthermore, it helps in IOT based home management system
- It is essential one in drone control
- You can turn On /Off any device using Windows remote Arduino
Advantages of using WiFi for Arduino
- It highly secure to transfer
- Data transmission occur at high speed than other wireless protocols
- Moreover, it has expandability.
- Additionally, this protocol is mobile
- It has mobile access
- Above all, Wi-fi is flexible to use
- Cost is less
- Your Arduino can work at any location that you can get a signal.
Disadvantages of using WiFi in your Arduino projects
- Wi-Fi uses a 2.4 GHz spectrum, that is crowded with other devices.
- 11n doubles the radio spectrum/bandwidth (40 MHz)
- Furthermore, It has a high power consumption
- Speed is slower than cable transfer
- Above all, Wi-Fi has a limited network range
What is Bluetooth(BLE)?
Bluetooth is a wireless communication protocol that uses radio waves for transmitting data. Hence, It is one of the most widely used wireless protocols in IoT. It is suitable only for short-range communication. Blue tooth is available on our cellphones, smartphones, and computers. Moreover, This protocol has a frequency range of 2.4GHz. That Bluetooth is backward compatible,
Though it is low cost and it consumes low power. It can work up to 10 meters. Therefore, it is used to establish a network with nearby devices. It supports IEE802.15.4.
Bluetooth launched its latest version as Bluetooth 5.0 that is used in wireless headphones, keyboards, mouse and IoT applications. The upgraded Bluetooth version 5.0 has some improvements compared to traditional 4.0 and previous 4.2. You can experience the features of Bluetooth 5.0 only when you use Bluetooth 5.0 enabled peripherals. Otherwise, you can’t see the exact features of Bluetooth 5.0. Because the peripherals are in the older version as Bluetooth 4.2. The main improvement in Bluetooth 5.0 is a low energy specification.
It helps the peripheral devices to work with low power consumption because Bluetooth is mostly used in wearable devices. Another main advantage of Bluetooth 5.0 is that it can be connected to two devices at the same time. Whereas, The speed of data transmission and the range is also improved when compared to the previous standards.
Bluetooth 5.0 has the data transmission speed up to 2Mbps, which is two times greater than Bluetooth 4.2. Moreover, It can communicate up to 240 meters while the previous standard Bluetooth 4.2 has only a 60 meters range.
Applications of BLE
- It is used in wireless headsets.
- BLE is used to transfer files between two devices such as mobile phones and computers.
- It is used in cell phones, smartphones, and laptops for transferring data wirelessly.
- Additionally, It is used in personal digital assistant.
- It is also used in printers to receive files to be printed.
- Wireless networking between two laptops requires little bandwidth. In this case, Bluetooth will be used.
Advantages of using Bluetooth for your Arduino projects
- It is cheap and cost-efficient.
- BLE is straightforward to install and use.
- It is used for both voice and data transfer
- The range of BLE is higher than Infrared communication.
- It can avoid interference with other wireless devices.
- Power consumption is low.
Disadvantages of using Bluetooth for your Arduino projects
- It can be easily hacked
- The bandwidth of BLE is lower than Wi-Fi
- Furthermore, data security is low.
- It can only support short-range communication.
- Only two devices can be connected at the same time.
- Moreover, It can lose connection in certain adverse conditions
You can get a more in-depth overview to the Bluetooth Wireless Protocol here.
What is Thread?
Thread is one of the wireless serial communication protocols that is an open standard. It is built on IPv6 and 6LoWPAN protocols. It is an IPv6- based networking protocol that helps low-power internet of things devices in an IEEE 802.15.4-2006. Which is a wireless mesh network? Another name of Thread is Wireless Personal Area Network (WPAN). Therefore, Thread is independent of other mesh networking protocols.
Whereas, it is an open-standard reliable, cost-efficient, and low power and wireless communication protocol.
Hence, this protocol has the following features,
Application areas of the thread communication protocol
- It will play a major role in home automation
- Above all, It has more advantages in remote access field
Advantages of the thread communication protocol for Arduino
- It is a standard-based protocol.
- Thread has a simplified configuration.
- It messages based on IP.
- This protocol has low-power consumption.
- It is scalable.
- Hence, It is interoperable.
- It is highly secure.
- Moreover, It is IP based, so it is easy to connect with other IP based networks.
Disadvantages of the thread wireless protocol for Arduino
- It is a very new network protocol, so it needs some time to establish itself
- Moreover, It is not a very DIY-friendly protocol because it is very complex.
What is MQTT?
The abbreviation of MQTT is Message Queuing Telemetry Transport. It is simply a messaging protocol that helps devices with low- bandwidth. Notably, It plays a major role in the Internet of Things applications.
We can use it as a machine to machine IoT connectivity protocol. Hence, It is a lightweight publish and subscribe messaging transport protocol. Above all, you can use it for connections that have remote locations.
MQTT is one of the most commonly used protocols on the Internet of Things. Whereas, It enables the resource-constrained IoT devices to publish and send information as a message broker. Therefore, it is the best choice for wireless communication that involves varying latency due to occasional bandwidth.
MQTT client is any device that can connect to an MQTT over a network using the MQTT library. It is a low-overhead protocol that strongly considers the bandwidth and CPU limitations. It usually runs over TCP/IP. Hence, the MQTT gateway is an Ethernet gateway that has a modified software that makes it ac an MQTT client.
Applications of MQTT protocol
- It enables the system to react to changes based on Facebook notifications.
- It helps in push-style messaging that helps low power mobile phones.
Advantages of MQTT wireless communication protocol for Arduino
- It can carry any type of data.
- MQTT is highly reliable.
- It can publish and subscribe model in a power-efficient way.
- Additionally, It has robust communication that can decouple both the device and the subscribing server.
- It is a time-efficient protocol.
- Moreover, It is a low-overhead protocol.
- It is a lightweight communication protocol.
- Above all, It minimizes network bandwidth.
Disadvantages of MQTT wireless communication protocol for Arduino
- Usually, MQTT operates using TCP, but TCP helps devices that have more memory capacity as well as more processing power. That is greater than any other lightweight, power-constrained IoT devices. While TCP uses more handshaking to set up the communication links before transferring the message. It will stimulate the wake-up and communication times. That affects long-term battery consumption.
- Moreover, it has a centralized broker that can limit the scale. Broker affects the scale when there is additional overhead for their peripheral devices.
What is GSM?
The abbreviation of GSM is Global System for Mobile communication standard that is developed by European Telecommunication Standards Limited, which describes various protocols. That helps to achieve second-generation digital cellular devices used by mobile phones.
Therefore, It can digitize and compress the data. It is a digital cellular technology to transmit mobile voices and services. Moreover, GSM uses Time Division Multiple Access (TDMA) for transmitting data is narrowband Time Division Multiple Access(TDMA)
Standards for cellular technology have evolved as 2G,3G,4G,5G.
What is 2G?
2G refers to second-generation cellular technology. Correspondingly, it uses CODEC, which is compression and decompression algorithms to compress and multiplex voice data. Besides, Using this technology, 2G can hold a large number of calls per amount of bandwidth. And also it offers SMS and email services.
It uses low powered radio signals. That requires less battery power.
What is 3G?
3G refers to third-generation cellular technology. It was introduced in 2000. Still, It increases data transmission from 144 kbps to 2 Mbps. As a result, there is an increase in bandwidth for smartphones. It allows simultaneous use of speech and internet data service. So 3G enables the operators to give a wide range of advanced services to the users than earlier GSM and GPRS systems.
What is 4G?
4G refers to fourth-generation cellular technology. Whereas it can provide 100Mbps to 1Gbps speed. MAGIC is another name of 4G. Hence, The abbreviation of MAGIC is ‘Mobility Support Integrated Wireless Solution’.
You can use 3G and 4G for IoT devices. But it needs a constant power source.
What is 5G?
5G refers to fifth-generation cellular technology. In reality, it will play an important role than previous standards. Though it won’t be released for the next five years. It is not only for interconnecting people. Moreover, it is to interconnect and control machines. It will deliver multi Gbps peak rates with very low latency.
Application areas of GSM
- 2G helps to provide services like text messages, picture messages, and multimedia services.
- 2G provides enough security for both the sender and receiver.
- In 2G, It encrypts all text messages digitally.
- 3G plays a vital role in voice telephony, mobile internet access.
- Furthermore, 3G enables video calls and mobile TV
- 3G supports data transmission rate at least 144 kbit/s
- 4G provides high-speed internet connections
- Additionally, 4G helps to deliver intensive, interactive user services.
- Particulary, 4G enables multiple user video conferencing.
- Above all, 4G helps in location-based services.
- 4G is helpful in telemedicine.
- 4G has applications in HDTV.
- 5G has constant connections with minimal lag times.
- Notable, 5G has increased bandwidth.
- In general, 5G can compile and compute data faster than others
- Whereas, 5G has faster download and upload speeds.
Advantages of GSM for Arduino
- GSM has Improved spectrum efficiency
- It supports international roaming
- GSM provides High-quality speech
- 2G modules are readily available with lots of documentation.
- It has Compatibility with Integrated Services Digital Network (ISDN) and other telephone company services
- 3G provides faster communication.
- It can send and receive large email messages
- GSM provides high-speed web service with more security
- Specifically, 3G can support video conferencing
- For interfacing with Arduino, 3G and 4G are better than 2G. Because 3G and 4G have more coverage than 2G.
- 3G and 4G can receive the data even in low coverage areas
- It supports TV streaming, mobile TV and phone calls.
- It has broadband capabilities
Disadvantages of GSM for Arduino
- Power consumptions are very high.
- 2G GSM/GPRS is almost dead in the USA.
- There are not a lot of 4G modules are available for DIY users
- 4G need complicated hardware
- Notably, the equipment required to implement next-generation network using GSM is costly
- It can cover a distance of up to 2 meters (in indoor) and 300 meters (outdoor). It is due to higher losses at high frequencies (such as millimeter waves). 5G wave may suffer many such losses (penetration loss, attenuation due to rain, foliage loss, etc
- The range of 5G is only 2 meters (in the door) and 300 meters(outdoor). It is due to massive loss in frequency. The 5G wave suffers many losses such as penetration loss, attenuation due to rain, foliage loss.
- 3G has more reduced coverage than 2G.
- In India, It is a little bit difficult to buy 2G sim. Because network companies almost stopped 2G production.
- Fee for 3G Licenses Services are expensive.
- Notable, it requires a higher bandwidth.
Factors that help to choose the appropriate protocol for our IoT projects
- How many devices that the Arduino board has to exchange data with?
- How speed data transmission has to occur?
- What is the distance between the devices and Arduino?
- Is it necessary to send and receive the data simultaneously?
How to choose the right wired communication protocol for your Arduino project?
- For communication with sensors, I2C is the right choice.
- I2C is very useful while doing communication with a large number of modules with a minimum amount of wires.
- For long-range communication, we can use RS232.
- In the case of reliable communication, we can use an SPI protocol.
- If the need is short-range communication, SPI protocol is enough for getting the desired outcome.
How to choose the right wireless communication protocol for your Arduino project?
- Power consumption plays a vital role in choosing wireless protocols.
- Data transmission speed
- Range of communication, the distance between the devices
- Environment factors.
- The number of devices that can be connected
- Bit rate.
- Quantity of data.
Other popular wireless communication methods for an Arduino IoT project
- Z wave