Wednesday, 25 March 2020

IoT- Part- 4- IoT Communication Protocol


Implementation of IoT is of no use unless or until we overcome some existing problems. As we are very much familiar with the most widely used HTTP (HyperText Transfer Protocol) and its "request and response architecture", just imagine implementing this architecture for just sending the data of one bit to someone. Below is some point we can figure out from this protocol that will create a problem for us.
  • Power Consumption.
  • Range
  • Data-rate
  • Security
  • Operational Cost
Most importantly we need an addressing format for the communication between two end-points over the internet which is IP address.

Let us see what are most widely protocol that is able to overcome with this problem.

6LowPan

  • 6LowPan is a combination of the latest version of  IPv6 and 'Low Power Personal Area Network' which makes enable a small device to send data over internet protocol.
  • Header Compression Mechanism is made lightweight, which means IP header is compressed in data packets before it is transmitted which also reduces the consumption of bandwidth during the transmission of RTP (Real-Time Transport Protocol) or TCP (Transmission Control Protocol).
  • In Header Compression Mechanism at initial (head) of each data packet, information of destination is stored (IP address).
  • Range - Approx 115 meters with a single antenna. 
  • Data Rates - Fixed data-rate of 250 kbit/s.
  • Standards - RFC 6282, CC2538, CC1200, CC2592, CC1190.
  • These standards are having freedom from frequency bandwidth and physical layer i.e 6LowPan is not something related to hardware rather just a concept such as IPv4 and IPv6 so it can be used on global multi-communication platforms such as blue-tooth, WiFi, and Ethernet.

Wireless Communication Protocols:

Bluetooth
  • Wireless technology designed for data transfer between two fixed devices at a short distance using UHF (Ultra High Frequency) wavelength.
  • Standard:- Bluetooth 4.2 core specification.
  • Frequency:- 2.4GHz ISM (Industrial Scientific Module).
  • Range:- 100 - 110m (Class 1), upto 10m (Class 2) used in headset.
  • Data rate:- 2 - 3 Mbps for Smart / BLE (Bluetooth Low Energy).
  • Power Consumption:- 30mA approx.
  • Used in:- phones, camera, tv, speaker, etc.

Wi-Fi (Wireless Fidelity)
  • Member of wireless technology family designed to provide wireless internet and network-connections at high speed.
  • Standard:- 802.11n.
  • Frequency:- 2.4GHz & 5GHz (Most commonly used).
  • Range:- up to 50m approx.
  • Data rate: 600 Mbps, 802.11-ac - 500 Mbps to 1 Gbps.
  • Power Consumption: For wifi router 2 - 20 watt (6-watt average).
  • Used in:- wireless router, internet access, local area wireless network, etc.

ZigBee
  • A small device designed for creating own personal area network for exchanging data between many to many devices.
  • Standard:- Zigbee 3.0 based on IEEE 802.15.4.
  • Frequency:- 2.4GHz.
  • Range:- 10-100m approx.
  • Data rate: 250 Kbps.
  • Power Consumption: 18mA (while receiving), 25.8-33.6mA (while transmitting).
  • Used in:- M2M Communication, communication between multiple sensors, etc.

Cellular
  • A communication network where the last link is wireless and data is transmitted using at least one fixed-based transmitter station specially designed for transmitting voice, text, or other types of data. This transmitter provides the services to devices that are under coverage. 
  • Standard:- GSM/ GPRS/ EDGE (2G), UMTS/ HSPA (3G), LTE(4G).
  • Frequency:- 900/ 1800/ 1900/ 2100 MHz.
  • Range:- 6-12 km (GSM), 3-6 km (HSPA), 35-72 km (LTE).
  • Data rate: 9.6 Kbps (GMS), 42 Mbps max (HSPA), Uplink 100 Mbps Download 50 Mbps (LTE).
  • Power Consumption: N/A.
  • Used in:- Mobile phone for voice or other content data transfer, etc.

