TL;DR InfluxDB, the IoT Stack, and MQTT
By Susannah Brodnitz / Sep 09, 2022 / InfluxDB, IoT
The Internet of Things (IoT) describes devices with sensors and computational ability which let them collect, exchange, and act on data. IoT is a broad category that includes uses from smart home thermostats to industrial manufacturing equipment. Sensor data is time series data, and IoT is a common use case for InfluxDB because it can handle the huge amounts of data IoT sensors create. There are a few different ways InfluxDB can fit into an IoT system to help companies and developers store and analyze sensor data.
InfluxDB in the IoT stack
An IoT stack is what connects IoT devices to applications that use the data they collect. In these stacks, companies want storage and computational locations to be secure and to always have network access. Companies may choose to manage their own infrastructure or use a managed cloud provider. In IoT spaces it’s common to have many devices with sensors spread out over large areas, and these situations have specific architectural needs.
One way to incorporate InfluxDB into an IoT stack is to install it at the edge and use it directly there. You can also install Telegraf on edge devices and collect data to send to the cloud or another data center for more central computation. One of the benefits of using Telegraf is that it can also transform and enrich data as it’s transported. Planning how to use different kinds of data in each location lets companies and developers save storage space. For example, an engineer working in the field with a wind turbine might want to see the detailed data it’s collecting, while a data scientist managing hundreds of turbines might want a summary display. InfluxDB’s Edge Data Replication feature is designed to automatically send data from InfluxDB instances on the edge to InfluxDB Cloud.
Using MQTT and InfluxDB for IoT
MQTT is a broker with a publication and subscription model that enables machine-to-machine communication. Devices that collect data can publish it to different topics and client devices can subscribe to those topics. In the case of the wind turbine example, a turbine might publish wind speed data to one topic and power data to another. A broker temporarily holds the data so other machines can subscribe to it and receive it, whether they’re other devices or computers. Within your architecture you can have many different topics.
InfluxDB supports working with MQTT in two key ways, collecting data from a broker and sending data back to it. MQTT brokers continuously update with new data and don’t store old data for long. InfluxDB can subscribe to topics so you can collect and store the data you want and the broker doesn’t overwrite it. You can then query that data with Flux and send it back to the broker. This lets machines access it again from the broker after it’s been transformed, which helps with automation.
There are a few different ways to send data from an MQTT broker to InfluxDB. Telegraf has a plugin that is a good option if you have a server within your architecture you can install Telegraf on, especially if you want to transform data as it’s transported. Another option is InfluxDB’s MQTT Native Collector. This lets you subscribe to a broker directly from InfluxDB cloud to keep your data pipeline fully cloud based. It’s simple to use, fully managed, and lets you start collecting data immediately.
To learn more about InfluxDB in the IoT stack you can watch our video on this topic.
And to find out more about how to use MQTT and InfluxDB you can check out this video.