Page 1 of 1

ESP32 default I2C pins?

Posted: Sun Jul 16, 2023 11:33 pm
by bsdinis
I am getting very conflicting information about the default I2C pins on the ESP32, everywhere I read says the default I2C0 pins are GPIO21 and GPIO22 for SDA and SCL respectively but the following screenshot from the datasheet seems to suggest otherwise
image-3.png
image-3.png (271.99 KiB) Viewed 10286 times

Re: ESP32 default I2C pins?

Posted: Mon Jul 17, 2023 2:12 am
by ESP_Sprite
The hardware doesn't define any default pins: the GPIO matrix carries the I2C signals but they're not sent out to any GPIO on startup; software can however use any (compatible and not otherwise used) GPIO to put the I2C signals on. I think software like Arduino does use certain IO pins when you don't specify them yourself; that could be the 21 and 22 you're referring to.

Re: ESP32 default I2C pins?

Posted: Mon Jul 17, 2023 3:15 am
by bsdinis
You say the hardware doesn't define the default pins, I know most interfaces can be reassigned to any GPIO but most of them have dedicated/default pins such as UART, SPI, SDIO, USB (ESP32-S3), etc.
Are you saying that the two I2C interfaces on the ESP32 do not have dedicated pins at all, and that GPIO21 and GPIO22 were merely arbitrary "defaults" set by the IDE?

Re: ESP32 default I2C pins?

Posted: Mon Jul 17, 2023 5:25 am
by ESP_Sprite
Yes. I2C isn't alone in this: from memory I2S, PCNT, MCPWM, Ethernet, one of the UARTS and the LEDC also don't have 'default' GPIOs.

Re: ESP32 default I2C pins?

Posted: Tue Jan 16, 2024 3:10 pm
by tionebrr
Just for accuracy, most of the RMII EMAC peripheral pins are fixed.