Home temperature controller and webcam gas meter reader

The write-up of this project is still under construction…


This project came into existence because during the cold winter’s it can take some time to warm up the house to a cosy temperature when you’ve been away for a couple of days. Thus the urge arose to build a solution that enabled me to turn the heating on and off using my mobile phone. To realize this I connected an Arduino controlled relay to my home thermostat to directly toggle the heating and a temperature sensor. The Arduino in turn is connected to a Raspberry-Pi that takes care of the online connectivity and the heating algorithm.

To be able to monitor and control the temperature from my Android phone I wrote a program in Processing.

Home temperature app


In this app which runs on Android you can see the current temperature and history and the history of gas usage as well. By clicking the graph you can go back in the temperature and gas history.

The graph shows:

  • Temperature history
  • Gas usage history
  • Heat switching moments
  • Requested temperature

The gas values are also multiplied with the average cost of gas in order to get a sense of the cost of heating, showering and cooking.

By tapping left or right on the temperature dial you can decrease or increase the temperature. All input values from both the app and the current temperature and gas use are uploaded to a SQL database. Both the app and the Raspberry-Pi check this database to get the requested values or to see if the heating needs to be turned on or off.

If the temperature gets above an adjustable threshold I get a notification by email. This comes in hand if you accidentally let the heating on (or if you house is on fire).


For reading the gas meter I have made a rig of a webcam and some LEDs connected to a Raspberry-Pi with a wireless internet connection. Every 5 minutes the LEDs go on and the webcam makes a snapshot. This process is controlled by a Linux bash script. Next the snapshot is editted using command line options to crop the image, make it black and white for optimal character recognition and search for cue in the snapshot in order to correct for slight webcam movements before the snapshot is cropped to keep only the gas usage.


If the optical character recognition software is not able to deduct a realistic number from the cropped snapshot (i.e. a number that does not drastically differ from the previous value) another piece of code changes some parameters of the character recognition software. If this does not work after a few tries another software program is called upon for character recognition.

I am also able to compare which temperature controller algorithm is most efficient.