The device layer earlier discussed different types of devices with different networking abilities. Devices will communicate with communication layer to set up network connectivity and send the data to the Internet. This section will feature different communication strategies that one can use based on the available device. We will also discuss different communication protocols.
The section discusses different communication strategies that can be used with IoT devices. It will depict how devices will communicate with the Internet to transmit or send data. The communication strategy is devised based on the networking capability of each device. Talking about device networking capability, hosts of IoT devices by itself are unable to route data directly to the internet due to protocol incompatibility. Though there are some that may be able to connect directly to the Internet. Devices that are unable to connect directly to the Internet make use of something called ‘gateway’ or a ‘hub.’ We will talk about device gateway in detail in next section.
An IoT Device gateway is a device that glues or connects incompatible networks or protocols and provides a means to connect devices to the internet. Low powered devices like sensors connect to a gateway through protocols like Z-wave or Bluetooth LE protocol, which in turn will communicate with the broadband router to route the messages to the internet. A broadband router could use WLAN or WI-FI to connect to the internet. Protocols like ZigBee or Z-wave by itself are not equipped or capable of talking to the internet directly, and therefore gateway device is used. The gateway will translate the incoming ZigBee data into IP data that can be then routed to the internet. Gateways can also act as a firewall thereby securing the devices from any malicious attack.
Smart Gateway We could also have something called as ‘smart’ gateways. Such gateways have their own local storage and embedded application to perform analytics on data streamed directly from the devices. These are also called edge gateways. They are configured right at the edge of the device so that the data need not be sent over the network to the internet and can be analyzed or filtered close to the device in the gateway itself. The concept is also called ‘fog computing’ – a term devised by Cisco. The benefits of edge gateways lie in reduced network traffic and bandwidth, increased efficiency in terms of core data processing and delivering real -time processing.
Tip – Eclipse Kura is an open source project that provides a platform for building IoT edge gateways. It is a smart application container that enables remote management of such gateways and provides a wide range of APIs for allowing you to write and deploy your own IoT application. We would revisit Kura in Chapter 3.
Smartphone as a gateway
Another form of communication could be through the use of smartphones. Instead of the gateway, a device can talk to a smartphone through say Bluetooth protocol and the data can be then channelized to the cellular network through a SIM card. This way a Smartphone can act as a gateway and eliminates the need of having a dedicated gateway device or a broadband router. A limitation to this approach is that smartphone by itself will not automate the process of data communication from the device to the internet. Manual intervention is required to set up the process of communication, for instance launching the corresponding application on the phone.
Certain devices have the capability to connect directly to the Internet without the need of any gateway. It could be either through Wi-Fi or cellular network. Modern day microcontrollers are equipped with a Wi-Fi capability that enables devices to broadcast itself over the internet. The obvious advantage is that there is no need for any dedicated gateway thereby saving that one extra hop to send the data to the cloud or internet.
Another form is a device-to-device communication. This form of communication defers the process of relaying data to the internet. Devices communicate with each other to form a mesh network. Devices communicate to collect information, report their existing states, send alerts or perform discovery routines. The communication could be with or without the human intervention. For example, a home security system may connect with a nearby alarm system to alert if someone approaches a door. The alert then can be sent to the internet so that if you are outside the home, you can get the status update.
API-based communication is the new talk of the town. In this approach, devices communicate its state to an internet service provider (say A) which then uses an API (often a REST URL) to communicate to another service provider (say B) which then triggers action to another device. This kind of API-based communication eliminates the need of installing a shared gateway. This mode of communication is handy when there are multiple disparate devices associated with a vendor service that needs to shake hands to realize a use case.