Help using Adafruit ESP32-S2 with platformio: BME280 i2c sensor communication issue

Please file an issue in Issues · platformio/platform-espressif32 · GitHub to get help from the developers. If basic I2C sketches do not execute correctly although both should be using the Arduino Core 2.0.3 with the exact same board definition, so especially the same I2C SDA and SCL pins, the outcome should be the same. It not being the same hints at a bug.

How do I make sure that I’m using the same board definition as the arduino ide?

On arduino ide I do Tools > Board > ESP32 Arduino > Adafruit Feather ESP32-S2,
On platformio I have platformio.ini

[env:featheresp32-s2]
platform = espressif32
board = featheresp32-s2
framework = arduino

Does that ensure I have the same board definition?

It should. Selecting Adafruit Feather ESP32-S2 in the Arduino IDE uses the definitions from here, most importantly the variant folder as adafruit_feather_esp32s2.

Using board = featheresp32-s2 maps to featheresp32-s2.json which has that same adafruit_feather_esp32s2 variant set.

Not a platformio issue, Just a feather esp32-s2 quirk.

Needed to configure the i2c correctly (I2C Scan Test | Adafruit ESP32-S2 Feather | Adafruit Learning System)

  pinMode(PIN_I2C_POWER, INPUT);
  delay(1);
  bool polarity = digitalRead(PIN_I2C_POWER);
  pinMode(PIN_I2C_POWER, OUTPUT);
  digitalWrite(PIN_I2C_POWER, !polarity);

But how come in PlatformIo you have to add this code when you said that

where that is not explicitly done? Same could should lead to same results.

This I2C power initialization is already done in the adafruit_feather_esp32s2/variant.cpp, which is called here.

Let me do some sanity checks on whether this function is called at all when using PlatformIO. These _weak functions are quirky in PlatformIO where you usually have to set lib_archive = no in the platformio.ini to make them work.

EDIT: Builder sript is bugged, see comment in issue above.