I2C connection to mpr121 using circuit python

Hi, im trying to connect the nano to a mpr121 breakout board by adafruit. Im using circuit python rather that Arduino ide. Ive posted the code and the serial data below. Im able to query the SDA and SCL pins from the board library and it returns A4 and A5. However I cannot seem to make an I2C instance without an error. Ive checked wiring but all seems fine. Im aware adafruit boards already apply a pull up resistor as well.

Any help much appreciated :slight_smile:

import time

import board

import busio

import adafruit_mpr121

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

mpr121 = adafruit_mpr121.MPR121(i2c)
---- Sent utf8 encoded message: "board.SCL\r" ----
**board.SCL**
**board.A5**
>>> 
---- Sent utf8 encoded message: "board.SDA\r" ----
**board.SDA**
**board.A4**
>>> 
---- Sent utf8 encoded message: "import busio\r" ----
import busio
>>> 
---- Sent utf8 encoded message: "i2c = busio.I2C(board.SCL, board.SDA)\r" ----
i2c = busio.I2C(board.SCL, board.SDA)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: **No pull up found on SDA or SCL; check your wiring**
>>> 

You're using an Arduino Nano ESP32, correct?
Have you tried using MicroPython rather than CircuitPython?

BusIO is a wrapper to several protocols, including I2C, so I'm not sure how it configures things behind the scene, but can you try and replace board.SCL and board.SDA with 12 and 11?

Could be that the mapping is wrong.

1 Like

Im running a nano esp 32.

Im new to running Arduino's in python and I choose CP because it seemed better supported for adafruit shields.

The class doesn't except int's as arguments

I see...

try this at the beginning

from machine import Pin

at time of initialisation of BusIO

i2c = busio.I2C(Pin(12), Pin(11))

I'm not a fan of CP, but I love MicroPython.
In theory you could just replace all of the BusIO stuff with native MicroPython,
but I don't know how much Adafruit hides/modifies from the original code.

from machine import I2C, Pin

i2c = I2C(scl = Pin(12), sda = Pin(11))

(you may get a deprecation warning but it's ok)

then you can pass this newly created i2c object as your new mpr121 object parameter

1 Like

it is also possible that their library just requires a BusIO instance to do something and this will fail :smiling_face_with_tear:

You are pushing your luck.
There are many odd things together. You have a ESP32-S3 instead of a ESP32, you use an Arduino board and then try to run Adafruit code on it, you use CircuitPython, the MPR121 is one of those weird chips that do not acknowledge to any I2C write if I remember it well, and then there are issues.

The Arduino Nano ESP32 uses a ESP32-S3.

Some boards have to turn on the power for the I2C bus. The Arduino Nano ESP32 does not need that as far as I know.
Some boards should be used with SDA1 and SCL1: https://forums.adafruit.com/viewtopic.php?t=189629
The ESP32-S3 might have issues for the I2C bus: https://github.com/adafruit/circuitpython/issues/6311

2 Likes

Ive tested another i2c device and that works fine so it seems as tho a hardware issue

I actually have one of those lying around somewhere.
I'm curious if I can make it work using MicroPython.
Will report back :slight_smile:

1 Like

I swapped out the mpr sheild for a a different mpr shield with qwik connection and that works fine.

Adafruit support the nano esp32 with a cp build. Thats why I was curious to try, from my few days of experimenting I'm finding the repl great, easier to try things, a lot less code but ofc a lot slower to boot up.

Ive rarely used python for anything other that computer vision but I'm curious now and will persevere with cp and mp

I just tested a Grove MPR121 attached via Grove to my Nano ESP32 and an i2c scan finds it right away.
Which Adafruit MPR121 are you using?
I found a breakout board in my drawer but I'm curious to see if there's something particular about the one you were having trouble with :slight_smile:

1 Like

Its the Adafruit mpr121 for Arduino boards, I wasn't aware it was designed for unos but anyway I just wired up the vin and i2c pins to the nano. Now, interestingly the reset button functioned but I never saw any power lights on the adafruit board.

found your mistake: VIN

The onboard IC is powered via the 3V3 pin, so your shield was actually off all the time :smiley:


Originally I had tried the 3v and 5v pins but nothing

Then I have no explanation :slight_smile: