Holiday Lights – Surprise Widget

I was approached by Jan Cumps some time ago, as he wanted to give the challenge an extra IoT twist.

After some messages going back and forth, the conclusion was that we would symbolise each other’s project in our own design and have that component light up when the other design was online.


Both our designs are making use of MQTT messages on the same broker (

We came up with the idea of having our designs send periodic messages (e.g. every minute) on a specific topic with a specific payload as a heartbeat mechanism.
Once a heartbeat is received, a timer is started and the symbol lit up. When a new heartbeat is received, the timer is reset, ensuring the symbol remains lit up.
However, if the timer expires because no heartbeat is received, the symbol is turned off as we assume the other design is offline.

Here’s the code used to send my heartbeat (I removed the unrelated bits of code):

And the code used to process Jan’s heartbeat (unrelated bits removed as well):


Jan’s design is a Christmas wreath. To symbolise that in my own design, I chose a NeoPixel ring lighting up in green and red.

photo 1 (1) photo 2 (1)


To test this new feature, I used MQTT Lens and the Console output of the Yun.

MQTT Lens allowed me to confirm both Jan’s and my heartbeats were “on air”, with the expected payload. The console output on the Yun then confirmed I received and processed Jan’s heartbeat as expected.

Screen Shot 2015-01-02 at 14.25.28 Screen Shot 2015-01-02 at 13.24.48


Here’s a video of my widget being activated by Jan’s MQTT heartbeat.

I shortened the timeout interval for demo purposes to 30 seconds, so the widget would turn off between heartbeats which are sent every minute. The timeout is otherwise configured to 120 seconds.

© Frederick Vandenbosch, 2014-2019. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.