Matt Daubneys Blog

Arduinos, MQTT and Light levels

by on Sep.04, 2011, under arduino, EasyRadio, Fun, programming, ubuntu

Since watching Andy Pipers talk on MQTT at Oggcamp, I’ve been trying to understand and use Mosquitto with my Arduinos. I’ve got a few sensors lying around to test this with (and have ordered some more \o/ ) and have started to have some success.

Installing Mosquitto is a doddle. I added the ppa to one of my household servers, then just apt-get install mosquitto. MQTT broker up and running in a matter of minutes. The first thing I setup to check if it was working was a simple python program that would just connect to the broker and send “Hello World” to the “hello” topic. I wrote a second little python script to just listen to the “hello” topic and print out the message from any updates. Most of the code was borrowed from this blog post which was incredibly helpful :)

With that running happily, I moved on a stage. Digging out an old shield for my arduino that I made to control the lights in my flat using some home easy sockets and an RF chip, I added an LDR and used the thermister that was already on the board. This simple set of components means I can now monitor both the temperature and light levels in one of the rooms of my flat. Using an ethernet shield for the arduino also means that I can then report that information to my Mosquitto broker using the arduino mqtt library.

What will I do with all this information? Well, initially I’m going to write an mqtt to sql bridge (might use this an excuse to learn postgres now mysql has an uncertain OSS future) and will setup some scripts to graph the information. I’ll probably change this sketch to control the lights in the flat, so I could have a machine somewhere sending a message to the mqtt broker at a set time to turn the lights on in the bedroom (a simple mqtt powered alarm clock :) ). Hopefully I’ll write a small application using the app indicator framework for Ubuntu (and growl for OSX) to tell me when certain thresholds are passed, especially for the other sensors I have coming (Alcohol, Gas, Smoke and humidity). I might write another bridge to use the google cloud messaging system to add an alert on my phone as well.

There’s a whole world of possibilities out there, thanks to so many people building these various components and libraries that make hacking fun toys so much easier :) Many thanks to all those who have developed the frameworks, libraries and services that I’m using and for making the F/OSS to make life even easier.

:, , , ,

1 comment for this entry:

Trackbacks / Pingbacks

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...