Monthly Archives: July 2013

LCD Display

Until now the only way to check the status of some basic sensors (mainly the temperature) was to open the web interface I created.

I wanted an easier and quicker way to check the temperature and humidity. I therefore decided to get a small LCD screen to display that basic info.

I ended up buying a SainSmart® IIC/I2C/TWI Serial 2004 20×4 LCD Module from Amazon.

2013-07-26 07.18.24Since I wanted to display data from different script sources (main GPIO controller script, Temperature and humidity script) I soon realised I had to use a separate script to handle the LCD as opposed to a simple call to display data: 2 simultaneous calls (or in quick succession) would scramble the I2C port and the LCD would either not display anything or display garbage.

I therefore use a MySQL database to hold the messages, which can be updated by any of my scripts, and a separate handler that loops and updates the LCD

Note: the LCD’s address is 0x3F. You can confirm it’s correctly detected by running:


(depending on the version of your Raspberry Pi).

The LCD needs to be powered by +5V, but then it does not get detected:

I found that if I power the LCD with +3.3V it gets recognised but the display is a bit faint, even with the brightness set to max. A Logic Level Converter is then required to make it bright enough while being recognised. See the LCD Brightness post for more info on that…

DHT22 Crashing – “Resolved”

For some reason, the script I was running to get the temperature and relative humidity from the DHT22 kept hanging every so often.

Instead of running two scripts separately (one for the DHT22, one to monitor the other different sensors I have), I’m now calling the DHT22 script from my main script and in case the last update from the DHT22 is over 2 min old, I just kill it:

and restart it.

For the negative temperatures, the script seems ok, but since we’re in summer I have not had the chance to test why the returned data shows 0. I’ll have to wait for Winter for this one

Watch this space…