0

I am trying to use a 4x20 LCD display with RPLCD module. Its working. But if I run the program ten times every four or five times LCD shows these three garbage values(See below images). Here is my code:

from RPLCD.gpio import CharLCD
import RPi.GPIO as GPIO

class LCD(object):
    def __init__(self):
        GPIO.setwarnings(False)

        self.lcd = CharLCD(pin_rs = 15, pin_e = 16 \
            , pin_backlight = 18 \
            , pins_data = [21, 22, 23, 24] \
            , numbering_mode = GPIO.BOARD \
            , cols = 20, rows = 4, dotsize = 8 \
            , charmap = 'A02', auto_linebreaks = True \
            , backlight_mode = 'active_high')

        self.lcd.clear()
        self.lcd.cursor_mode = 'hide'
        self.lcd.backlight_enable = True
        self.lcd.write_string("hello, world")

    def close(self):
        self.lcd.close(clear = True)

if __name__ == "__main__":
    disp = LCD()

    try:
        while True:
            pass

    except KeyboardInterrupt:
        disp.close()

lcd garbage 1 lcd garbage 2 lcd garbage 3

1

This should be fixed in version 1.2.1: https://github.com/dbrgn/RPLCD/pull/91

If you've been experiencing the described issues with garbled text occasionally on initialization/use of the display, try setting the parameter compat_mode=True, which allows for better interoperability with slower displays.

    self.lcd = CharLCD(pin_rs = 15, pin_e = 16 \
        , pin_backlight = 18 \
        , pins_data = [21, 22, 23, 24] \
        , numbering_mode = GPIO.BOARD \
        , cols = 20, rows = 4, dotsize = 8 \
        , charmap = 'A02', auto_linebreaks = True \
        , backlight_mode = 'active_high' \
        , compat_mode = True)
  • 1
    I am currently not working with hardwares, So I can't verify this myself. But by reading comments in github thread, I am assuming this issue is fixed. – Ashfaqur Rahman Mar 22 at 16:00
0

This is actually a bug of the RPLCD module.

Adafruit CharLCD can be used as an alternative.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.