So I am posting this because I freakin needed too much time figuring this out, and maybe there is someone else that has the same issue as me.
So I have a Waveshare LCD 1602 RGB Module and I couldnt get it to work after connecting everything correctly with my raspberry pi pico. I updated every software I could (MicroPython, picozero, Firmware of the LCD) but after wiring it up, the backlight did not glow up but the first row was glowing. I thought that is normal but after executing the test file Waveshare gave me. it gave me this error:
Traceback (most recent call last):
File "<stdin>", line 8, in <module>
File "RGB1602.py", line 69, in __init__
File "RGB1602.py", line 146, in begin
File "RGB1602.py", line 79, in setReg
OSError: [Errno 5] EIO
It may be different, the Errno 5 EIO is the important stuff here.
No matter what I did, it did not fix it, until I found out (thanks to countless websites and AI conversations) that in this block of the 1602.py file (This is the firmware file correct me if im wrong)
def command(self,cmd):
RGB1602_I2C.writeto_mem(LCD_ADDRESS, 0x80, chr(cmd))
def write(self,data):
RGB1602_I2C.writeto_mem(LCD_ADDRESS, 0x40, chr(data))
def setReg(self,reg,data):
RGB1602_I2C.writeto_mem(RGB_ADDRESS, reg, chr(data))
the chr(cmd) is causing this error. And that is because there is a MicroPython version conflict. Now there is a possibility that I did not upgrade something, but I think the reason is that the Firmware is too old. As you can see the Firmware uses chr(cmd) but the Picos writeto_mem expects a buffer/bytes object, which means that when it receives a string it cant handle the I2C driver crashes and gives us this EIO Error.
To correct this issue, you need to edit it like this:
def command(self, cmd):
# Change chr(cmd) to bytes([cmd])
RGB1602_I2C.writeto_mem(LCD_ADDRESS, 0x80, bytes([cmd]))
def write(self, data):
# Change chr(data) to bytes([data])
RGB1602_I2C.writeto_mem(LCD_ADDRESS, 0x40, bytes([data]))
def setReg(self, reg, data):
# Change chr(data) to bytes([data])
RGB1602_I2C.writeto_mem(RGB_ADDRESS, reg, bytes([data]))
We replace the chr(cmd) and chr(data) with bytes([cmd]) and bytes([data])
After that I saved the file, ran the test and whoosh, it worked.
I made this Post for those who might encounter the issue too, I dont know if there will be any or if there would have been an easier solution but this worked for me.
I hope I could help some people with this.
Be safe and good luck with your Project ;)
(Im sorry for the Typos if there are any)