I try to interface my 2004-LCD display with wiringPi (in Python 3). The display is connected to a PCF8574-chip, so I need to use I2C.
This is my test code:
import wiringpi2 as wiringpi
wiringpi.wiringPiSetupSys();
af_base = 100
af_rs = af_base + 0
af_e = af_base + 2
af_db4 = af_base + 4
af_db5 = af_base + 5
af_db6 = af_base + 6
af_db7 = af_base + 7
af_backlight = af_base + 3
def backlight_on():
wiringpi.digitalWrite(af_backlight, 1)
def backlight_off():
wiringpi.digitalWrite(af_backlight, 0)
wiringpi.pcf8574Setup(af_base, 0x27)
lcd_handle = wiringpi.lcdInit(4, 20, 4, af_rs, af_e, af_db4, af_db5, af_db6, af_db7, 0, 0, 0, 0)
backlight_on()
wiringpi.lcdPrintf(lcd_handle, "Hello World!")
The code runs without any errors. The backlight on the LCD first turns out and then turns on again, when I run backlight_on()
.
However, the text doesn't show up on the display.
To check if the LCD or the I2C-chip is damaged, I followed the instructions from this website.
Now comes the strange part:
When I now run the test code from above again, it works without any hassle.
It seems, the other project loads some stuff which is essential for controlling the LCD.
What is missing in my test code to interface the LCD in the first place?