User avatar
mike632t
Posts: 104
Joined: Sat May 19, 2012 7:56 pm
Location: UK

Using an MCP23017 with a Pi Pico [SOLVED]

Tue Jun 01, 2021 10:01 pm

I was just wondering if any one had got this to work, I've tried several different pairs of pins but i2c.scan() doesn't return anything.

Code: Select all

import machine
i2c = machine.I2C(0, sda=machine.Pin(8), scl=machine.Pin(9))
i2c.scan()
It doesn't make any different if I specify the freq as well.

Code: Select all

import machine
i2c=machine.I2C(0, sda=machine.Pin(8), scl=machine.Pin(9), freq=400000)
i2c.scan()
I'm obviously missing something, the MCP23017 works fine with various models of Raspberry Pi, Pi Zero, and a WiPy2.0. The only thing I can think of is that the Pico needs external pull up resistors, but my google fu is weak today and I've not found a definite answer (resistors on their way just in case).

Thanks
Last edited by mike632t on Wed Jun 02, 2021 8:15 pm, edited 1 time in total.

scotty101
Posts: 4413
Joined: Fri Jun 08, 2012 6:03 pm

Re: Using an MCP23017 with a Pi Pico

Wed Jun 02, 2021 3:14 pm

The source code for the MicroPython port indicates that the internal pull up resistors configured when you use machine.I2C so external ones shouldn't be needed.

Check your wiring, especially power and ground.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

pic0
Posts: 54
Joined: Tue Jan 26, 2021 11:04 am

Re: Using an MCP23017 with a Pi Pico

Wed Jun 02, 2021 6:18 pm

Hi,
scotty101 wrote:
Wed Jun 02, 2021 3:14 pm
The source code for the MicroPython port indicates that the internal pull up resistors configured when you use machine.I2C so external ones shouldn't be needed.
As stated here the internal pull ups are vrery weak, so you should add external resistors.

User avatar
mike632t
Posts: 104
Joined: Sat May 19, 2012 7:56 pm
Location: UK

Re: Using an MCP23017 with a Pi Pico

Wed Jun 02, 2021 7:27 pm

Added a couple of external 10K pull up resistors and .. success!!

Code: Select all

>>> i2c = machine.I2C(0, sda=machine.Pin(8), scl=machine.Pin(9))
>>> i2c.scan()
[33]
>>> hex(33)
'0x21'
>>>
Actually discovered that I only needed a single 10K pull up on SCL (MCP23017 pin 12)
Mike T.

Return to “General”