I have decided to add a 16×2 LCD to my Raspberry Pi 3 based network audio player with PCM1794 DAC in order to see what is currently playing and the bitrate of the output without having to check my phone. I don’t like the number of wires that parallel LCD connection requires so I started looking for a 16×2 LCD with I2C interface which is not too expensive.
I found a very cheap 16×2 LCD on Aliexpress and even cheaper I2C backpack for it. I personally chose green foreground with black background as it looks nice in my enclosure, but there are other options too: https://www.aliexpress.com/item/1709948156.html
I decided to use LCDproc as it is a mature solution that works (almost) out of the box with HD44780 based displays over I2C, it just needs a driver and proper configuration. It is easy to control it via a telnet-like TCP protocol with Python, PHP, C++ or any other language of choice and it has many options such as managing a scrolling text, widgets, icons etc. which reduced my code to only a few lines.
My Github repository contains everything needed to pair HD44780 based LCD displays and LCDProc on Raspberry Pi via I2C. It includes installation instructions for installing on Moode or other Raspbian/Debian based OS.
- play.php – My script to fetch currently playing song on Moode Audio and push it to the LCD via LCDProc, you can edit this one to fit your needs
- client.php – LCDProc PHP client library by Peter Clarke (@theapi)
- LCDd.conf – My /etc/LCDd.conf which works perfectly with the display linked above
- hd44780.so – Driver for LCDProc HD44780 I2C displays by @wilberforce. You should copy it to /usr/lib/lcdproc/
I am running Moode Audio v6.2.1 which is based on Raspbian so it should work with any other Debian/Raspbian based OS, and most likely with Ubuntu too. I have written a small script which parses /var/local/www/currentsong.txt (a file automatically updated by Moode) and displays currently playing song/output bitrate info on the LCD. You can rewrite the script to work for any other OS, display size or purpose.