Message Queueing Telemetry Transfer (MQTT) with Arduino and JS
Session Leaders: tigoe
Tags: #MQTT • #networks • #Arduino • #JavaScript • #node.js
Created By: tigoe
This is a session for intermediate Arduino users who want to learn a bit more about networking, particularly for sensor datalogging.
A microcontroller can technically run a web server, but it's a tough job. Sometimes it's easier to connect devices with lighter-weight protocols than HTTP. Message Queuing Telemetry Transport, or MQTT is a lightweight protocol designed for connecting devices to each other through a broker service. It's a popular protocol in industrial settings. You can use it for many applications, from sensor data gathering to WebMidi and much more.
In this session, I'll introduce how to run MQTT on a WiFi-connected Arduino, or in the browser using p5.js, and in node.js. We'll use shiftr.io as the server to test on. I'll demonstrate using a network of sensors I have spread around the ITP floor at the moment that send data back to a Google Sheets doc (thanks to Arnab Chakravarty). If you have a WiFi-capable Arduino, or just a browser, you'll be able to send data of your own as well.
To make the most of this session, you'll should:
- To be comfortable programming Arduinos
- Know how to use (and maybe have) a WiFi-connected Arduino like the Nano 33 IoT, MKR 1010, or MKR1000.
- Know how to connect a sensor to your Arduino (and it helps to have one).
Background material that may help:
All the code I'll run in this session will run on the boards above. It may run on other Arduino-compatible models, but I can only guarantee the ones I'll have tested on. The code links are above.