|
| typedef uint8_t | i2c_addr_t |
| | Type for I²C addresses.
|
| |
| typedef float | t_celsius_t |
| | Type for temperature [°C].
|
| |
| typedef float | rh_percent_t |
| | Type for relative humidity [%].
|
| |
| typedef float | p_hpa_t |
| | Type for atmospheric pressure [hPa].
|
| |
- Copyright
- Copyright (c) 2026 Adrien Chevrier. Under AGPL-3.0-or-later license.
ESP-IDF I²C interface for the Bosch BME280 environmental sensor.
This interface uses the driver provided at https://github.com/espressif/esp-iot-solution/tree/1f4206cfe0ff480fedd4fa7860dc41ece6768812/components/sensors/pressure/bme280
◆ BME280_I2C_ADDR
| #define BME280_I2C_ADDR (0x77) |
Default I²C address for BME280 sensors.
◆ i2c_addr_t
◆ p_hpa_t
Type for atmospheric pressure [hPa].
◆ rh_percent_t
Type for relative humidity [%].
◆ t_celsius_t
Type for temperature [°C].
◆ bme280_i2c_delete()
| void bme280_i2c_delete |
( |
bme280_handle_t | sensor | ) |
|
Deinitialize a BME280 sensor and free associated resources.
- Parameters
-
- Warning
- This function must run inside a critical section.
◆ bme280_i2c_init()
| bme280_handle_t bme280_i2c_init |
( |
i2c_bus_handle_t | bus, |
|
|
i2c_addr_t | i2c_addr ) |
Initialize a BME280 sensor on the specified I2C bus.
- Parameters
-
| [in] | bus | The I²C bus handle to use. |
| [in] | i2c_addr | The I²C address of the sensor. |
- Return values
-
| bme280_handle_t | Handle to the initialized BME280 sensor. |
| NULL | On failure. |
- Note
- The returned handle must be freed with
bme280_i2c_delete()
- Warning
- This function must run inside a critical section.
◆ bme280_i2c_read_measurement()
Read temperature, humidity, and pressure from a BME280 sensor.
- Parameters
-
| [in] | sensor | The sensor handle returned by bme280_i2c_init() . |
| [out] | t | Pointer to a variable to receive temperature. |
| [out] | h | Pointer to a variable to receive relative humidity. |
| [out] | p | Pointer to a variable to receive atmospheric pressure. |
- Return values
-
| ESP_OK | On success. |
| ESP_ERR_INVALID_ARG | If any parameter is NULL. |
| ESP_FAIL | If the sensor read fails. |