I2C does not work. OS Error

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
dhylands
Posts: 3593
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: I2C does not work. OS Error

Post by dhylands » Wed Feb 17, 2021 9:32 pm

The HD44780 is a parallel interface. You've got a "backpack" with an I2C to GPIO adapter on it.

It looks like one of the PCF8574 adapters (but I can't really tell from the pictures).

If this is the case, then you can't just do an i2c.write to send ASCII data. You need to use the I2C commands that the PCF8574 expects, and use those to manipulate the GPIO lines in the manner that the HD44780 expects.

I have an LCD library available here: https://github.com/dhylands/python_lcd and this file: https://github.com/dhylands/python_lcd/ ... i2c_lcd.py *might* work for you, depending on whether your backpack has a PCF8574 and how it's wired up to the HD44780.

happyandrew
Posts: 4
Joined: Wed Feb 17, 2021 4:11 pm

Re: I2C does not work. OS Error

Post by happyandrew » Thu Feb 18, 2021 6:05 pm

First of all, thank you for your help, most of the time I have no idea what I am doing and only learn by example, and you are quite right, it is the PCF8574T chip. I still have not really got anywhere. I can get the i2c lcd to work on the raspberry pi with python, but when I change thorny to microPython and program the pilo, it does not like the import Python_LCD. Is there a library to import for micropython for this LCD ?

User avatar
dhylands
Posts: 3593
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: I2C does not work. OS Error

Post by dhylands » Thu Feb 18, 2021 7:20 pm

You can try the one I referenced: https://github.com/dhylands/python_lcd (Disclaimer - I wrote that one).

You'd need to copy lcd/esp8266_i2c_lcd.py and lcd_api.py to your pyboard. You might also want the esp8266_i2c_lcd_test.py

I'll see if I can find my HD44780 LCD with the PCF8574 backpack.

User avatar
dhylands
Posts: 3593
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: I2C does not work. OS Error

Post by dhylands » Thu Feb 18, 2021 7:30 pm

Also be aware the the RPi Pico doesn't have 5v tolerant pins, so you may need a level shifter when connencting it. I don't recall if those I2C backpacks work from 3.3v or not.

happyandrew
Posts: 4
Joined: Wed Feb 17, 2021 4:11 pm

Re: I2C does not work. OS Error

Post by happyandrew » Sat Feb 20, 2021 1:27 pm

A BIG THANK YOU, between you and Tyler, I have managed to get the pico to power the LCD. Where I was going wrong was I assumed that all things were equal, that one i2c LCD would be the same as any other. No mention was made in "Getting Started with MicroPython on Raspberry Pi Pico" in the chapter on i2c that you had to buy a specific i2c LCD (which is expensive and difficult to get hold of).

The code they publish just will not work with any other LCD. So what I have leant is this., Most i2c LCD's work in 5 v, that is to say the data coming into the LCD has to be at 5 v. The pico data is at 3v, so you need an additional bit of hardware, 3.3 to 5v level translator. You also need some additional code. https://github.com/t-622/rpi-pico-i2c-lcd.

Once again, thank you.

Post Reply