NFC (Near Field Communication)
  • NFC is a modified version of RF-ID, which is a set of the communication protocols between two electronics devices any one of them being portable (smartphone) by bringing them closer up to 4cm, mainly developed for the contactless payment transaction.
  • Standard:- ISO/ IEC 18000-3.
  • Frequency:- 13.56 MHz (ISM).
  • Range:- up to 10 cm max.
  • Data rate: 100- 420 Kbps.
  • Power Consumption: 40mA while active, 3-5mA while in sleep.
  • Used in:- Wireless communication in mobile phones, payment transactions, etc.

SigFox
  • Developed for long-range communication between IoT devices. Specially designed for many M2M (machine to machine) applications that require low level of data transfer because using WiFi range is too short and cellular is expensive also consumes too much power.
  • Uses technology called UNB (Ultra Narrow Band) designed to handle low-data-transfer speeds of 10 to 1000 bps (bits per second).
  • Standard:- Sigfox.
  • Frequency:- 900MHz.
  • Range:- 30-50m (rural), 3-10m (urban).
  • Data rate: 10-1000 bps.
  • Power Consumption: 50 µwatt also having standby time of 20 years with 2.5 Ah battery.
  • Used in:- Electricity meters, smart watches, etc which need to run continuously for emitting small amount of data.

LoRaWAN (Long Range Wide Area Network)
  • Lorawan is a competitor of SigFox. It is a media access control (MAC) layer protocol designed for large-scale public networks with a single operator. 
  • Supports large network with millions of devices, highly used in the tracking system.
  • Tata group of Industries has taken license to sell LoRa chips also it is only company deploying the LoRa network in India.
  • Standard:- Lora Alliance.
  • Frequency:- ISM band 868 MHz & 915 MHz.
  • Range:- 2-5 km in dense urban, up to 15 km in suburban areas.
  • Data rate: 0.3-50 Kbps.
  • Power Consumption: Have deep sleep mode technology which extends battery life upto 10 years.
  • Used in:- Mobile Network Operator, Single Coordinate network, Gateway framing, up-down link acknowledgment, etc.

NB-IoT (Narrow Band - IoT)
  • Radio technology device developed for Low Power Wide Area Network (LPWAN).
  • This wide range of devices & services is to be connected using cellular telecommunication bands.
  • Standard:- 3GPP (Generation Partnership Project).
  • Frequency:- Licensed LTE.
  • Range:- up to 15 km approx.
  • Data rate: 100 KBps.
  • Power Consumption: 74-220mA (while transmitting), 46mA (while receiving).
  • Used in:- Smart metering (Gas, water), Consumer (White Goods, Tracking), Agricultural (Land, Pollution, Animal Monitoring), Smart Cities (Street lights, Parking, Waste Management), Smart Building (Alarm Building, Access Control), etc.

Summary for LoRaWan, NB-IoT & LTE

Protocol TX Current RX Current Ideal Current Sleep Current
Lorawan 24-44 mA 12 mA 1.4 mA 0.1 µA
NB-IoT 74-220 mA 46 mA 6 mA 3 µA
LTE 100-490 mA N/A 9 mA 8 mA

In next part we will begin with implementation of ESP-01 module with arduino.

IoT- Part- 3- Serial Communication and Bluetooth Voice Control

Serial Communication:

Serial communication is the process of sending  one bit of data at a time over a channel or a bus.

Serial in Arduino:

All Arduino boards has at least one Serial port (connection point), Four ports are available in Arduino Mega. These Serial ports are also know as UART (Universal Asynchronous Receiver/Transmitter) or USART (Universal Synchronous/Asynchronous Receiver Transmitter). Its a physical circuit embedded on the arduino board to communicate with the outer computer.

Note: Serial communication is not a type of Communication protocol, you can think of it an chip which is doing its work standalone.

UART: Two systems working on different clock speed
Ex: WiFi, Uploading code to arduino.

USART: Two systems working on same clock speed
Ex: SPI, I2C (Two wire interface).

Receiver is alias as Rx and Transmitter as Tx. 

Types of Wired Communication:

  1. Serial - There is only one channel between Rx and Tx.
  2. Parallel - Multiple channels are available between Rx and Tx

