CircuitPython on the Pico with a character lcd

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
cheeseshark
 
Posts: 4
Joined: Sun Sep 26, 2021 3:43 pm

CircuitPython on the Pico with a character lcd

Post by cheeseshark »

Hello,

I'm attempting to get a 16x2 I2C LCD module to work with a RPi Pico using Circuitpython.

I'm using the code found in the article here: https://learn.adafruit.com/i2c-spi-lcd- ... cuitpython with the proper modifications for the Pico

Code: Select all

i2c = busio.I2C(board.GP1, board.GP0)
I'm also setting an address for the display of 0x27 or it throws an error ValueError: No I2C device at address: 20

It runs through the code properly but the only output I get is the occasional flash of the backlight, no text on the display.

I'm finding all sorts of code for Micropython and the Pico, but nothing concrete for using Circuitpython and the Pico.

I've tried running the display at both 3.3v and 5v, and there is no difference.

Any help would be greatly appreciated.

Full code :

Code: Select all


# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""Simple test for 16x2 character lcd connected to an MCP23008 I2C LCD backpack."""
import time
import board
import busio
import adafruit_character_lcd.character_lcd_i2c as character_lcd

#initialize I2C bus.
i2c = busio.I2C(board.GP1, board.GP0)

# set LCD dimensions
lcd_cols = 16
lcd_rows = 2
lcd_addr = 0x27

#initialize LCD class
lcd = character_lcd.Character_LCD_I2C(i2c, lcd_cols, lcd_rows, lcd_addr)

# Turn backlight on
lcd.backlight = True
# Print a two line message
lcd.message = "Hello\nCircuitPython"
# Wait 5s
time.sleep(5)
lcd.clear()
# Print two line message right to left
lcd.text_direction = lcd.RIGHT_TO_LEFT
lcd.message = "Hello\nCircuitPython"
# Wait 5s
time.sleep(5)
# Return text direction to left to right
lcd.text_direction = lcd.LEFT_TO_RIGHT
# Display cursor
lcd.clear()
lcd.cursor = True
lcd.message = "Cursor! "
# Wait 5s
time.sleep(5)
# Display blinking cursor
lcd.clear()
lcd.blink = True
lcd.message = "Blinky Cursor!"
# Wait 5s
time.sleep(5)
lcd.blink = False
lcd.clear()
# Create message to scroll
scroll_msg = "<-- Scroll"
lcd.message = scroll_msg
# Scroll message to the left
for i in range(len(scroll_msg)):
    time.sleep(0.5)
    lcd.move_left()
lcd.clear()
lcd.message = "Going to sleep\nCya later!"
time.sleep(5)
# Turn backlight off
lcd.backlight = False
time.sleep(2)

Thanks in advance.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: CircuitPython on the Pico with a character lcd

Post by mikeysklar »

Your i2c address choice of 0x27 might be an issue. Our guide page suggests the default address is 0x70 if no jumpers are soldered.

https://learn.adafruit.com/i2c-spi-lcd- ... no-i2c-use
f you want to have more than one MCP23008 device (like more than one backpack+LCD) each one needs to have a unique 'address'. You can set the address by jumpering the A0 A1 and A2 solder jumpers. By default, no jumpers are soldered, giving an address of 0x70 (offset 0). If you want to have an address of 0x73 (0x70 + offset 3) you would solder A0 (bit 0) and A1 (bit 1) for an address offset of "011" = 3 in binary. Then in the code change:
Maybe you can remove the address hardcoding and setup your GPIO's for i2c usage using this syntax we recommend:

Code: Select all

i2c = busio.I2C(scl=board.GP1, sda=board.GP0)
You can also trying running i2c.scan() with this example code chunk to see if the device appears. If you are still getting address errors please post a photo of your wiring and soldering to confirm any possible issues there.

Code: Select all

import busio
from board import *

i2c = busio.I2C(scl=board.GP1, sda=board.GP0)
print(i2c.scan())
i2c.deinit()

User avatar
cheeseshark
 
Posts: 4
Joined: Sun Sep 26, 2021 3:43 pm

Re: CircuitPython on the Pico with a character lcd

Post by cheeseshark »

I found the issue, the 16x02 LCD was not an Adafruit screen, so it wasn't using an MCP23008 backpack, it was a different chip. I found the proper library for that backpack and everything is working.

I'm in the testing phase currently, but when I go production I'll be using Adafruit parts instead of the cheap stuff.

Thanks for the help.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”