GNOME MQTT Panel Applet 0.1

We’ve been tracking our electricity usage for a few weeks now and have a web page of graphs which make it easier to work out when we’re using a lot of electricity.

Last 24 hours power usage
Last 24 hours power usage

I have a perl script running on one machine which reads the CurrentCost data from a serial port and publishes the temperature and instantaneous power consumption into an MQTT microbroker. On the webserver machine another perl script is subscribed to the temperature and power consumption topics and uses rrdtool to record the data and create not so pretty graphs.

I also wanted to be able to keep an eye on the current power usage so I put together a little gnome applet that connects to an MQTT server and subscribes to a single topic. You can run multiple applets connecting to different brokers or subscribing to different topics. Conceptually data moves from the current cost around the system like this:


One of the big advantages of using the broker is it neatly abstracts the data producers like the CurrentCost or a temperature sensor connected via an arduino from the consumers that process, record and render the data. Its easy to slip in additional sensors or replace existing ones with something which is quite different without having to make any changes on the processing and user interface side. When our new house gets built and we have a C-Bus system controlling the electrical system, state information from it will be added to the broker so it can be monitored easily.

I’ve never written a gnome applet before nor even done much gtk programming before so its still a bit rough around the edges. But it currently looks like this on a panel:

Temperature and Power Usage
Temperature and Power Usage
Preferences dialog
Preferences dialog

Tooltip with status information
Tooltip with status information

I still need to work on having the preferences saved between sessions.

6 thoughts on “GNOME MQTT Panel Applet 0.1

  1. Chris – tweeted you – would like st get more details or collaborate on what you have done – as you know I too am monitoring my home – and was looking to find a more integrated way of pulling data of the device & graphing it than via “currentcost” as it is very very flaky after about 2-3 days.

  2. Andy S-C – MQTT is so useful for this sort of application. Removes the need to write custom code and have custom protocols to get data from one machine to another for each application.

    Matthew – sure – IM me sometime and we can chat. MQTT does make things much simpler and when one end breaks a bit (eg lose the signal from the CC temporarily) going through MQTT insulates the other parts of the system (like visualisation tools). Have some scripts etc I can share.

  3. Chris,
    I love your work. Currently I have custom perl code to extract the data from the currentcost gear and send as an XML file to our webserver, where it is consumed and data stored from there. I’m also using the process to monitor solar power generated (the graphs are at ).
    I too have been inspired by Andy SC and mqtt, so I’ve (slowly) started to convert stuff over to use mqtt as it’s pub/subs model is perfect for this. I’m also trying to do the same for the weather stats on the site, but there is much more info to manage.
    I’ve been mucking about with the IBM rtmb – it looks like from your C-BUS article that mosquitto is easy to call the pub/subs messages etc. Is that the case ?

  4. Hi Mangrove – thanks! I’ve been using the mosquitto server as a drop in replacement for rsmb. I mostly use the perl MQTT module on CPAN to connect to it but it does have some issues so in places I have just called the mosquitto_pub and mosquitto_sub command line programs which work fine. I haven’t used the C or python interfaces from mosquitto yet. The phpMQTT module is okay for getting data from an MQTT server into webpages – though I had to hack it a bit so can poll for info.

    btw – nice graphs on your site – what do you use to generate them?

  5. Hi Chris, would it be OK to use your diagram in my talk on MQTT at LinuxConf 2011 – full credit to be provided and a pointer here, of course? Trying to pull together a nice range of examples of how people are hooking things together :-)

Comments are closed.