Black Lives Matter - Action and Equality.
0

Can I change the default address for the CircuitPython LCD?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Can I change the default address for the CircuitPython LCD?

by craignied on Wed Dec 25, 2019 8:31 pm

Hi! I'm playing around with a Metro Express M0 board and trying to get it to display on a Jansane 16x2 1602 LCD (https://www.amazon.com/gp/product/B07D83DY17/) with Circuit Python. I'm trying to adapt the instructions found at https://learn.adafruit.com/i2c-spi-lcd-backpack/python-circuitpython . I know that the Metro is seeing the device, as for

Code: Select all | TOGGLE FULL SIZE
import board
import busio

i2c = busio.I2C(board.SCL, board.SDA)

while not i2c.try_lock():
    pass

while True:
    print("I2C addresses found:", [hex(device_address)
                                   for device_address in i2c.scan()])
    time.sleep(2)


I get:
I2C addresses found: ['0x27']

which agrees with the default address for the LCD.

However, if I try:

Code: Select all | TOGGLE FULL SIZE
import adafruit_character_lcd.character_lcd_i2c as character_lcd

i2c = busio.I2C(board.SCL, board.SDA)
lcd = character_lcd.Character_LCD_I2C(i2c, 16, 2)


I get:
...
File "adafruit_bus_device/i2c_device.py", line 171, in __probe_for_device
ValueError: No I2C device at address: 20


Is the I2C address hard coded into the library files in CircuitPython? Is there any way to set if for address 20?

Thanks in advance!
craignied
 
Posts: 4
Joined: Tue Jan 24, 2012 11:50 am

Re: Can I change the default address for the CircuitPython L

by dastels on Thu Dec 26, 2019 1:32 pm

The things is, the CircuiutPython library is written for the display sold in the Adafruit shop. There's no gaurentee at all that the controller on what you have works in the same way. I do see address jumpers on the board you linked to (A0-A2) so you might be able to get it using address 0x20 (which is hardcoded for the 23008 used in the displays in the shop). Still the controller chip may not be remotely similar... but those address selectors are encouraging at least.

Dave

dastels
 
Posts: 2473
Joined: Tue Oct 20, 2015 3:22 pm

Re: Can I change the default address for the CircuitPython L

by dastels on Thu Dec 26, 2019 1:34 pm

The amazon listing does mention a library. It's probably in C/C++ but it could be ported to CircuitPython.

dastels
 
Posts: 2473
Joined: Tue Oct 20, 2015 3:22 pm

Re: Can I change the default address for the CircuitPython L

by craignied on Thu Dec 26, 2019 5:57 pm

Thanks! Makes perfect sense. The jumpers on the board seem to add to a base that is greater than the Adafruit LCD backpack default, so I can't get to it that way. But I did download the driver software from https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx, replaced mcp23008.mpy with mcp23008.py in lib on the Metro board, and changed _MCP23008_ADDRESS on line 40 from const(0x20) to const(0x27). No errors when running! However, the LCD flashed and then stayed dark. So the hardware driver on the Jansane isn't compatible with the CircuitPython code designed for the Adafruit backpack.
craignied
 
Posts: 4
Joined: Tue Jan 24, 2012 11:50 am

Re: Can I change the default address for the CircuitPython L

by RobinLandal on Tue May 12, 2020 1:51 pm

Just tried out a similar old LCD (KL SN102) with Circuit Playground Express and got the exact same adress error, not finding adress 20. Tried doing exactly as @craignied and got the same result, error vanished but got just a flashing screen with no characters.
Guess one could use it for morse code though ;)

RobinLandal
 
Posts: 1
Joined: Tue May 12, 2020 1:25 pm

Please be positive and constructive with your questions and comments.