Skip to content

BLOG

How IoT Works: IoT Networks

In this final installment of our “How IoT Works” series, we tie everything together. We’ve built our IoT device, set up our AWS cloud back-end, and optimized our user-facing front-end for simplicity and ease of use. Now it’s time to connect the dots and see the true power of the Internet of Things.

IoT Networks: Connecting the Ecosystem

IoT networks are complex ecosystems with multiple systems that need to communicate with each other seamlessly. These discrete parts have their own requirements and constraints: they each need to source data from different parts of the data pipeline, run their own calculations, provide varying degrees of fault tolerance, and send messages to other devices.

How IoT works diagram

For instance, we may want to enable machine-to-machine (M2M) communications on a smart factory floor while simultaneously sending aggregated diagnostic reports to the cloud and also serving runtime information to a technician’s human-machine interface (HMI).

The main challenge, then, becomes creating a fluid, real-time communications ecosystem that keeps every part in sync.

While it’s possible for certain use cases to set up a direct channel between devices or between a device and the cloud, we usually choose to use an IoT gateway as a communications bridge.

The Role of IoT Gateways

IoT gateways play a crucial role in connecting devices to the cloud by utilizing various communication streams like Wi-Fi, Bluetooth, LoRa, cellular, Ethernet, or wired serial connections like I2C. They enable the transfer of data over the internet using the TCP/IP stack, ensuring reliable connectivity.

However, gateways often also manage communications between devices, as well as offer a few other advantages.

IoT devices communicating with cloud through IoT gateway

Bandwidth and Latency

First, gateways save bandwidth and reduce latency. By aggregating, pre-processing, and filtering data, gateways send much less data to the cloud than individual devices would.

And, since the gateway sits much closer to the devices, often as part of the same LAN, they are ideal for applications that require real-time control or offline functionality.

From a security perspective, gateways act as the first line of defense by serving as intermediaries between IoT devices and the internet, enhancing overall system security.

Custom IoT Gateways: Tailored for Success

At Very, we often build customized gateways for our IoT technology, and it all starts with hardware. Our hardware team starts by thinking about the gateway’s requirements and then builds accordingly.

For instance, we might use a Raspberry Pi for a consumer IoT gateway with low compute requirements, while on the other side of the coin, we could build a full-powered x86 server for an IIoT (industrial IoT) gateway that’s going to do a lot of heavy lifting.

With our hardware in place, it’s time to start coding. We generally write software for IoT gateways in three languages: Elixir, Python, and C.

Our favorite, Elixir, is a dynamic, functional programming language that’s tailor-made for IoT development. Its concision, fault tolerance, and concurrency are perfect traits for remote devices that don’t get much user interaction.

On the gateway specifically, Elixir factors into building out the data pipeline that moves sensor data from the device to the cloud.

The other two languages are more well-known, and each has its own purpose. As a high-level programming language that’s well suited to data-intensive applications, Python shines when it comes to jobs like analytics and filtering.

Note: While Elixir can’t fully compete with Python for data-intensive applications at this time, it’s made huge strides in the last year, and it’s catching up fast.

On the other end of the spectrum, C is a low-level language that gives us more direct access to compute resources like CPU and RAM without requiring tons of processing power.

We also employ some ready-made services that are built into these languages. One of our favorites is Tortoise, an Elixir-based MQTT client application that we use to publish information to the cloud.

Another common Elixir service is Phoenix, a web framework that lets us serve APIs and webpages locally while also providing a user interface for administrators to monitor and configure their IoT fleet.

The last piece of the puzzle for most gateways is edge computing.

Let’s say, for example, that we’ve been using sensor data from an IIoT machine to train a machine learning (ML) algorithm for predictive maintenance to know when that machine is likely to break so that we can fix it beforehand.

Once we’ve trained that model, we can ship it to the gateway and use embedded GPUs to run it.

IoT Communication Protocols

When it comes to communication protocols, choosing the right one is crucial due to geographically dispersed devices, network constraints, and the need to connect numerous systems.

As with many situations in IoT development, the right decision depends on the use case. While there are numerous options for communication protocols used in IoT, we rely most often on MQTT

The MQTT Communication Protocol

MQTT architecture graphic

Benefits of MQTT

Originally developed by IBM for communicating between oil pipelines and satellites, in recent years the MQTT protocol has become the de-facto standard for IoT messaging for a few reasons:

  1. It’s lightweight and efficient. 
  2. It’s easy to scale up. 
  3. It’s reliable, even over unreliable networks.

Another selling point of the MQTT protocol for IoT networks is the security it offers by using TLS encryption and client-side authentication.

Pub/Sub in MQTT

A key concept in MQTT is the publish/subscribe model, AKA “pub/sub”. This means that clients, such as individual devices or gateways, publish their data to a centralized MQTT broker like Eclipse Mosquitto or AWS IoT Core.

The broker then sends that data to subscribed clients, depending on the data’s “topic”. For example, if a thermometer publishes the temperature, then a mobile app, a cloud database, and a smart thermostat could subscribe to that topic, causing the broker to send it their way once it receives the data. 

MQTT Features: QoS and More

Other useful MQTT features include quality of service (QoS), which gives a client the ability to choose a service level befitting the network’s reliability and application logic; retained messages, which give newly-subscribed clients an immediate status update after subscribing to a topic; and the Last Will and Testament feature, which automatically publishes a message if a client suddenly disconnects due to causes such as mechanical or network failure.

The HTTPS Communication Protocol

Besides MQTT, IoT solutions sometimes use HTTPS, which is the same protocol that fuels the internet by sending document-centric data between web browsers and websites.

HTTPS doesn’t have all the IoT-specific benefits of MQTT and testing shows that it’s 22% less energy efficient and 15% slower than MQTT, it often works for user-facing applications like web UIs and mobile apps.

Final Thoughts

A complete IoT network solution bears more resemblance to a community than a standalone product. Each member brings their own strengths to the table, excelling at certain tasks and depending on other members in turn.

Our cloud service, for instance, has exponentially more resources than an IoT device, allowing it to crunch big data sets and create valuable insights, but it relies on that device to generate data in the first place and then put its derived knowledge into practice.

That’s why connectivity is so crucial. By facilitating data flow between every corner of an IoT ecosystem, a robust connectivity framework brings the community together to achieve great things.

KEEP READING: Find out how Very helped an alcohol monitoring company develop a powerful IoT connectivity solution, delivering real-time results for their customers.

IoT insights delivered to your inbox