Using the GROVE Port to run I2C sensors using ESP-IDF doesnt work.

  • Hello, I'm using the I2C driver library from ESP-IDF to communicate with some sensors connected to the GROVE port and I have this problem where the sensors are just not responding to any I2C writes and reads from the microcontroller (NO ACKs). The weird thing is, when I used the premade libraries from Adafruit (using Wire), it works just fine and managed to find the sensors on the GROVE port.

    One thing I noticed, is that when I use the Adafruit libraries, the power LED on the sensor module lights up meaning the sensor is receiving power from the GROVE port. When I use the I2C drivers from ESP-IDF however, the LED on the module doesnt light up.

    What I found to be crazy weird is that, when I flash the M5 with the Arduino code first, the M5 could then find the sensor when I flash the ESP32 with the code using the I2C driver from ESP-IDF. This however only works when I directly flash the IDF code after I flashed the Arduino code on the M5. The LED on the sensor is still turned on for some reason with the new code flashed on the M5.

    When I turn the M5 off (press side button) and turn it on again, the M5 would then be unable to find the sensor and the LED of the sensor module doesnt light up.

    This is what I found out while tinkering around between IDF and Arduino with the M5StickC Plus. It would be nice if any engineers from M5Stack can help me figure out why the M5StickC Plus is behaving like this.

    Thanks for the help,


  • Hello @ameero95

    I think the reason is that the Arduino M5StickC/Plus library turns the external power on when M5.begin() is called which in turn calls Axp.begin(). Below line in the Axp.begin() function looks like a viable candidate:

        // Enable Ext, LDO2, LDO3, DCDC1
        Write1Byte(0x12, Read8bit(0x12) | 0x4D);

    Also have a look at the documentation here. Check out the Power structure block diagram and or the schematic.


  • @felmue Hi, thanks for the reply. I'll look into it :D