Hi there,
I am having issues connecting my Raspberry Pi 3B+ to a Sparkfun LCD screen 20x4 via serial connection. (SparkFun 20x4 SerLCD - RGB Backlight (Qwiic) - LCD-16398 - SparkFun Electronics).
I am trying to connect using python code. (GitHub - fourstix/Sparkfun_CircuitPython_SerLCD: CircuitPython driver for the Sparkfun SerLCD displays)
I find this strange because I was able to get it working with my Raspberry Pi Zero W. All I did was move the SD card from the Raspberry Pi Zero to the Raspberry Pi 3B+. I thought it would be the same settings, as per the documentation (Raspberry Pi Documentation - Configuration). However, I have changed the serial settings within to see if I can get it working.
(UPDATE: Ever since changing to a Raspberry Pi 3B+, the LCD is not working anymore on the Raspberry Pi Zero)
My physical connections to the LCD are as follows:
Raspberry Pi Pin17 (3.3V) - LCD RAW power input
Raspberry Pi Pin30 (GND) - LCD Ground connection
Raspberry Pi GPIO14 or Pin8 (Tx) - LCD Rx connection
Other setup information:
- DS3231 RTC module is installed on pins 1,3,5,7,9 on raspberry pi
- several other GPIO pins are being used, but are most likely irrelevant to the LCD issue.
I am currently trying to talk to the serial port using the miniUART (GPIO pins 14 only), and I have also tried using the PL011 UART hardware too. Both show the following on the screen using a baud rate of 9600.
If I change the baud rate to 115200 (on both PL011 and MiniUART), I get the following on the LCD screen.
To verify that my baud rate settings were default:
stty < /dev/ttyAMA0
speed 9600 baud; line = 0;
min = 0; time = 0;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
stty < /dev/ttyS0
speed 9600 baud; line = 0;
min = 0; time = 0;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
=============
I have disabled both consoles for /dev/ttyS0 (MiniUART) and /dev/ttyAMA0 (PL011):
sudo systemctl disable serial-getty@ttyS0.service
sudo systemctl disable serial-getty@ttyAMA0.service
=============
MiniUART SETUP on raspberry pi 3B+ is as follows:
- /boot/config.txt file has the following relevant settings for the MiniUART:
[all]
enable_uart=1
#dtoverlay=uart1,txd1_pin=8,rxd1_pin=10 # Setting MiniUART to Pin 8 and Pin 10
- I removed the appropriate console from my /boot/cmdline.txt for the MiniUART:
console=tty1 root=PARTUUID=ede117fa-02 rootfstype=ext4 fsck.repair=yes rootwait
=============
PL011 SETUP
When trying to use the PL011 UART, I disabled Bluetooth to make the PL011 the primary UART.
- the /boot/config.txt file has the following settings for the PL011:
[all]
enable_uart=1
dtoverlay=disable-bt
#dtoverlay=uart0,txd1_pin=8,rxd1_pin=10 # Setting MiniUART to Pin 8 and Pin 10
- I had to disable the Bluetooth modem:
sudo systemctl disable hciuart
sudo systemctl stop hciuart
- /boot/cmdline.txt for the PL011 is the same as MiniUART. The file is as follows:
console=tty1 root=PARTUUID=ede117fa-02 rootfstype=ext4 fsck.repair=yes rootwait
=============
My CODE:
#!/bin/env python3
import time
from sparkfun_serlcd import Sparkfun_SerLCD_UART
from serial import Serial, PARITY_NONE, STOPBITS_ONE, EIGHTBITS
raspiUART = Serial(
#port='/dev/serial0',
#port='/dev/serial1',
#port='/dev/ttyAMA0',
port='/dev/ttyS0',
baudrate = 9600,
parity=PARITY_NONE,
stopbits=STOPBITS_ONE,
bytesize=EIGHTBITS,
timeout=1)
serlcd = Sparkfun_SerLCD_UART(raspiUART)
serlcd.set_cursor(0,0)
serlcd.write("Is the LCD working??")
serlcd.set_cursor(0,1)
serlcd.write("Monkeys luv bananas.")
serlcd.set_cursor(0,2)
serlcd.write("Yum, bananas. Purple")
serlcd.set_cursor(0,3)
serlcd.write("Monkey Dishwasher!!!")
print("Check the LCD screen.\nSomething legible should be seen.\n\nSleeping for 2 seconds...")
print("One banana ...")
time.sleep(1)
print("Two banana ...")
time.sleep(1)
serlcd.reset()
=============
As a last resort, I attempted an Emergency Reset using this guide (AVR-Based Serial Enabled LCDs Hookup Guide - SparkFun Learn), but was unable to get a “System Reset” message on the screen.
I have been working on this for over a week now and still no success with communicating with the Raspberry Pi 3B+. Any help would be appreciated.