|
Envorimental Monitoring
|
Driver interface for the BMP180 barometric pressure and temperature sensor. More...
#include "stdint.h"#include "stddef.h"Go to the source code of this file.
Data Structures | |
| struct | BMP180_CalibrationData_t |
| BMP180 factory calibration coefficients. More... | |
| struct | BMP180_HandleTypeDef |
| BMP180 driver handle. More... | |
| union | BMP180_CtrlMeas_t |
| Bit-field overlay for the BMP180 ctrl_meas register (0xF4). More... | |
Macros | |
| #define | BMP180_CALIB_DATA_SIZE 22 |
| #define | BMP180_ADDRESS 0xEE |
| #define | BMP180_REG_CALIB_DATA_START 0xAA |
| #define | BMP180_REG_CALIB_DATA_END 0xBF |
| #define | BMP180_REG_OUT_XLSB 0xF8 |
| #define | BMP180_REG_OUT_LSB 0xF7 |
| #define | BMP180_REG_OUT_MSB 0xF6 |
| #define | BMP180_REG_CTRL_MEAS 0xF4 |
| #define | BMP180_REG_SOFT_RST 0xE0 |
| #define | BMP180_REG_CHIP_ID 0xD0 |
| #define | BMP180_MEASURE_TEMP 0x0E |
| #define | BMP180_MEASURE_PRESSURE 0x14 |
Functions | |
| int8_t | BMP180_Init (BMP180_HandleTypeDef *dev) |
| Initialises the BMP180 sensor and reads calibration data. | |
| int8_t | BMP180_Read (BMP180_HandleTypeDef *dev) |
| Reads both temperature and pressure from the BMP180. | |
| int8_t | BMP180_Read_Temperature (BMP180_HandleTypeDef *dev) |
| Reads only the temperature from the BMP180. | |
| int8_t | BMP180_get_ut (BMP180_HandleTypeDef *dev, int32_t *ut_result) |
| Triggers and reads the raw (uncompensated) temperature ADC value. | |
| int8_t | BMP180_get_up (BMP180_HandleTypeDef *dev, int32_t *up_result) |
| Triggers and reads the raw (uncompensated) pressure ADC value. | |
| void | BMP180_calc_temperature (BMP180_HandleTypeDef *dev, int32_t ut) |
| Converts a raw temperature ADC value to degrees Celsius. | |
| void | BMP180_calc_pressure (BMP180_HandleTypeDef *dev, int32_t up) |
| Converts a raw pressure ADC value to Pascals. | |
Driver interface for the BMP180 barometric pressure and temperature sensor.
The BMP180 uses a fixed I2C address of 0x77 and requires a one-time read of 11 factory calibration coefficients stored in non-volatile memory. These coefficients are used in a multi-step integer compensation algorithm specified by Bosch to convert raw ADC values into temperature (°C) and pressure (Pa).
The oversampling setting (oss) controls the trade-off between conversion time and noise: 0 = ultra-low power, 3 = ultra-high resolution.
Platform independence is achieved through injected I2C and delay function pointers, identical in style to the AHT20 and BH1750 drivers.
| #define BMP180_ADDRESS 0xEE |
8-bit I2C address (0x77 << 1).
| #define BMP180_CALIB_DATA_SIZE 22 |
Size of the calibration data block in bytes.
| #define BMP180_MEASURE_PRESSURE 0x14 |
ctrl_meas value to start a pressure read.
| #define BMP180_MEASURE_TEMP 0x0E |
ctrl_meas value to start a temperature read.
| #define BMP180_REG_CALIB_DATA_END 0xBF |
Last calibration register address.
| #define BMP180_REG_CALIB_DATA_START 0xAA |
First calibration register address.
| #define BMP180_REG_CHIP_ID 0xD0 |
Chip ID register (expected value: 0x55).
| #define BMP180_REG_CTRL_MEAS 0xF4 |
Control/measurement register.
| #define BMP180_REG_OUT_LSB 0xF7 |
ADC output LSB register.
| #define BMP180_REG_OUT_MSB 0xF6 |
ADC output MSB register.
| #define BMP180_REG_OUT_XLSB 0xF8 |
ADC output XLSB register.
| #define BMP180_REG_SOFT_RST 0xE0 |
Soft-reset register.
| void BMP180_calc_pressure | ( | BMP180_HandleTypeDef * | dev, |
| int32_t | up ) |
Converts a raw pressure ADC value to Pascals.
Implements the full Bosch pressure compensation algorithm. BMP180_calc_temperature() must be called first to populate dev->b5.
| [in,out] | dev | Pointer to an initialised BMP180_HandleTypeDef. |
| [in] | up | Raw uncompensated pressure value from BMP180_get_up(). |
| void BMP180_calc_temperature | ( | BMP180_HandleTypeDef * | dev, |
| int32_t | ut ) |
Converts a raw temperature ADC value to degrees Celsius.
Uses the Bosch compensation algorithm. Also computes and stores dev->b5 which is required by BMP180_calc_pressure().
| [in,out] | dev | Pointer to an initialised BMP180_HandleTypeDef. |
| [in] | ut | Raw uncompensated temperature value from BMP180_get_ut(). |
| int8_t BMP180_get_up | ( | BMP180_HandleTypeDef * | dev, |
| int32_t * | up_result ) |
Triggers and reads the raw (uncompensated) pressure ADC value.
| [in,out] | dev | Pointer to an initialised BMP180_HandleTypeDef. |
| [out] | up_result | Pointer to store the raw pressure value. |
| int8_t BMP180_get_ut | ( | BMP180_HandleTypeDef * | dev, |
| int32_t * | ut_result ) |
Triggers and reads the raw (uncompensated) temperature ADC value.
| [in,out] | dev | Pointer to an initialised BMP180_HandleTypeDef. |
| [out] | ut_result | Pointer to store the raw temperature value. |
| int8_t BMP180_Init | ( | BMP180_HandleTypeDef * | dev | ) |
Initialises the BMP180 sensor and reads calibration data.
Verifies the chip ID (0x55) and reads all 11 calibration coefficients from the sensor's EEPROM into dev->calib.
| [in,out] | dev | Pointer to a BMP180_HandleTypeDef with function pointers set. |
| int8_t BMP180_Read | ( | BMP180_HandleTypeDef * | dev | ) |
Reads both temperature and pressure from the BMP180.
Calls BMP180_get_ut(), BMP180_calc_temperature(), BMP180_get_up() and BMP180_calc_pressure() in sequence. Results are stored in dev->temperature_C and dev->pressure_Pa.
| [in,out] | dev | Pointer to an initialised BMP180_HandleTypeDef. |
| int8_t BMP180_Read_Temperature | ( | BMP180_HandleTypeDef * | dev | ) |
Reads only the temperature from the BMP180.
| [in,out] | dev | Pointer to an initialised BMP180_HandleTypeDef. |