MQTT Table Football with Arduino, Raspberry Pi and Websockets

One of our main motivation refreshers in our office is our football table and we use it heavily every day. Someone came up with the idea: „Hey, why don’t we add some freaking MQTT support to the football table?“. Of course there was no argument against it and so we added the MQTT support and used a Arduino One for the job. To make things more interesting we decided against a mechanical goal trigger and used infrared sensors for detecting goals. To raise the motivation even more we used a Raspberry Pi to play goal celebration sounds on actual goals, notified via MQTT, of course.

To raise the nerd factor a bit more, we also decided to remove the built-in goal counter (which needed human interaction count up) and built a very basic small web application which acted as goal counter by using websockets to get MQTT messages when a goal was shot. This web application also implemented the logic when a player has won and published messages to the MQTT broker.

MyMQTT for Android was used as a remote control to reset the game with. With MQTT, of course.

The HiveMQ MQTT broker was the heart of the communication. All communication was done via MQTT with the HiveMQ broker.

Architectural Overview

MQTT Table Football Architecture

MQTT Table Football Architecture

In Action

We brought the football table to an event a few days ago and it was the absolute highlight of the event. Everyone had great fun.

MQTT IRC Bot/Bridge

It has been a long time since my last blog post. I was incredibly busy with HiveMQ and my focus pivoted to M2M in general and MQTT, an awesome, ultra-low footprint protocol for the Internet of Things, specifically. In the future this blog will also cover these things.

I had some spare time this weekend and decided to do some fun programming. The result was a MQTT-to-IRC or IRC-to-MQTT bridge bot. Although it is a fun project, it turns out that there are real useful use cases for that and because of that I decided to share it :)

How to use

The first step is to download or clone my Github Repository. Then, on the command line, simply run:

mvn clean package

Copy the jar file to a directory of choice and create a config.properties file with the properties according to the documentation. An example config:

broker.host=localhost
broker.port=1883
mqtt.clientId=mqttbot

irc.hostname=irc.freenode.net
irc.port=6667
irc.nickName=mqtt_bot_
irc.channels=#myircchannel1,#thesecondchannel

The next step is to install a MQTT broker locally. To do this, go to http://www.hivemq.com and download the latest version. HiveMQ is an advanced enterprise MQTT broker which is made for use cases where scalability, extensibility and reliability is key. It is also perfect for private MQTT projects. Please follow the quick start at here to install HiveMQ.

After installing the HiveMQ MQTT broker locally, start the bot and try publish a MQTT message with a tool of choice on the topic „irc/#%yircchannel1“. Now your message should appear in the corresponding IRC chat.

Of course it is also possible to get all messages via MQTT. Just subscribe to the topic „irc/%myircchannel1/messages“ and you should receive all messages of the IRC chat.

Huh? Why should I do that?

At first sight this does not make any sense why one would do that. When taking a second look, you will realize that you could connect any things to a chat with humans. You could send an IRC message when someone enters a door, when your Jenkins has build results, when a Github Commit occurs, and so on.

Also, you may probably want to get a Andorid Push Notification when someone writes your name in an IRC chat. And if you think this does not make any sense, at least it was fun hacking on :-)