I2C LCD screen with Raspberry Pi Pico

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
ElJacko123
Posts: 3
Joined: Mon Jan 25, 2021 1:00 am

I2C LCD screen with Raspberry Pi Pico

Post by ElJacko123 » Mon Jan 25, 2021 1:04 am

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.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: I2C LCD screen with Raspberry Pi Pico

Post by jimmo » Mon Jan 25, 2021 3:20 am

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

ElJacko123
Posts: 3
Joined: Mon Jan 25, 2021 1:00 am

Re: I2C LCD screen with Raspberry Pi Pico

Post by ElJacko123 » Mon Jan 25, 2021 5:42 am

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?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: I2C LCD screen with Raspberry Pi Pico

Post by jimmo » Tue Jan 26, 2021 12:44 am

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.

ElJacko123
Posts: 3
Joined: Mon Jan 25, 2021 1:00 am

Re: I2C LCD screen with Raspberry Pi Pico

Post by ElJacko123 » Tue Jan 26, 2021 1:03 am

Alright thanks that is what I was looking for. :D
I love Miss Vickies Sea Salt and Malt Vinegar Kettle Cooked Potato Chips.
How about you?

NikLever
Posts: 2
Joined: Thu Jan 28, 2021 5:10 pm

Re: I2C LCD screen with Raspberry Pi Pico

Post by NikLever » Thu Jan 28, 2021 5:17 pm

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

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

Re: I2C LCD screen with Raspberry Pi Pico

Post by dhylands » Thu Jan 28, 2021 6:17 pm

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.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: I2C LCD screen with Raspberry Pi Pico

Post by Roberthh » Thu Jan 28, 2021 7:36 pm

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.

NikLever
Posts: 2
Joined: Thu Jan 28, 2021 5:10 pm

Re: I2C LCD screen with Raspberry Pi Pico

Post by NikLever » Fri Jan 29, 2021 3:38 pm

Thanks so much to both of you. Now working perfectly.

So this is because the Pico has two I2C buses?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: I2C LCD screen with Raspberry Pi Pico

Post by jimmo » Mon Feb 01, 2021 1:08 am

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!

Post Reply