Check out the highlights from Developer Week

IoT Edge Computing Devices

IoT Edge Computing Devices

1. Introduction

a) Introduction to IoT

The Internet of Things (IoT) describes different types of physical devices that collect data using sensors. The idea is that one of these “things” is just an embedded device that could be as simple as a light sensor measuring light intensity and then broadcasting the data in real time or at predefined intervals to a central entity. People can use the data collected from these devices to make intelligent decisions. A device embedded with a light sensor can tell us when to turn on or off the lights on our driveway based on sunlight intensity, as an example. But IoT devices can also broadcast sensor data to a more powerful system that can run AI/ML models on that data instantly to predict future behaviors. The Internet of Things has changed the way we interact with the world and has, in turn, revolutionized the way we use and process data.

b) Introduction to edge computing

As electronic devices get smaller, the number of connected devices increases. It’s estimated that the number of IoT devices will increase by 24 billion by the end of 2030.

IoT devices are used across many industries to improve processes, and many industries rely on analyzing and processing this data in real (or near real) time. The challenge is that IoT data is so massive that it’s actually measured in zettabytes, which is equal to one trillion gigabytes. . With IoT data coming from all over the world across billions of devices, processing this data in real-time requires compute closer to where the data is generated. This is where edge devices or edge compute modules come in. 

An edge device or edge compute module can be the same IoT device that is collecting the data or a standalone device near the IoT devices themselves. Rather than offloading the processing tasks to a distant cloud VPS or a server, the data can be processed on the edge node so that instant decisions can be made. These decisions can be time or security-critical ones like setting off an alarm or avoiding an obstacle in the case of smart cars.

IoT diagram

Figure 1: Typical Industrial Environment with Sensor Nodes

In Figure 1, sensor nodes are spread across a typical industrial environment, which might include temperature-sensing nodes, current-sensing nodes, and vibration-sensing nodes. All the data acquired from the sensor nodes is shared with the edge node or edge compute module near the machine, so the edge node can do real-time and on-prem calculations and set the machine parameters accordingly.

2. How IoT and edge computing works together

IoT devices can sometimes be edge devices as well. IoT devices have sensors with limited processing power, connected to a network that communicates between the devices and the cloud/edge. Edge devices, in comparison, havenodes with enough compute power and storage to process data on their own. Some use cases that make use of IoT and edge devices include:

  • Smart homes
  • Self-driving cars
  • Industrial IoT (IIoT) devices

a) IoT edge computing architecture

Edge computing is now being used extensively in many IoT settings. While there are no industry standards for how to design a system with edge compute nodes, there are some commonalities in most IoT systems.

IoT diagram

Figure 2: Common Components in an IoT Solution with Edge Computing Devices

Layer 3 is a gateway or wireless gateway layer that is responsible for acquiring the processed data from the edge devices and forwarding it to the cloud server on layer 4 to permit data storage at scale. This ensures that the historical data is always available for visualization. Layer 4 is a traditional cloud-based VPS and can have (but is not limited to) a database, front-end dashboards, microservices, and a back-end.

While edge nodes can be made to run machine learning / deep learning (ML/DL) models, it is important to note that model training is always done in the cloud or on a machine equipped with powerful resources because edge nodes are not made for every task.

b) Edge Gateways

A simple IoT gateway or edge gateway is a device that connects IoT sensors or sensor networks to the cloud. For example, edge gateway can be used for converting data acquired from long-range communication protocol (LoRa) sensor nodes to TCP data to be sent to a central server. In Figure 2, we can regard the IoT nodes as LoRa nodes, creating a mesh network of LoRa node devices. A mesh network eliminates the need for each IoT node to send data to the server directly, congesting the network. In a mesh network, all the IoT nodes share the data among themselves, and only a specified number of IoT nodes (LoRa nodes), out of the whole mesh network, send the data to the server or gateway.

Now, to broadcast the data to a central entity like a central hub or analytics dashboard hosted on the cloud, we need some sort of translation mechanism to convert the data to TCP/UDP because that’s what our central analytics hub supports. In this scenario, the wireless gateway at layer 3 is acting as an edge gateway.

3. Use Cases / Examples of Edge Computing in IoT

There are multiple uses cases and examples of edge computing being used in IoT:

  • Real-time industrial environment monitoring
  • Security networks based on facial recognition
  • Machine fault detection and prevention

Let’s start with an example of a real-time industrial monitoring system with fault detection and prevention, where we have very basic sensor nodes like temperature sensors, vibration sensors, and current sensors making a mesh network in an industrial environment. Each machine is fitted with similar sensor nodes and broadcasts the sensor data to the IoT edge devices at defined intervals. Now with just these basic sensors, we can make an ML model on the edge devices that can do model training of machine behavior over time and then quickly turn off the machines instantly in the event of fault detection.

4. Benefits of Edge Computing in IoT

Edge computing provides a number of benefits when used in an IoT solution:

  • Faster data processing with lower data communication latency between the sensor nodes and the edge devices
  • Native security (because the data remains within the premises of the deployment)
  • Lower operation costs (because the cloud services are not being used extensively in the edge computing use-case)

a) Speed / Fast Edge Analytics

Taking the above-discussed example of machine fault detection and prevention, let’s do some formal calculations of the time required to process the current and vibration waveform data and perform an emergency turn-off sequence. We assume that the sensor nodes are in Sydney, Australia, while the cloud service provider is in Los Angeles, United States, and the data shows that the average ping between the two cities is 162.8ms.

Let’s assume that is a time variable defined in milliseconds that is dependent on various factors and conditions of the network. In that case, the following calculations apply to cloud-based and edge-based architectures.

