I2C Device Registered on CLI but not in Python

I have a JANSANE 16x2 1602 LCD I2C that i purchased and am trying to run on a raspberry pi 3 b+.

Following this tutorial

https://learn.adafruit.com/adafruit-16x2-character-lcd-plus-keypad-for-raspberry-pi/python-usage

I am trying to run the below code:

import board
import busio
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
lcd_columns = 16
lcd_rows = 2
i2c = busio.I2C(board.SCL, board.SDA)
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows)
lcd.message("TEST")

However I get the error:

ValueError: No I2C device at address: 20

When I run i2cdetect I get:

sudo i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Which tells me that the device is being registered. Can someone please explain the error in python?

Answers 2


  • The address of the board connected to your Pi is 27(hex) and not 20(hex).

    The row shows the most significant digit and the column shows the least significant digit of the address in hex.

    Going by Amazon, this is the default for the PCF8574T chipset on this board but looking at the pictures, one of the interface cards have a set of three address pins that may let you set the address to match the software but I cannot tell without the manual that matches your board.

    From a quick scan of the source, I think the issue is in the i2c = busio.I2C(board.SCL, board.SDA) line where the board library is setting the wrong address for you but without knowing the tutorial you are following I can only guess this is a Micropython issue.

    It would help if you can edit your question with links to the instructions and your board (as the one I found was 5V Arduino).


Related Questions