Listed on

Tronixlabs LCD Backpack

For my Raspberry Pi GPS NTP server project I found it useful to have a display available to put up simple status messages for example the IP address and the output of ntpq.

To that end I purchased a Serial I2C backpack for HD44780-compatible LCD modules from Tronixlabs. Although they provide a tutorial for the use of these devices I had greater success with a different Python library.

The program displays text messages on the screen (The code does need to be patched with the number of lines the LCD display supports). Naturally the program does need to run as root to access the SDI bus - sudo makes this trivial.

The program uses the i2c_lcd_smbus module ( from Think Bowl ( key to getting it to work is the declaration

lcd = i2c_lcd(0x27,1, 2, 1, 0, 4, 5, 6, 7, 3)

which specifies the default config of the Serial I2C backpack.

The solution isn’t perfect as the backlight turns off for brief moment when the program starts.

An example of the usage of the code is the following crontab line (executes once per minute):

* * * * * root ( /usr/bin/ntpq -p | /bin/sed '1,2d' | /usr/bin/cut -c1-20 | /usr/local/bin/ ; sleep 30 ; /usr/local/bin/ "`/bin/hostname -I`" "`/bin/date`")

which displays the ntp status, ip address and time.

Connection is a trivial 4 wires as the interface is 3.3V tolerant.