Updated on 26-03-2021, to include extended ASCII chars.
Changes with previous installation:
New driver:
If V2.x
sudo pip install RPLCD
If V3.x
sudo pip3 install RPLCD
new script
Installation has been performed on a fresh instance of Raspbian:
Make sure to pay attention to your python version, as mixing python 2.x and 3x might cause all kind of strange errors. Instruction to check your version are further down in this post.It’s just a very basic of displaying track data, feel free to modify to your needs. I am sure code could be more efficient (especially the attribute reading), but I am not a python programmer. (and def. not looking to master a 7th programming language
)I’ve assumed that you have JRiver running, with the media network enabled and protected with a password. If you don’t use a password, you need to modify the function. See track.py below. The script comes as is.
When Artist or track exceeds 20 chars, the line will scroll. Due to the physical properties, scrolling looks like blinking for the scrolling lines, but I do prefer this over strange shorten text.
If you see text that belongs to 1 line appearing on other lines, your LCD_WIDTH is set incorrect.
What is needed:- rPi board
- A compatible LCD Matrix (I am using a GeeekPi IIC/I2C 2004 20x4 Character LCD Module Display from Amazon.) https://www.amazon.nl/gp/product/B07QNKCLJM
- 4 wires to connect everything
- SSH access to the Pi, or run everything from the rPi desktop
Perform the needed setups:- Enable wait for boot till network is available:
sudo raspi-config
- Create a new directory in your home folder
cd ~/
mkdir jriverapi && cd jriverapi
Place lcd_V2.0.zip in this folder.
- Unzip the content
unzip lcd_V2.0.zip
We will execute the script: “Enable_I2C.sh”. This scipt will, if needed, enable I2C and install i2c-tools.
- Make script executable, execute it and shutdown the rPi:
chmod a+x Enable_I2C.sh
sudo ./Enable_I2C.sh
sudo shutdown
- Connect display
rPi | Display |
Pin3 (SDA) | SDA |
Pin2 (5V) | VCC |
Pin5 (SCL) | SCL |
Pin39 (GND) | GND |
Boot the rPi
Check your python version, important to avoid random errors. The libraries we are going to add need to be for the correct version.
python --version
If V2.x
sudo pip install RPLCD
sudo apt-get install python-smbus
If V3.x
sudo pip3 install RPLCD
sudo apt-get install python3-smbus
Reboot the rPi
Locate the address for the display. Depending on the version of your rPi, you need to run one off the following lines:
i2cdetect -y 0
i2cdetect -y 1
- Configure the library
Make sure to respect the indents, don’t add spaces or tabs. This will result in errors like below:
cd ~/jriverapi
- Configure track.py
Set your display width, URL and credentials.
nano track.py
LCD_WIDTH = 20
sURL = 'http://localhost:52199/MCWS/v1/Playback/Info?Zone=-1'
sUsername = 'username'
sPassword = 'password'
Modify the address with the info taken form the previous command:
mylcd = CharLCD('PCF8574', 0x27,charmap='A00')
When done: press "CTRL + X, ENTER CTRL + O" to save it.
You can test the script by running:
cd ~/jriverapi
python track.py
If all went well, you'll see:
When JRiver is playing:
If you want the script started when the rPi boots, you can do this very easy by adding a line to the cron:
crontab -e
@reboot sleep 10 && python /home/pi/jriver_api/track.py
Reboot your Pi. If all went well it should come up with the hostname and time.
If the screen stays blank, you might need to increase “sleep 10” to a higher number.
This should not happen as we "Enable wait for boot till network is available".
Good luck.