bmp180: Driver for BMP180 digital pressure sensor
Defines
- BMP180_DEVICE_ADDRESS
I2C address.
Enums
- enum bmp180_mode_t
Hardware accuracy mode.
See Table 3 of the datasheet
Values:
- enumerator BMP180_MODE_ULTRA_LOW_POWER
1 sample, 4.5 ms
- enumerator BMP180_MODE_STANDARD
2 samples, 7.5 ms
- enumerator BMP180_MODE_HIGH_RESOLUTION
4 samples, 13.5 ms
- enumerator BMP180_MODE_ULTRA_HIGH_RESOLUTION
8 samples, 25.5 ms
Functions
- esp_err_t bmp180_init_desc(bmp180_dev_t *dev, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)
Initialize device descriptor.
- Parameters:
dev – Device descriptor
port – I2C port number
sda_gpio – GPIO pin number for SDA
scl_gpio – GPIO pin number for SCL
- Returns:
ESP_OKon success
ESP_ERR_INVALID_ARGifdevis NULL
ESP_ERR_NO_MEMif the descriptor mutex cannot be created
- esp_err_t bmp180_free_desc(bmp180_dev_t *dev)
Free device descriptor.
- Parameters:
dev – Pointer to BMP180 device descriptor
- Returns:
ESP_OKon success
ESP_ERR_INVALID_ARGifdevis NULL
- esp_err_t bmp180_reset(bmp180_dev_t *dev)
Reset the sensor.
Runs the power-on sequence: the control and the data registers return to their default values and an ongoing conversion is aborted. The calibration coefficients are stored in the E2PROM and survive the reset.
- Parameters:
dev – Pointer to BMP180 device descriptor
- Returns:
ESP_OKon success
ESP_ERR_INVALID_ARGifdevis NULLanother error code from the I2C layer
- esp_err_t bmp180_init(bmp180_dev_t *dev)
Initialize device.
Calls bmp180_reset, verifies the chip ID and reads the calibration coefficients. The reset puts the sensor into the known state after an MCU restart while the sensor stays powered.
- Parameters:
dev – Pointer to BMP180 device descriptor
- Returns:
ESP_OKon success
ESP_ERR_INVALID_ARGifdevis NULL
ESP_ERR_NOT_FOUNDif the chip ID is not the BMP180 oneanother error code from the I2C layer
- esp_err_t bmp180_measure(bmp180_dev_t *dev, float *temperature, uint32_t *pressure, bmp180_mode_t oss)
Measure temperature and pressure.
The temperature is measured before the pressure, the pressure measurement needs the temperature one. At least one of the output parameters has to be given; when the pressure is not requested it is not measured, which saves the conversion time of its mode.
- Parameters:
dev – Pointer to BMP180 device descriptor
temperature – [out] Temperature in degrees Celsius, may be NULL
pressure – [out] Pressure in Pa, may be NULL
oss – Measurement mode, one of bmp180_mode_t
- Returns:
ESP_OKon success
ESP_ERR_INVALID_ARGifdevis NULL, both outputs are NULL orossis out of range
ESP_ERR_TIMEOUTif a conversion does not finish in time
ESP_ERR_INVALID_RESPONSEif the measured value is not physical, which means that the calibration data is corruptedanother error code from the I2C layer
- struct bmp180_dev_t
#include <bmp180.h>BMP180 device descriptor.