Serial Communication:

The very fine example of Serial communication is already implemented by you, remember the process of uploading arduino program? Did you notice that continuous blinking of orange led when upload was happening? 

Definitely Yes!!!

Reason for this is that when you connect your USB cable with arduino board, the communication established between them was a Serial Communication, Arduino uses Rx-Tx pins of atmega to communicate with your PC. Once you begin with the uploading process the serial ports are activated and bit wise data are sended from your PC to arduino board.

You can also see as Rx and Tx are available at arduino board mostly pin no. 0 and 1, these pins are available for the use of external purpose which we will see later on. In Arduino UNO only one Serial Port is available.

Baud Rate:

Baud rate is the rate at which the information is being transferred over the channel, measured in bits/sec.

Some very known baud rates are:
  • 300
  • 9600
  • 19200
  • 38400
  • 57600
  • 74880
  • 115200
  • 230400

Serial.begin():

Defines the speed (baud rate) at which your arduino board will be communicating with the Serial Monitor or with the connected device at the serial ports. As configuration of baud rate is required once it is placed in void setup() block.

Syntax: Serial.begin(speed);

Ex:

Serial.print():

Is used to print data over the Serial port in Human Readable format.

Syntax: Serial.print(data);

Ex:
This will print data in a single line, to shift printing to the next line replace print with println.



Upload your program and open Serial Monitor by clicking magnifying icon  from top right corner, shortcut (CTRL+SHIT+M).

Set baud rate from bottom right drop 2nd down menu as per baud rate configured in void setup. Once baud rate is set you will be able to see result



To print  data multiple times, write the instruction into void loop(). 

To print variable simply pass the variable as parameter without inverted commas.

Serial.read():

Is used to read the incoming data at the Serial port. Serial.read() returns the data in byte and returns -1 if not available.

Demo Code:



Note: Serial.available() checks for byte data that is already received and is stored in Serial buffer (size of 64 byte).

HC-05 Bluetooth interface with arduino:

Brief description of HC-05

HC-05 is wireless module which can be used for two-way (full duplex) function. It can be used to create communicate between arduino or other controller to your daily devices such as smartphone or laptop.

HC-05 consist of  7 pins:
  1. Enable key: This pin is used to toggle between Data mode (set low) and AT command  modes (set high). We will be using Data mode which is also default mode for HC-05.
  2. Vcc: Used for the power supply of HC-05.
  3. GND: Connect with system ground.
  4. Tx: Transmit serial data, is used by Bluetooth to transmit data to other device.
  5. Rx: Receive serial data, is used as an input of Bluetooth.
  6. State: Is used to check if Bluetooth is working properly.
  7. LED: Indicate status of module.

Note: Bluetooth LED  blinking pattern show status of module.
  • Blink once in 2 sec: Command mode is set.
  • Repeated blinking: Waiting for connection in Data Mode.
  • Blink twice in 1 sec: Connection successful in data Mode.

Default Settings:

  • Name: HC-05
  • Password: 1234 or 0000
  • Communication type: Slave
  • Mode: Data
  • Baud Rate: 9600

Operating specification:

  • Input Voltage: 3v to 6v (Most commonly works on 3.3 v).
  • Current Consumption: 30mA.
  • Communication range: less than 100m.
  • Protocol: IEEE 802.15.1
  • Max support baud rate: 460800.

HC-05 interface with arduino:

Connect Bluetooth using one to one jumper wire as show below.



Note: Rx-Tx pins available on Arduino Nano is common pin for Arduino program loading purpose, you need to disconnect Bluetooth Rx-Tx from Arduino every time you upload program into arduino. 

We will be seeing practical demonstrations for better understanding of Arduino Serial and program flow.


Practical Demonstration Videos:

Clip -1: Serial Communication using HC05


Clip -2: Bluetooth voice control using HC05



In next part we will begin with some communicating protocols and hardware interface in IoT.








IoT- Part- 4- IoT Communication Protocol

Implementation of IoT is of no use unless or until we overcome some existing problems. As we are very much familiar with the most wide...