Iot 2
Iot 2
IoT Communication Models and APIs – IoT Communication Protocols – Bluetooth – WiFi –
ZigBee– GPS – GSM modules – Open Platform (like Raspberry Pi) – Architecture
–Programming – Interfacing – Accessing GPIO Pins – Sending and Receiving Signals Using
GPIO Pins – Connecting to the Cloud
IoT devices are found everywhere and will enable circulatory intelligence in the
future. For operational perception, it is important and useful to understand how
various IoT devices communicate with each other. Communication models used in
IoT have great value. The IoTs allow people and things to be connected any time,
any space, with anything and anyone, using any network and any service.
3. Push-Pull Model –
The push-pull model constitutes data publishers, data consumers, and data queues.
Publishers and Consumers are not aware of each other.
Publishers publish the message/data and push it into the queue. The consumers,
present on the other side, pull the data out of the queue. Thus, the queue acts as
the buffer for the message when the difference occurs in the rate of push or pull
of data on the side of a publisher and consumer.
Queues help in decoupling the messaging between the producer and consumer.
Queues also act as a buffer which helps in situations where there is a mismatch
between the rate at which the producers push the data and consumers pull the
data.
4. Exclusive Pair –
Exclusive Pair is the bi-directional model, including full-duplex communication
among client and server. The connection is constant and remains open till the
client sends a request to close the connection.
The Server has the record of all the connections which has been opened.
This is a state-full connection model and the server is aware of all open
connections.
WebSocket based communication API is fully based on this model.
IoT Data Link Communication Protocol
The IoT Data Link communication protocol provides service to the Network Layer. There are
various protocols and standard technologies specified by the different organization for data link
protocols.
Bluetooth
Bluetooth is a short-range wireless communication network over a radio frequency. Bluetooth is
mostly integrated into smartphones and mobile devices. The Bluetooth communication network
works within 2.4 ISM band frequencies with data rate up to 3Mbps.
1. Bluetooth Classic
2. Bluetooth Low Energy
3. Bluetooth SmartReady
The features of Bluetooth 5.0 version is introduced as Bluetooth 5 which have been developed
entirely for the Internet of Things.
o It is wireless.
o It is cheap.
o It is easy to install.
o It is free to use if the device is installed with it.
Z-Wave
Z-Wave is a wireless communication protocol with the frequency of 900MHz. The ranges of Z-
Wave lies between 30 meters to 100 meters with the data transfer rate of 100kbps so that it is
suitable for small messages in IoT applications for home automation. This communication
protocol operates on mesh network architecture with one and several secondary controllers.
o Zigbee Coordinator
o Zigbee End Device
o Zigbee Router
o Wireless
o Mesh networking
o Direct communication
o Low power consumption
o Costly
o Works with low speed within a small distance
LoRaWAN
LoRaWAN refers to Long Rage Wide Area Network which is a wide area network protocol.
It is an optimized low-power consumption protocol design to support large-scale public networks
with millions of low-power devices. A single operator operates the LoRaWAN. The LoRaWAN
network is a bi-directional communication for IoT application with low cost, mobility, and
security.
o Standard: LoRaWAN
o Frequency: Various
o Range: 2-5km (urban environment), 15km (suburban environment)
o Data Rates: 0.3-50 kbps.
RPL Protocol
RPL stands for Routing Protocol for Low-Power and Lossy Network. It is a distance-vector
protocol that supports a varity of Data Link Protocols. RPL builds a Destination Oriented
Directed Acyclic Graph (DODAG) which has only one route from each leaf node to the root.
All the traffic in this DODAG is routed through the root. Initially, each node sends a DODAG
Information Object (DIO) announcing them self as a root. This information travels in the
network, and complete DODAG is gradually built. When a new node wants to join the network,
it sends a DODAG Information Solicitation (DIS) request and root responds back with a DAO
Acknowledgment (DAO-ACK) confirming the join.
CORPL Protocol
CORPL protocol is the extension of the RPL protocol, which is termed as cognitive RPL. This
network protocol is designed for cognitive networks and uses DODAG topology. CORPL
protocol makes two new modifications in the RPL protocol. It uses opportunistic forwarding to
forward a packet between the nodes. Each node of CORPL protocol keeps the information of
forwarding set rather than parents only maintaining it. Each node updates its changes to its
neighbor using DIO messages. On the basis of this updated message, each node frequently
updates its neighbor for constant forwarder set.
CARP Protocol
6LoWPAN
The 6LoWPAN protocol refers to IPv6 Low Power Personal Area Network which uses a
lightweight IP-based communication to travel over low data rate networks. It has limited
processing ability to transfer information wirelessly using an internet protocol. So, it is mainly
used for home and building automation. The 6LoWPAN protocol operates only within the 2.4
GHz frequency range with 250 kbps transfer rate. It has a maximum length of 128-bit header
packets.
o Standard: RFC6282
o Frequency: Used over a variety of other networking media including Bluetooth Smart
(2.4GHz) or ZigBee or low-power RF (sub-1GHz)
o Range: NA
o Data Rates: NA
CoAP
CoAP (Constrained Application Protocol) is a session layer protocol that provides the
RESTful (HTTP) interface between HTTP client and server. It is designed by IETF Constrained
RESTful Environment (CoRE) working group. It is designed to use devices on the same
constrained network between devices and general nodes on the Internet. CoAP enables low-
power sensors to use RESTful services while meeting their low power constraints. This protocol
is specially built for IoT systems primarily based on HTTP protocols.
This network is used within the limited network or in a constrained environment. The whole
architecture of CoAP consists of CoAP client, CoAP server, REST CoAP proxy, and REST
internet.
The data is sent from CoAP clients (such as smartphones, RFID sensors, etc.) to the CoAP server
and the same message is routed to REST CoAP proxy. The REST CoAP proxy interacts outside
the CoAP environment and uploads the data over REST internet.
DDS
DDS (Data Distribution Service) is a middleware (sometimes called machine-to-machine
(M2M)) communication protocol. It is implemented by the Object Management Group (OMG)
standard for the real-time system with high speed and high-performance, scalable, dependable,
and interoperable data exchange. This communication protocol is based on a publish-subscribe
pattern for sending and receiving data, events, and commands among the nodes.
Hardware Requirements
Software requirements
1. Arduino software
2. Android Studio
The Android app is built to send serial data to the Bluetooth Module HC-05 by pressing ON
button. As Bluetooth Module HC-05 works on serial communication. It receives the data from
the app and sends it through TX pin of Bluetooth module to RX pin of Arduino. The uploaded
code inside Arduino checks the data received. If the receive data is 1, the LED turns ON, and if
the received data is 0 the LED turns OFF.
TX --------------------------------> RX (Pin 0)
RX --------------------------------> TX (Pin 1)
VCC --------------------------------> 5v
GND --------------------------------> GND
After successful download, run the setup and follow the instructions.
When it asks to install the driver software, click to install
After installation, open the software, and if it generates a security alert then allow it.
Write a program for Arduino UNO board, if received data is equal to 1, LED turns on and if data
is equal to 0, LED turns OFF.
1. char data = 0; //Variable for storing received data
2. void setup()
3. {
4. Serial.begin(9600); //Sets the baud for serial data transmission
5. pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
6. }
7. void loop()
8. {
9. if(Serial.available() > 0) // Send data only when you receive data:
10. {
11. data = Serial.read(); //Read the incoming data and store it into variable data
12. Serial.print(data); //Print Value inside data in Serial monitor
13. if(data == '1') // Checks whether value of data is equal to 1
14. digitalWrite(13, HIGH); //If value is 1 then LED turns ON
15. else if(data == '0') // Checks whether value of data is equal to 0
16. digitalWrite(13, LOW); //If value is 0 then LED turns OFF
17. }
18. }
Save your program and compile it.
Connect your Arduino device to your Laptop (or Monitor) via Arduino UNO USB cable.
Remove all the other connections with Arduino UNO device such as Bluetooth Module and LED
while uploading the program in Arduino UNO.
After compiling the code, upload it in Arduino UNO device. Before uploading the code in
Arduino, UNO device makes sure that your Arduino serial port is selected otherwise, it generates
an error message "Serial port not selected".
To select your serial port, open Device Manager > Ports >Arduino Uno, and then upload your
code.
Download the Android app's .apk file and install it on your Android smartphone. Click Here to
Download
GPS is a space-based satellite navigation system. It provides location and time information in all
weather conditions, anywhere on or near the Earth. GPS receivers are popularly used for
navigation, positioning, time dissemination, and other research purposes.
The GPS consists of satellites that orbit the earth. These satellites are geosynchronous with an
orbital period that is the same as the Earth’s rotation period. So they maintain exactly the same
position with respect to the earth below them.
All the GPS satellites transmit radio signals, which are then captured by a GPS receiver and used
to calculate their geographical position. A minimum of four satellites may be required to
compute the four dimensions of X, Y, and Z (latitude, longitude, and elevation) and time.
GPS receiver converts the received signals into position and estimates the time and some other
useful information depending on the application and requirements.
GPS determines the distance between a GPS satellite and a GPS receiver by measuring the
amount of time taken by a radio signal (the GPS signal) to travel from the satellite to the
receiver.
To obtain accurate information, the satellites and the receiver use very accurate clocks, which are
synchronized to generate the same code at exactly the same time.
If accuracy is important, you need GPS with a wide-area augmentation system (WAAS)
capability. This is a satellite service providing additional correction information to the GPS
receiver in order to increase its accuracy.
Before purchasing a GPS receiver, it’s good to know the protocols supported by it. Some
popular protocols for GPS receivers are:
GPS Protocols
NMEA 0183
A binary packet protocol that allows the designer to configure and control the GPS receiver for
optimal performance in any number of applications.
Designed specifically for vehicle tracking applications. It is a bidirectional protocol using simple
ASCII commands with associated ASCII responses.
GSM Modem
A GSM modem is a specialized type of modem that accepts a SIM card and operates over a
subscription to a mobile operator just like a mobile phone.
GSM modems are a cost-effective solution for receiving SMS messages because the sender is
paying for the message delivery. To perform these tasks, a GSM modem must support an
extended AT command set for sending and receiving SMS messages, as defined in the ETSI
GSM 07.05 and 3GPP TS 27.005 specifications.
It should also be noted that not all phones support this modem interface for sending and
receiving SMS messages, particularly most smartphones like the Blackberry, iPhone, and
Windows mobile devices.
The circuit diagram of a GSM and GPS-based vehicle tracking system is displayed in the figure.
It consists of a microcontroller, GPS module, GSM modem, and 9V DC power supply. GPS
module gets the location information from satellites in the form of latitude and longitude.
The microcontroller processes this information and sends it to the GSM modem. The GSM
modem then sends the information to the owner’s mobile phone.
ATmega16 microcontroller (IC2) is the heart of the project that is used for interfacing
with various hardware peripherals. It is a low-power CMOS 8-bit microcontroller based
on the AVR-enhanced RISC architecture.
ATmega16 microcontroller is interfaced serially to a GPS module and GSM modem. The GPS
module outputs many data but in this project, only the NMEA data is read and processed by the
microcontroller. The processed data is sent to the user’s mobile through a GSM modem.
This GPS-based vehicle tracking system implements RS-232 protocol for serial communication
between the microcontroller, GPS, and GSM modem. A serial driver IC MAX232 (IC3) is used
for converting RS-232 voltage levels into TTL voltage levels.
The user’s mobile number should be included in the source code written for the microcontroller.
Thus the user’s mobile number resides in the internal memory of the MCU.
If you are looking for the difference between Microprocessor and Microcontroller, you can read
it here.
In this project, we have used the iWave GPS module. GPS always transmits the data to the
microcontroller. Transmit pin TXD of GPS is connected to the microcontroller via MAX232.
NMEA defined an RS-232 communication standard for devices that include GPS receivers.
The iWave GPS module supports the NMEA-0183 standard which is a subset of the NMEA
protocol. It operates in the L1 frequency (1575.42 MHz) and provides information with an
accuracy of up to 10 meters in the open sky. The antenna should be placed in an open space and
there should be at least 50 percent space visibility.
GSM Modem
This vehicle tracking system using GPS uses a SIM300 GSM modem. GSM modem transmits
and receives the data. Modem SIM300 is a tri-band GSM/GPRS engine that works on
frequencies EGSM 900 MHz, DCS 1800 MHz, and PCS 1900 MHz.
Transmit pin TXD and receive pin RXD of the GSM modem are connected to the
microcontroller (IC2) via MAX232 (IC3). The microcontroller’s port pin PD0 (RXD) and port
pin PD1 (TXD) are connected to pins 12 and 10 of MAX232, respectively.
Power Supply
The circuit is powered by a 9V battery. 7805 regulator (IC1) is used to convert 9V into 5V. The
microcontroller and MAX232 are powered by 5V. LED1 indicates the presence of a power
supply.
An actual-size, single-side PCB for the GSM and GPS-based vehicle tracking circuit
The program for the microcontroller is written in ‘C’ language and compiled using AVR Studio.
The user’s mobile number should be included in the source code in order to receive the call from
the SIM card used in the GSM modem. The hex code of the program is burnt into the MCU
using PonyProg2000 software. You can use any other suitable tool for the same.
A GPS module with a 9600 baud rate is used to receive the data from the satellites, which is
defined in the software.
The software is developed to decode the NMEA protocol. This protocol includes a set of
messages that use an ASCII character set and has a defined format that is continuously sent by
the GPS module to the interfacing device.
The GPS module or receiver provides data in the form of ASCII comma-delimited message
strings. Each message starts with a dollar sign ‘$’ (hex 0x24) and ends with (hex 0x0D 0x0A).
The software output protocol message includes global positioning system fixed data (GGA) and
geographic position latitude/longitude (GLL). In this project, we will use GGA only.
Note that the latitude and longitude information are both represented in the ‘degrees, minutes,
and decimal minutes’ format as ddmm.mmmm.
However, most mapping applications require longitude and latitude to be expressed in decimal,
degrees, in ‘dd.dddddd’ format with a corresponding sign (negative for south latitude and west
longitude). So some kind of conversion is required in the software if you want a particular
format.
The NMEA standard explains how each message string is formed with a dollar sign ($) leading
each new GPS message.
With this data, you can find out the exact location using a map or you can use freely available
software to check the location.
The actual-size, single-sided PCB layout of the GPS and GSM-based vehicle tracking circuit,
along with its component layout, is shown in the figure
Assemble the components on the PCB with IC bases for ATmega16 and MAX232. Burn the
code into the MCU and mount it on the PCB. Insert the SIM card with sufficient balance in the
GSM module. Connect the circuit as shown above.
Testing
3. Switch on the GPS module and wait for 10-15 minutes for initialization.
5. Dial the mobile number in the GSM modem. After two rings, the ringing stops automatically.
Wait for a few seconds. You will get an SMS alert on your mobile.
6. Check your SMS inbox. You will see the latitude and longitude data in the form of SMS text.
7. Open a standard map and locate the point on the map. You can also enter latitude and
longitude values in software such as http://www.latlong.net/Show-Latitude-Longitude.html or
any other suitable software.
Further Applications
This system can also be used where the information is not needed so frequently and the subject
has to be tracked at irregular time periods, such as monitoring of adolescents by parents, in
research to track animals in the jungle, coordinating search and rescue efforts, and mapping trails
and exploring new terrains.
This article is a part of the Top 15+ Microcontroller Projects. If you want to read more projects
based on microcontrollers, you can go through this article.
Architecture of Raspberry Pi
Raspberry Pi is a small single-board computer (SBC). It is a credit card-sized computer that can
be plugged into a monitor. It acts as a minicomputer by connecting the keyboard, mouse, and
display. Raspberry Pi has an ARM processor and 512MB of RAM. The architecture of
Raspberry Pi is discussed in this article.
GSM Modules
GSM (Global System for Mobile Communications) modules are widely used in IoT (Internet of
Things) applications to enable wireless communication over cellular networks. These modules
allow IoT devices to send and receive data via SMS, GPRS (2G), EDGE (2.5G), 3G, 4G
(LTE), and even 5G networks.
1. The IoT device (e.g., Arduino, ESP32, Raspberry Pi) connects to the GSM module via
UART (serial communication).
2. A SIM card is inserted into the GSM module to access the mobile network.
3. The IoT device sends AT commands to the GSM module to perform tasks like:
o Sending an SMS (AT+CMGS="phone_number")
o Making a call (ATDphone_number;)
o Sending data over GPRS/Internet (AT+HTTPACTION=0 for HTTP GET)
4. The GSM module transmits data via the mobile network, allowing remote
communication.
Home Automation
Industrial Monitoring
Vehicle Tracking
Healthcare Monitoring
Works anywhere with GSM coverage. Requires a SIM card and cellular plan.
Supports SMS, voice, and internet. Not ideal for high-speed data applications.
Cost-effective for simple IoT applications. Newer networks (5G) may phase out 2G/3G support.
Wearables,
BLE Short Very Low Low
healthcare
Open platforms like Raspberry Pi, Arduino, ESP32, BeagleBone, and Jetson Nano are widely
used in IoT, automation, robotics, and AI applications. These platforms offer flexibility, cost-
effectiveness, and strong community support for hardware and software development.
No OS Ubuntu
OS Linux-based FreeRTOS Linux-based
(Firmware) (JetPack)
Wi-Fi,
GPIO, SPI, Wi-Fi, BLE, Wi-Fi, USB,
Connectivity Bluetooth, Ethernet, GPIO
I2C GPIO HDMI
GPIO
Industrial IoT
Robotics
Architecture of Raspberry Pi
Raspberry Pi is a small single-board computer (SBC). It is a credit card-sized computer that can
be plugged into a monitor. It acts as a minicomputer by connecting the keyboard, mouse, and
display. Raspberry Pi has an ARM processor and 512MB of RAM. The architecture of
Raspberry Pi is discussed in this article.
These are the physical pins on the Raspberry Pi that can be configured to receive data from
sensors (input) or send signals to control devices (output).
Pinout Diagram:
To understand which pins are which, consult the Raspberry Pi pinout diagram which maps
each pin to its function.
Python Library:
The most common way to access GPIO pins in Python is through the "RPi.GPIO" library,
which provides functions to set pin modes (input/output), read pin values, and write to pins.
Basic steps to access GPIO pins:
Important considerations:
Always connect your external devices to the proper power and ground pins on the Raspberry
Pi.
Pin limitations:
Check the pinout diagram to see which pins are capable of providing enough current for your
devices.
Cleanup:
When you finish using the GPIO pins, remember to clean up your code by setting the pins back
to their default state using GPIO.cleanup().
To send and receive signals using GPIO pins, you configure specific pins on a microcontroller or
similar device as either "outputs" to send signals (by setting a high or low voltage) or "inputs" to
receive signals from external devices, allowing for flexible communication with sensors,
actuators, and other components based on the digital signal levels interpreted by the
software; essentially acting as a bridge between the internal circuitry and the external world.
General Purpose:
The "G" in GPIO stands for "General Purpose," meaning each pin can be configured as either
an input or an output depending on the application needs.
Digital Signals:
GPIO pins transmit digital signals, which are represented by discrete voltage levels (high or
low) interpreted as logical 1s and 0s.
Software Control:
The functionality of a GPIO pin (whether it acts as an input or output) is determined by
software settings within the microcontroller.
Example of Sending and Receiving Signals:
Write a high logic value to the pin to send a "high" signal (e.g., turn on an LED).
Write a low logic value to send a "low" signal (e.g., turn off an LED).
Receiving a Signal (Input):
Configure a GPIO pin as an input.
Read the voltage level on the pin to determine if a signal is high or low.
Use this information to trigger actions in your program based on the input received (e.g., detect a
button press).
Applications of GPIO Pins:
Controlling LEDs: Turn LEDs on and off by setting GPIO pins as outputs.
Reading Sensor Data: Receive analog sensor readings by converting them to digital signals
using an ADC (Analog-to-Digital Converter) and reading the corresponding GPIO pin.
Interfacing with Switches: Detect button presses by monitoring the state of a GPIO pin
configured as an input.
Motor Control: Send control signals to motors using GPIO pins set as outputs.
CONNECTING TO THE CLOUD
To connect an IoT device to the cloud, you need to first register the device on the chosen cloud
platform (like AWS IoT Core, Azure IoT Hub, or Google Cloud IoT Core), which generates
unique credentials like keys and certificates, then use a communication protocol (like MQTT,
HTTP, or CoAP) to establish a secure connection between the device and the cloud, sending data
from the device to the cloud platform for storage and analysis; this usually involves utilizing an
IoT SDK provided by the cloud platform to facilitate the connection process on the device side.
Device Registration:
Register your IoT device on the platform, providing details like device ID and desired
connectivity options.
The platform will generate unique security credentials (keys and certificates) for your device.
Device Configuration:
Install necessary firmware on the device, including the IoT SDK specific to the chosen cloud
platform.
Configure the device with the cloud platform endpoint, security credentials, and communication
protocol.
Data Transmission:
Use the chosen communication protocol to send data from the device to the cloud.
Most commonly, MQTT is used for its lightweight nature and efficient data delivery.
Once data reaches the cloud, the platform can store, process, and analyze it based on your
application needs.
Important considerations:
Connectivity:
Choose the appropriate network technology based on your device's requirements (Wi-Fi, cellular,
LoRaWAN, etc.).
Security:
Implement robust security measures like encryption and authentication to protect data
transmission.
Device Management:
Utilize features provided by the cloud platform to manage device updates, monitoring, and
troubleshooting.