Arduino Nano RP2040 Connect - I2C with custom Nina Firmware

Dear all,

@Arduino Crew: THX for this amazing board, it is EXACTLY what we needed :slight_smile: .

There is one issue I cannot resolve on my own. Basically we are using our own ESP32 (Nina module) firmware, which is located here: GitHub - asterics/esp32_mouse_keyboard: ESP32 implementation for HID over GATT Keyboard and Mouse (Bluetooth Low Energy). Including serial API for external modules (similar to Adafruit EZKey HID)

In addition, we want to use the I2C interface of the RP2040 to interface an external sensor.

One major problem came up:

If the ESP32 is running, after some time (usually 5-30s), the I2C bus is unusable. This happens reproducible only if the ESP32 is not in reset.

I've seen you connected SDA & SCL to pins 13/34 & 14/39 of the ESP32.
34/39 don't seem to be a problem, as they are input only and used for A4/A5.

But what about 13 & 14, these are JTAG pins?

I've tried following, but no solution:

  • Change nothing in the pin configuration
  • Set to input without Pullup/Pulldown (via gpio_config of esp-idf)
  • Set to input/output open drain with pullup, not working at all
  • Set to I/O/OD and use iomux to route the SDA/SCL lines (but without enabling I2C in the ESP32) -> not working at all

The last 2 options are also done in the nina-fw repository, but these are making it worse in our case.

Do you maybe have a suggestion or a solution to overcome this issue?
Removing the connection between SDA_crypto & SDA is unfortunately no option.

Any help is greatly appreciated!
Greetings

One of the most beautiful features of the RP2040 chip is the "PIO" feature -- the ability to load dedicated software programs that implement protocols like I2C on any of the other pins of the chip with the same performance as true hardware I2C. This is because a dedicated co-processor runs the protocol.

I would just pick two unused pins, run a PIO-based "soft i2c" on them, and never look back.

The greatest caveat (temporary at worst) is that someone hasn't wrapped "PIO soft i2c" into an Arduino library yet. The RP2040 SDK on the other hand includes a "soft i2c" PIO program as one of its PIO examples (see pico-examples/i2c.pio at master ยท raspberrypi/pico-examples ยท GitHub). I don't know if someone has cooked that into an Arduino library. If not, I'd consider it my challenge to include that PIO program in my sketch and call into it as a substitute.

Dear @reswobslc ,

THX for the hint with the PIOs.

We choose the route with a second I2C interface as well, simply because we are designing a PCB anyway, and there is not enough time to debug this kind of nondeterministic error :-).

Because the RP2040 has 2 hardware I2Cs, we choose Wire1 and it works as expected.

But still, the original problem persists.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.