Traditional Cloud-Based Architecture

  • Time to acquire sensor data =1𝛗
  • Average ping between Sydney and Los Angeles =162.8𝛗
  • Time to send the data to the cloud via Gateway =162.8 + 𝛗
  • Time required to analyze the real-time data and deduce a result =2𝛗
  • Complete round-trip time =2 × (162.8𝛗 +1𝛗 +2𝛗)= 331.6𝛗

IoT Edge-Based Architecture

  1. Time to acquire sensor data =1𝛗
  2. Time to send the data to the edge within the local network =2 + 𝛗
  3. Time required to analyze the real-time data and deduce a result =2𝛗
  4. Complete round-trip time =2 × (2𝛗 +1𝛗 +2𝛗)= 10𝛗

These calculations show clearly that when using IoT edge-based architecture for tasks like machine fault detection and prevention, the complete round-trip data communication time is lower than using a traditional server-based approach.

b) Security

In IoT edge devices, most of the data remains on-premises, confined within the local network and with data transmission constraints put in place. Only the desired data is shared with the cloud, yielding a naturally secure system because most of the data remains local.

5. Quick Edge-Device Creation Using Off-the-Shelf Hardware

In this section we will go through a step-by-step tutorial to create and use an edge device using off-the-shelf hardware components (based on Raspberry Pi) and the Macrometa service as an edge computing platform.

a) Macrometa

Macrometa permits the building of fast real-time applications and APIs on stateful-serverless edge clouds. On the IoT front, Macrometa promises up to a 60% reduction in cloud opex costs of the solution while increasing data processing and analysis speeds. Some of the IoT use cases that can be built using Macrometa include:

  • Real-time location tracking
  • Autonomous and connected vehicles
  • AI/ML and computer vision applications
  • Predictive maintenance
  • Fleet management and tracking

b) System Architecture

  1. Sensor Node

The sensor node is a simple Raspberry Pi 3B+ circuit. We can make a very simple sensor node by connecting an easily available temperature sensor called a DHT22. Figure 3 shows a simple circuit diagram connecting the Raspberry Pi and DHT22 using the GPIO4 line of the Raspberry Pi.

IoT diagram

Figure 3: Schematics Diagram; Raspberry Pi 3B+ interfaced with DHT22 Temperature Sensor

  1. System
IoT diagram

Figure 4: System Architecture of Example Solution

Each sensor node is an edge IoT device, the schematics of which are shown in Figure 3. The system architecture diagram here shows N sensor nodes connected to a WiFi router to get internet access. Once the internet connection is established, the data is sent to the Macrometa cloud. The Consumer shown in the diagram above is a device that wants to get the live sensor node data. This is just a laptop or a device with an operating system running a program (details below) that allows it to connect to Macrometa and receive the data.

From a technical perspective, the data is published to Macrometa GDN using pub-sub streams. The sensor nodes produce streams that are then shared over Macrometa GDN and subscribed to and consumed by the Consumer, which, in this example, is a simple laptop running a Python-based subscriber program.

c) Sensor Node Configuration

As mentioned earlier, the sensor nodes are IoT devices that send/publish data to Macrometa. To configure them, follow these steps:

  • Since the Raspberry Pi is just an ordinary computer but in a smaller form factor, connect any HDMI LCD, keyboard, and mouse to it to permit its use.
  • Connect the Raspberry Pi to a power supply (any smartphone adapter works) to turn it on.
  • Open the terminal on Raspberry Pi from Menu->Accessories->Terminal, as shown in Figure 5.
IoT screenshot

Figure 5: Opening the Terminal in Raspberry Pi

  • Execute the following commands one by one by typing them in the terminal and pressing the Enter button.
sudo apt update
sudo apt upgrade
sudo apt-get install python3-dev python3-pip
sudo python3 -m pip install --upgrade pip setuptools wheel
sudo pip3 install Adafruit_DHT
cd ~ ; git clone https://github.com/Macrometacorp/pyC8.git
cd pyC8*
python3 setup.py build
git clone https://github.com/Nauman3S/MacrometaPubSub.git
cd SensorNode
python3 SensorNode.py

Once you have run the above commands, the sensor node will start publishing the real-time temperature sensor data to Macrometa GDN.

d) Stream Consumer

The Stream Consumer is a device (such as a laptop or even another Raspberry Pi) that shows the live data sent from the sensor nodes.

  • On a Linux machine, open the terminal, as shown in the Sensor Node Configuration section above.
  • Execute the following commands to set up a Consumer Node and see the real-time data published by the sensor nodes.
sudo apt update
sudo apt upgrade
sudo apt-get install python3-dev python3-pip
sudo python3 -m pip install --upgrade pip setuptools wheel
cd ~ ; git clone https://github.com/Macrometacorp/pyC8.git
cd pyC8*
python3 setup.py build
git clone https://github.com/Nauman3S/MacrometaPubSub.git
cd Consumer
python3 Consumer.py

At this point, the Consumer is ready; whenever a sensor node publishes new data, it will be displayed by the Consumer node.

e) Usage Details

Real-time data streams can be handled very easily and effectively with Macrometa. We can easily modify the above example to make use of IoT edge devices for preprocessing the data before publishing it. Just add another single-board computer as a Consumer node and collect all the data at that point, process it, make decisions, and then publish it again to Macrometa GDN or any other cloud for analytics.

10. Conclusion

IoT edge computing devices allow faster data processing with lower processing costs. With the number of IoT devices increasing every year, it is a natural choice for IoT solution architects to make use of IoT edge computing devices to provide the most optimal and cost-effective IoT solutions.

11. Further Reading

  1. Macrometa Quickstart
  2. Macrometa Essentials
  3. pyC8 by Macrometa. Python Driver for Digital Edge Fabric

Platform

Global Data Network
Join the Newsletter