Almost Xmas Ornaments 2016

I didn’t have time to complete this project – so, I didn’t launch it – but, I’m posting my progress here so that I can leverage it in the future.

The idea was to let users light up different xmas ornaments on our tree and send us comments through the Facebook comment plugin.

I had already used the Facebook comment plugin to LED panel a few years back and had done the internet connected relay. This time, I wanted to build on those projects to solve for multiple users actioning the lights and make it wireless. I was polling before, which turned out to be unreliable. To solve for this problem, I looked into using some form of websocket – MQTT.

I found the MQTT.js library, which connected rather seamlessly to adafruit.io.

I put together a website with three buttons and was able to get them to pass through their statuses via the protocol. Interestingly, the library doesn’t really support subscribing to multiple topics, so I had to leverage delimiters to determine which button was on or off. I used ‘0’ for off and ‘1’ for on which resulted in the following payload “0|1|0”.

I still need to have the ESP8266 subscribe to the topic I created – but that should be relatively straightforward. I’ll then leverage C to split on a delimiter Eg article and should have a nice “tadah” moment. One of the things to note for MQTT is that you have to keep it alive, “You must send something to the MQTT broker once every MQTT_CONN_KEEPALIVE seconds

You can set it in Adafruit_MQTT.h – the default is 300 seconds (5 minutes)

If you are not publishing data, only subscribing, you must send a ping to let the broker know you’re around!

Pinging is easy, just call ping()”

Here is the WIP for the web portion of the project.

Here is a link to the project with simple buttons.

Tutorials used

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *