Trouble with I2C on Sparkfun Pro Micro ESP32-C3

I’m migrating from Arduino IDE to PlatformIO and I had some trouble getting my code to work. I’ve solved the issue so I’m just posting here in case someone else has the same issue.

Communicating over I2C was working in Arduino IDE but not PlatformIO, it would just keep failing to connect to my I2C device. Eventually someone suggested I try setting the SDA/SCL pins before Wire.begin(), so I found the relevant pin numbers from SparkFun’s github and called Wire.setPins(5, 6); before Wire.begin() and lo and behold there was my I2C device!

Really looking forward to working with PIO. Arduino IDE is great for beginners but it takes so unnecessarily long to compile and upload, PIO is so much faster.

It feel like my main issue is that the SparkFun Pro Micro ESP32-C3 is not in the list of support boards? I had to pick the closest one I could find which in this case was the esp32-c3-devkitm-1. How can I make a proper board file for this board, and would that solve the issues I was having?

Before this board can be added to PlatformIO it must be added to Espressif Arduino Core to make the “variants/sparkfun_pro_micro_esp32c3/pins_arduino.h” file available.

See the “Installation (Windows)” section in the github repo:

The SparkFun Pro Micro - ESP32-C3 board files are waiting on an official release from the Espressif Arduino Core…

It seems the sparkfun repo is out of date, because I see it in the espressif/arduino-esp32 github here. It was added nearly a year ago and there have been multiple releases since, so I’m not really sure what you’re talking about?

In any case what would be the next steps to get it to be a PIO supported board?

Oh, I missed that one :slight_smile:

Create a board file that matches the settings and create a PR here

This board manifest should match the Sparkfun Pro Micro ESP32-C3:

sparkfun_pro_micro_esp32c3.json:

Until your PR gets merged you can be place this file either

  1. in a “boards” folder located in the projects folder
  2. in a “boards” folder located in the .platformio folder (which is located in the users home folder)

Option 1 will only be available to the current project
Option 2 will make this board available for all your projects

Got it, thanks for the board file, I’ll make sure to take a good look at it before I make the PR.

Back to my original question, will this help with getting I2C working out of the box on this board with Arduino libs? I guess the board file you provided has "variant": "sparkfun_pro_micro_esp32c3" and that’s supposed to pick up the relevant data from Espressif Arduino Core and properly set up I2C? (Among other things probably but lets stick to this as an example).

I don’t know which board you where using before but it may have used this

instead of

SDA and SCL are used in Wire.cpp to initialize the default pins:

It’s the other way around. The pins_arduino.h is picked up to define the default pins which are then used by Espressif Arduino Core.

Yes

I finally got around to trying to make the PR to add the board, and things are a whole mess of confusing out there.

It turns out that platformio’s espressif32 platform only supports espressif’s espressif/arduino-esp32 up to version 2.0.17. The current files included in platformio’s arduino framework for esp32 appear to be coming from commit dcc1105 (see how the version of framework-arduinoespressif32 contains that sha), which unfortunately does not include the pro micro under the variants folder (although it was added in Jan 2024 and that commit is from May 2024 :man_shrugging:)

There’s a whole thread about having platformio support espressif/arduino-esp32 v3.0+ but it doesn’t appear to be going anywhere.

What a can of worms! And sha’s and version numbers! :face_with_head_bandage:

I guess I’ll just stick to hardcoding the SDA/SCL pin numbers.

Try pioarduino platform-espressif32! This provides the latest Espressif Arduino 3.x.

Espressif Arduino 3.2.0 has just released yesterday and is already available via pioarduino! Simply change the platform:

platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20/platform-espressif32.zip

Thanks for the tip; I saw it while searching around but I was a bit confused because there’s no info on the github org or repo as to what pioarduino is (except for the “acronym” being spelled out in the readme). Is it a community provided platform? I wonder why there’s a community provided platform for arduino for esp32 and an official one from platformio? This kind of stuff makes me want to keep shopping around for development environments, although I do appreciate that PIO gives me more control over the build process and file layout than arduino and has a nice interface for build/upload/monitor.

Anyway I did try out pioarduino like you suggested and I was able to point straight to the board without even having to do my own board file! Hopefully the forked platforms end up getting back together and we can all get our boards working :slight_smile: