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 LCD.py handler that loops and updates the LCD

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

i2cdetect -y 0

or

i2cdetect -y 1

(depending on the version of your Raspberry Pi).

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

pi@raspberrypi $ sudo i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

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…