ESP32 default I2C pins?

User avatar
bsdinis
Posts: 2
Joined: Sun Jul 16, 2023 11:23 pm

ESP32 default I2C pins?

Postby bsdinis » Sun Jul 16, 2023 11:33 pm

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 10331 times

ESP_Sprite
Posts: 9762
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 default I2C pins?

Postby ESP_Sprite » Mon Jul 17, 2023 2:12 am

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.

User avatar
bsdinis
Posts: 2
Joined: Sun Jul 16, 2023 11:23 pm

Re: ESP32 default I2C pins?

Postby bsdinis » Mon Jul 17, 2023 3:15 am

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?

ESP_Sprite
Posts: 9762
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 default I2C pins?

Postby ESP_Sprite » Mon Jul 17, 2023 5:25 am

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.

tionebrr
Posts: 8
Joined: Mon Jul 20, 2020 3:16 pm

Re: ESP32 default I2C pins?

Postby tionebrr » Tue Jan 16, 2024 3:10 pm

Just for accuracy, most of the RMII EMAC peripheral pins are fixed.

Who is online

Users browsing this forum: No registered users and 56 guests