The Native MQTT collector is an all-new way to natively ingest MQTT data from your MQTT broker into InfluxDB Cloud. This zero-code solution makes it easier than ever to monitor your IoT devices in InfluxDB. This session provides an overview of the Native MQTT collector, describes when and how to use it, and explains how it works behind the scenes. Lastly, Gene demos his recent IoT project that utilizes the Native MQTT collector.
3. The MQTT Native Collector is an all new way to natively ingest MQTT
data from your MQTT Broker into InfluxDB Cloud. This zero code
solution makes it easier than ever to monitor your IoT devices in
InfluxDB. This session provides an overview of the MQTT Native
Collector, describes when and how to use it, and explains how it works
behind the scenes. Lastly, Gene will demo his recent IoT project that
utilizes the MQTT Native Collector.
Gene Hynson
Senior Software Engineer,
InfluxData
Gene is a Senior Software Engineer at InfluxData who is passionate
about building thrilling product features for InfluxDB. Gene has 7 years
of experience as a full-stack engineer building modern, cloud-first
software at VMware, Pivotal, and Boeing. Outside of work, Gene
spends his free time skiing the slopes in the winter or playing volleyball
on the beach in the summer.
MQTT Native Collector
4. Agenda
1. What is the Native MQTT Collector?
2. How does Native MQTT Work?
3. How did we build Native MQTT?
4. Demo
6. The ability to directly ingest data from
popular data sources without the
need to do any transformation to Line
Protocol or run a Telegraf agent
6
Native Collection
7. 7
MQTT Topic Subscriptions
• Subscribe to topics being published by
their own devices and sent through a
message broker directly to the InfluxDB
Cloud service
• No code or installing any additional
software required
23. Apache NiFi automates the flow of data
between systems.
●Open source
●Data source agnostic
●Data type, format, & size agnostic
●End-to-end data encryption
●Guaranteed delivery
●Operates at a massive scale
Apache NiFi
26. Monitoring car OBD2 data over time
https://github.com/genehynson/arduino-mqtt-influxdb-obd2
27. Monitoring car OBD2 data over time
Arduino MKR1010 (WiFi)
HC-05 Bluetooth
Module
NEO-6M GPS
Module
28. Monitoring car OBD2 data over time
Arduino
#include <WiFiNINA.h>
while (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid, pass);
delay(10000);
}
Serial.println("Connected to WiFi");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
Arduino
#include <ArduinoMqttClient.h>
char host[] = "broker.hivemq.com";
int port = 1883;
if (mqttClient.connect(host, port)) {
Serial.print("Connected to broker");
}
Connect to WiFi Connect to MQTT broker
29. Monitoring car OBD2 data over time
Arduino
#include <ELMduino.h>
ELM327 elm;
elm.begin(Serial1, true, 5000);
...
float value = elm.rpm();
if (elm.nb_rx_state == ELM_SUCCESS) {
mqttClient.beginMessage("obd/rpm");
mqttClient.print(value);
mqttClient.endMessage();
}
Arduino
#include <TinyGPS++.h>
gps.encode(Serial2.read());
if (gps.location.isUpdated()) {
lat = gps.location.lat();
lng = gps.location.lng();
String json =
"{"lat":"+lat+","long":"+lng+"}";
mqttClient.beginMessage("odb/gps");
mqttClient.print(json);
mqttClient.endMessage();
}
Publish ELM327 as MQTT Publish GPS as MQTT
30. Monitoring car OBD2 data over time
Our data is being published to the
HiveMQ MQTT broker!
Now for the easy part: writing the
data to InfluxDB
33. Monitoring car OBD2 data over time
Use Regex (.*) to capture the entire message as _value
“rpm” will be our _field name
“obd” measurement name can be reused in each subscription
Leave this empty to allow InfluxDB to assign a timestamp for us
35. Monitoring car OBD2 data over time
Check out my shared Notebook!
https://tinyurl.com/influxdb-obd
36. Monitoring car OBD2 data over time
https://github.com/genehynson/arduino-mqtt-influxdb-obd2
37. Monitoring car OBD2 data over time
If you want to skip the Arduino DIY…
● WiFi / 4G LTE Support
● Connects to any MQTT broker
● Includes support for EVs
● No coding required
● See https://community.autopi.io/
for fun extensions and project
ideas!
I have one on the way… xD