# espidf_i2c Forked/rewritten ESP-IDF I2C sensor drivers, unified onto the native `driver/i2c_master.h` API (ESP-IDF >= 5.3) so every sensor shares the same handle lifecycle instead of each vendor bringing its own I2C abstraction (`i2c_bus`, `i2cdev`, etc.). ## Common API convention Every driver in this repo follows the same shape: ```c typedef void *xxx_handle_t; esp_err_t xxx_create(i2c_master_bus_handle_t bus_handle, uint8_t dev_addr, xxx_handle_t *handle_ret); esp_err_t xxx_delete(xxx_handle_t handle); // ... device-specific read/measure functions taking xxx_handle_t ``` Callers create one `i2c_master_bus_handle_t` via `i2c_new_master_bus()` and pass it to each sensor's `_create()`, which internally calls `i2c_master_bus_add_device()`. No sensor wraps the bus a second time. ## Components - `bh1750/` — ambient light sensor. Already used the native API upstream; relocated here unchanged. - `aht20/` — temperature/humidity sensor. Rewritten from Espressif's `i2c_bus` component onto `i2c_master_transmit`/`i2c_master_receive`. - `sgp40/` — VOC index sensor. Rewritten from esp-idf-lib's `i2cdev` component onto `i2c_master_transmit`/`i2c_master_receive`; the Sensirion VOC algorithm files are carried over unmodified (no I2C dependency). ## Using from a project ```yaml dependencies: laz/bh1750: git: https://git.jeese.fr/laz/espidf_i2c.git path: bh1750 laz/aht20: git: https://git.jeese.fr/laz/espidf_i2c.git path: aht20 laz/sgp40: git: https://git.jeese.fr/laz/espidf_i2c.git path: sgp40 ```