Julien Lazarewicz 88b4754e49 Fix aht20 build: drop reference to package-manager-generated version macros
AHT20_VER_MAJOR/MINOR/PATCH were only defined via Espressif's
cu_pkg_define_version CMake helper (espressif__cmake_utilities), which
this fork no longer depends on.
2026-07-05 23:44:56 +02:00

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:

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

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
Description
No description provided
Readme 57 KiB
Languages
C 99.4%
CMake 0.6%