Since 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:

Shell

1

i2cdetect-y0

or

Shell

1

i2cdetect-y1

(depending on the version of your Raspberry Pi).

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

Detecting the LCD display

Shell

1

2

3

4

5

6

7

8

9

10

pi@raspberrypi$sudo i2cdetect-y0

0123456789abcdef

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…

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:

Python

1

process=Popen(['sudo','killall','-9','DHT.py'])

and restart it.

Python

1

subprocess.Popen(['sudo','./DHT.py'])

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

Categories

Meta

This website uses cookies to personalise content and ads, to provide social media features and to analyse traffic. Information about your use of the site is also shared with social media, advertising and analytics partners who may combine it with other information you’ve provided to them or they’ve collected from your use of their services.OkRead more