Need help with an I2C LCD display

June 16, 2024, 13:28

dethress

I have a breadboard with Raspberry Pi Pico on it and connected an I2C LCD Display. I can't get the LCD to "work" though. Can't print anything on it despite having the libraries installed on the micro controller. I've tried .putstr and .putchar but neither work, although .backlight_on and .backlight_off work. If this makes things clearer, I have a 2x16 LCD with I2C LCM1602 converter

.jozekk

is it something like this?

.jozekk

matter of fact, wait, this is it

.jozekk

could you show the code

.jozekk

and double check if all the pins are correct

.jozekk

oh yeah also

.jozekk

this is correct

.jozekk

this is not

dethress

It's literally the same model, bought from Botland as well

.jozekk

yeah that makes sense

.jozekk

but show the code

dethress

py

import utime

import machine
from machine import I2C, Pin
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd

I2C_ADDR     = 0x27
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16

sda = Pin(0)
scl = Pin(1)

i2c = I2C(0, sda=sda, scl=scl, freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)

lcd.clear()
lcd.move_to(5,0)
lcd.putstr("Howdy")
utime.sleep(2)

dethress

Yeah SDA going to Pin(0) and SCL to Pin(1)

dethress

This is just one of many test codes I've tried to run anything on my LCD

.jozekk

\\\py [code] \\\

.jozekk

do this instead

dethress

The original code I've tried as well was from the tomshardware site:
py
from machine import I2C, Pin
from time import sleep
from pico_i2c_lcd import I2cLcd
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)

I2C_ADDR = i2c.scan()[0]
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
while True:
    print(I2C_ADDR)
    lcd.blink_cursor_on()
    lcd.putstr("I2C Address:"+str(I2C_ADDR)+"\n")
    lcd.putstr("Tom's Hardware")
    sleep(2)
    lcd.clear()
    lcd.putstr("I2C Address:"+str(hex(I2C_ADDR))+"\n")
    lcd.putstr("Tom's Hardware")
    sleep(2)
    lcd.blink_cursor_off()
    lcd.clear()
    lcd.putstr("Backlight Test")
    for i in range(10):
        lcd.backlight_on()
        sleep(0.2)
        lcd.backlight_off()
        sleep(0.2)
    lcd.backlight_on()
    lcd.hide_cursor()
    for i in range(20):
        lcd.putstr(str(i))
        sleep(0.4)
        lcd.clear()

.jozekk

py
from machine import I2C # type: ignore
from machine import Pin as pin # type: ignore
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd

I2C_ADDR     = 0x27
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16

i2c = I2C(0, sda=pin(0), scl=pin(1), freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)

lcd.putstr("hello world")

.jozekk

see if this works

.jozekk

this works for me

.jozekk

i have the exact same model

dethress

Nope, doesn't work either

.jozekk

probably means the pins are wrong then

.jozekk


dethress

I'll be numering by physical pins, so GND 28, power 40, SDA 1 and SCL 2

.jozekk

gnd - gnd vcc - vbus or vsys sda - gp0, pin 1 scl - gp1, pin 2

dethress

Yup, that's how I got it done

.jozekk

is the backlight on at least?

.jozekk

also, from the front the text is pretty much invisible

.jozekk

so look at it from an angle

dethress

Yeah, other commands such as .backlight_off/on work

dethress

I checked all the angles already as well

.jozekk

are you absolutely sure the breadboard connections arent wrong

dethress

Wait. I see really FAINT image of the text, is it supposed to be THAT barely visible?

.jozekk

yes.

.jozekk

💀

.jozekk

apparently so

dethress

Oh damn... Should I get myself a different LCD perhaps? A more visible one?

.jozekk

i mean its your lcd

.jozekk

i dont really need anything more

.jozekk

so i didnt get another

dethress

Any way to set the contrast higher then?

.jozekk

i dont believe there is one no

dethress

Anyway, thanks a lot for the help :)

dethress

I figured it out, on the I2C board there's a potentiometer taht u can rotate with a screwdriver

.jozekk

WAIT HOLY FUCK THERE IS??

dethress

Voltage control = contrast control

dethress

It's now bright as day for me lol

.jozekk

YOOOOO

.jozekk

HOL ON

.jozekk

I DID NOT KNOW THIS

.jozekk

oooohhh thats what that was

dethress

Hahaha it took me a while, I just found a youtube video explaining it

.jozekk

holy crap man thanks for figuring this out

.jozekk

i thought i was stuck with it being invisible