Page 1 of 2

I2C LCD screen with Raspberry Pi Pico

Posted: Mon Jan 25, 2021 1:04 am
by ElJacko123
I am thinking of buying a Pico for a project I'm working on, but I can't figure out how to use an i2c lcd screen with it. In the product page for the Pico there is a picture of the Pico with a screen attached to it:

https://www.raspberrypi.org/products/raspberry-pi-pico/

My question is what is the simplest way to program a 16 by 2 lcd screen like the one in the picture with micropython and how would I go about doing so. Thanks in advance for any advice.

Re: I2C LCD screen with Raspberry Pi Pico

Posted: Mon Jan 25, 2021 3:20 am
by jimmo
ElJacko123 wrote:
Mon Jan 25, 2021 1:04 am
My question is what is the simplest way to program a 16 by 2 lcd screen like the one in the picture with micropython and how would I go about doing so. Thanks in advance for any advice.
The LCD in the display is a LCD1602 module.

There's a MicroPython driver by dhylands (who is very active on this forum) at https://github.com/dhylands/python_lcd

Re: I2C LCD screen with Raspberry Pi Pico

Posted: Mon Jan 25, 2021 5:42 am
by ElJacko123
Thanks for the reply.
I have seen this library here before, and i wasn't sure if it was compatible with the Pico. What files in the library would I have to copy onto the Pico to drive the 1602?

Re: I2C LCD screen with Raspberry Pi Pico

Posted: Tue Jan 26, 2021 12:44 am
by jimmo
ElJacko123 wrote:
Mon Jan 25, 2021 5:42 am
I have seen this library here before, and i wasn't sure if it was compatible with the Pico. What files in the library would I have to copy onto the Pico to drive the 1602?
The Pico port provides the same machine.I2C API that other ports provide. So for example you could copy esp8266_i2c_lcd.py (and you'll also need lcd_api.py).

The way this library works is that lcd_api.py does the common stuff and the various xyz_i2c_lcd.py provide port-specific details. Now that most ports are providing the machine module, they all end up looking the same (I don't actually see any esp8266-specific stuff in esp8266_i2c_lcd.py).

You could use esp8266_i2c_lcd_test.py to test it too, the only thing you'll need to change is the pin numbers.

Re: I2C LCD screen with Raspberry Pi Pico

Posted: Tue Jan 26, 2021 1:03 am
by ElJacko123
Alright thanks that is what I was looking for. :D

Re: I2C LCD screen with Raspberry Pi Pico

Posted: Thu Jan 28, 2021 5:17 pm
by NikLever
Hi
I'm tinkering with the Raspberry PI Pico, basically I have no idea what I'm doing, a complete beginner. I'm trying to get a QAPASS lcd1602 board working. I copied esp8266_i2c_lcd.py and lcd_api.py to the pico and tried running esp8266_i2c_lcd_test.py. I changed the oins for sda and scl, but I get

Traceback (most recent call last):
File "<stdin>", line 47, in <module>
File "<stdin>", line 14, in test_main
TypeError: 'id' argument required

I can't see any evidence of id in the code.

Any advice?
Cheers Nik

Re: I2C LCD screen with Raspberry Pi Pico

Posted: Thu Jan 28, 2021 6:17 pm
by dhylands
I'm going to guess that it's the id passed to machine.I2C

I don't have my RPi Pico yet, so I can't confirm.

Looking at the source it looks like an ID is required:
https://github.com/micropython/micropyt ... 2ee64a1R64

and this makes sense since there are 2 I2C blocks which can each appear on any of the pins.

Re: I2C LCD screen with Raspberry Pi Pico

Posted: Thu Jan 28, 2021 7:36 pm
by Roberthh
You have to give the number of the I2c unit, which is 0 or 1. For instance

i2c = I2C(1, sda=Pin(14), scl=Pin(15))

Here GPIO14 and GPIO15 are used with ID1. The mapping between I2C ID and GPIO number is on the Pinout.

Re: I2C LCD screen with Raspberry Pi Pico

Posted: Fri Jan 29, 2021 3:38 pm
by NikLever
Thanks so much to both of you. Now working perfectly.

So this is because the Pico has two I2C buses?

Re: I2C LCD screen with Raspberry Pi Pico

Posted: Mon Feb 01, 2021 1:08 am
by jimmo
NikLever wrote:
Fri Jan 29, 2021 3:38 pm
So this is because the Pico has two I2C buses?
Yep. Sorry I missed that detail in the original reply!