ESP32-P4 OBC Firmware
ESP-IDF firmware for Plant-B CubeSat OBC
 
Loading...
Searching...
No Matches
BME280 Sensor

Macros

#define BME280_I2C_ADDR   (0x77)
 Default I²C address for BME280 sensors.
 

Typedefs

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].
 

Functions

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.
 
esp_err_t bme280_i2c_read_measurement (bme280_handle_t sensor, t_celsius_t *t, rh_percent_t *h, p_hpa_t *p)
 Read temperature, humidity, and pressure from a BME280 sensor.
 
void bme280_i2c_delete (bme280_handle_t sensor)
 Deinitialize a BME280 sensor and free associated resources.
 

Detailed Description

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

Macro Definition Documentation

◆ BME280_I2C_ADDR

#define BME280_I2C_ADDR   (0x77)

Default I²C address for BME280 sensors.

Typedef Documentation

◆ i2c_addr_t

typedef uint8_t i2c_addr_t

Type for I²C addresses.

◆ p_hpa_t

typedef float p_hpa_t

Type for atmospheric pressure [hPa].

◆ rh_percent_t

typedef float rh_percent_t

Type for relative humidity [%].

◆ t_celsius_t

typedef float t_celsius_t

Type for temperature [°C].

Function Documentation

◆ bme280_i2c_delete()

void bme280_i2c_delete ( bme280_handle_t sensor)

Deinitialize a BME280 sensor and free associated resources.

Parameters
[in,out]sensorThe sensor handle returned by bme280_i2c_init().
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]busThe I²C bus handle to use.
[in]i2c_addrThe I²C address of the sensor.
Return values
bme280_handle_tHandle to the initialized BME280 sensor.
NULLOn 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()

esp_err_t bme280_i2c_read_measurement ( bme280_handle_t sensor,
t_celsius_t * t,
rh_percent_t * h,
p_hpa_t * p )

Read temperature, humidity, and pressure from a BME280 sensor.

Parameters
[in]sensorThe sensor handle returned by bme280_i2c_init() .
[out]tPointer to a variable to receive temperature.
[out]hPointer to a variable to receive relative humidity.
[out]pPointer to a variable to receive atmospheric pressure.
Return values
ESP_OKOn success.
ESP_ERR_INVALID_ARGIf any parameter is NULL.
ESP_FAILIf the sensor read fails.