• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 Default I2C pins and Wire.begin

Q&A Forum › Category: ESP32 › ESP32 Default I2C pins and Wire.begin
0 Vote Up Vote Down
Donald asked 2 years ago

I2C
The ESP32 has two I2C channels and any pin can be set as SDA or SCL. When using the ESP32 with the Arduino IDE, the default I2C pins are:

  • GPIO 21 (SDA)
  • GPIO 22 (SCL)

If you want to use other pins, when using the wire library, you just need to call:

Wire.begin(SDA, SCL);


So, if I’m working on a project that is already using 21 and 22 (like the DS3231 RTC) and I want to add another I2C sensor/device, I would use the Wire function call like 

Wire.begin(12,13);

which would assign SDA = 12 and SCL = 13?

Question Tags: wire I2c
2 Answers
0 Vote Up Vote Down
Donald answered 2 years ago

I think I got a handle on it now. 
If you want to use other pins, when using the wire library, you #define the pins, like this:

#define SDA 33
#define SCL 32

and in the setup() you use them with this:

Wire.begin(SDA, SCL)
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
If the sensors have different I2C addresses, which is probable, you can use the same pins.
Alternatively, you can use different pins without any problem.
We have a guide about I2C with the ESP32 that you might find useful: 

ESP32 I2C Communication: Set Pins, Multiple Bus Interfaces and Peripherals (Arduino IDE)


Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.