DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
i2c.h File Reference

The one owner of the shared I2C bus bring-up for the peripheral drivers. More...

#include "ServerConfig.h"
#include <Wire.h>

Go to the source code of this file.

Functions

void detws_i2c_begin ()
 Bring up the shared I2C bus on DETWS_I2C_SDA_PIN / DETWS_I2C_SCL_PIN (-1 = default).
 

Detailed Description

The one owner of the shared I2C bus bring-up for the peripheral drivers.

The sensor / peripheral drivers (RTC, SHT3x, MPR121, ADS1115, INA219, PCA9685) all share a single I2C bus, so they all initialize it through detws_i2c_begin() rather than calling Wire.begin() themselves. That gives one place to choose the pins: DETWS_I2C_SDA_PIN / DETWS_I2C_SCL_PIN (default -1 = the platform default GPIO 21 / 22). Move them off 21/22 when those pins are needed elsewhere - most importantly a wired-Ethernet PHY: the LAN8720 RMII on the classic ESP32 (WROOM/WROVER) and the ESP32-P4 uses GPIO 21 and 22 (the S3/C3 have no RMII EMAC and use an SPI Ethernet such as the W5500 instead). Re-begin is idempotent, so per-driver calls are harmless.

Host builds compile this to nothing (there is no Wire); the I2C transfer is ESP32-only.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file i2c.h.

Function Documentation

◆ detws_i2c_begin()

void detws_i2c_begin ( )
inline

Bring up the shared I2C bus on DETWS_I2C_SDA_PIN / DETWS_I2C_SCL_PIN (-1 = default).

Definition at line 33 of file i2c.h.

References DETWS_I2C_SCL_PIN, and DETWS_I2C_SDA_PIN.