Tab5 I2C on Arduino works, same code does not work on PlatformIO
-
Tab5 uses internally I2C for example for RTC and Battery-status. I can add I2C devices on the I2C port in this way:
setup():// Start I2C if (!M5.Ex_I2C.begin(I2C_NUM_0, 31, 32)) { Serial.println("Ex_I2C initialization failed!"); } else { exI2CInitialized = true; Serial.println("Ex_I2C ok! "); }In the modified I2C sensor code:
uint8_t TON_BME280::read8(byte reg) { return M5.Ex_I2C.readRegister8(BME280_ADDRESS, reg, 400000U); }This works on Arduino, RTC (internal) and BME280 (external) are available.
However, on PlatformIO same code, it does not work. The first call to battery status returns zeroes and subsequent I2C calls hang the system.
Why use PlatformIO then? It compiles quicker, more control over libraries possible (lvgl 8 or 9 etc)
Why use the same pins as internal for external I2C instead of two fresh ones?
Modules like relays or stepper controllers all use the 31 and 32 pins for I2Cplatformio.ini:
[env:m5stack-tab5-p4] platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip board = m5stack-tab5-p4 framework = arduino upload_port = COM12 monitor_port = COM12 upload_speed = 1500000 monitor_speed = 115200 build_type = debug board_build.partitions = partitions.csv lib_deps = lvgl/lvgl@^8.3.11 paulstoffregen/OneWire@^2.3.8 milesburton/DallasTemperature@^4.0.5