[ITP: Connected Devices] Device Data Dashboard III

In my last blog post I got my sensor logging data using the TCP-to-net-cat connection. As a review, I’m going to get my sensor logging over a broker connection using MQTT, but I’ve done this before.

MQTT data logging

Recall that “Message Queueing Telemetry Transfer, or MQTT, is a lightweight IP-based messaging protocol designed for communication between sensors, controllers, and other devices. It’s designed to support equipment that may not always be online, like automated devices built with microcontrollers,” as Tom put it so well.

Using the ArduinoMqttClient library, start with Tom’s ArduinoMqttClient.ino. For some reason I was unable to connect to the broker with the “WiFiSSLClient” in line 33, but changing it to “WiFiClient” worked for me. I also setup the broker settings (test.mosquitto.org, port = 1883, topic and clientID). Next I added in all my sensor stuff (TCS34725). I got it working! I’m using MQTT Explorer and am subscribed to the “conndev/#” topic under the "Advanced” settings; looks like I’m the only one here right now.

Side quest: Turning an LED on/off with MQTT

Drumrooooollllll… I’ve been dying to learn how to do this for some personal projects of mine so I’m excited we went over this example in class. I’ve modified the MqttClientSubTopics example to just manipulate the LED. I removed the sensor stuff and added control of the built in LED on my Arduino. Here’s a video of me updating variables using the MQTT Explorer software.

Web Dashboard

Ok, back to the Arduino example with sensor data. Now that my TCS34725 sensor is successfully sending the sensors RGB values to the MQTT broker, I shifted my focus to Tom’s MqttJsClientSimple example. I think I was able to get this to work?! I change the topic to “conndev/makin-stuff” and occasionally the RGB values flashed on the web page. I think they’re only showing up in the instant that they’re published?

Looks like the RGB values are 16-bit, so I remapped them to the range 0-255 for web colors. I don’t know how to internet!

If you’re following along in this project, see my next blog post here.

Resources

https://tigoe.github.io/mqtt-examples/

https://vimeo.com/375315679