LCD not receiving commands/strings
I have a HD44780 styled LCD screen (4x20) and am using a library I found that was widely used and recommended through my google searching. However, despite the LCD powering on, I'm not getting anything to actually display on the device and would like some guidance to fix this if possible.
Files used from the github library:
ESP32 GPIO LCD
My main looks like this:
from machine import Pin from gpio_lcd import GpioLcd import time lcd = GpioLcd(rs_pin=Pin('P4'), enable_pin=Pin('P11'), d4_pin=Pin('P5'), d5_pin=Pin('P18'), d6_pin=Pin('P21'), d7_pin=Pin('P22'), num_lines=4, num_columns=20) lcd.putstr("It Works!\nSecond Line\nThird Line\nFourth Line") sleep_ms(3000) lcd.clear() count = 0 while True: lcd.move_to(0, 0) lcd.putstr("%7d" % (ticks_ms() // 1000)) sleep_ms(1000) count += 1
I initially followed the code exactly as shown in the test file. However, I was getting a ValueError issue with the initialization of the LCD, so I changed that to send a string for each pin as shown in GPIO pin initialization in the pycom documentation (as opposed to the general micropython documentation).
In the command line, I'm able to check the pins and they seem to be initialized properly. I'm also able to sometimes get a value of 1 or 0 for the various data pins when checking lcd.d4_pin.value() (for example).
@robert-hh Thank you so much. It was literally just my misuse of P18. I was just not paying attention to that detail and should have been referring back to the pinout.
robert-hh last edited by
@Lennac A few notes.
- P18 is an input only pin. You cannot use that for the LCD.
- These LCD have an additional R/W pin. Usually this is Pin5. That must be set to low level, since you need to write only.
- Usually these are 5V devices. Writing to it at 3.3Level should work, but the LCD requires 5V for operation.
- There is also the LCD contrast pin 3 at the LCD, with which the contrast of the LCD is controlled. Some LCD have a potentiometer instead, some require a proper voltage somewhere between 0 and 5V.