import bmp180
The bmp180 module reads Bosch BMP180-compatible barometric pressure sensors over I2C. It is meant for simple weather, altitude, and room pressure scripts where humidity is not required.
Quick example
import bmp180 bmp180.begin(21, 22) reading = bmp180.read() print(reading["temperature"]) print(reading["pressure_hpa"]) bmp180.configure(oversampling=3) print(bmp180.altitude())
importbmp180
BMP180 temperature and pressure module.
The bmp180 module reads Bosch BMP180-compatible barometric pressure sensors over I2C. It is meant for simple weather, altitude, and room pressure scripts where humidity is not required.
bmp180.begin(sda: int, scl: int, address: int = None, frequency: int = None, port: int = None) -> bool
bmp180.begin(sda: int, scl: int, address: int = None, frequency: int = None, port: int = None) -> boolInitialize a BMP180 sensor on I2C.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
sda |
int |
positional or keyword | Yes | GPIO pin used for I2C SDA. |
scl |
int |
positional or keyword | Yes | GPIO pin used for I2C SCL. |
address |
int |
positional or keyword | No | Optional I2C address. BMP180 uses 0x77. Defaults to 0x77. |
frequency |
int |
positional or keyword | No | Optional I2C bus speed in hertz. Defaults to 100000. |
port |
int |
positional or keyword | No | Optional ESP-IDF I2C port number. Defaults to 0. |
bool True when a BMP180 with chip id 0x55 is detected and calibration is loaded.
bmp180.configure(oversampling: int = None) -> bool
bmp180.configure(oversampling: int = None) -> boolSet the default pressure oversampling mode.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
oversampling |
int |
positional or keyword | No | Optional pressure oversampling mode from 0 through 3. Defaults to 3. Higher values are slower but less noisy. |
bool True when the oversampling value is accepted.
bmp180.read(oversampling: int = None) -> dict
bmp180.read(oversampling: int = None) -> dictRead temperature and pressure.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
oversampling |
int |
positional or keyword | No | Optional pressure oversampling mode for this read only. Use 0, 1, 2, or 3. Defaults to the configured value. |
dict Dict with ``ok``, ``c``, ``f``, ``temperature``, ``pressure_pa``, ``pressure_hpa``, raw ADC values, ``oversampling``, and ``address``.
bmp180.temperature() -> float
bmp180.temperature() -> floatRead temperature in Celsius.
float Float temperature in degrees Celsius.
bmp180.pressure(oversampling: int = None) -> float
bmp180.pressure(oversampling: int = None) -> floatRead barometric pressure.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
oversampling |
int |
positional or keyword | No | Optional pressure oversampling mode for this read only. Use 0, 1, 2, or 3. Defaults to the configured value. |
float Float pressure in hPa.
bmp180.altitude(sea_level_hpa: float = None, oversampling: int = None) -> float
bmp180.altitude(sea_level_hpa: float = None, oversampling: int = None) -> floatEstimate altitude from pressure.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
sea_level_hpa |
float |
positional or keyword | No | Optional sea-level pressure in hPa. Defaults to 1013.25. |
oversampling |
int |
positional or keyword | No | Optional pressure oversampling mode for this read only. Use 0, 1, 2, or 3. Defaults to the configured value. |
float Float estimated altitude in meters.
bmp180.reset() -> bool
bmp180.reset() -> boolSoft-reset the BMP180 and reload calibration.
bool True when reset and calibration reload succeed.
bmp180.id() -> int
bmp180.id() -> intRead the BMP180 chip id register.
int Integer chip id. A BMP180 reports 0x55.
bmp180.info() -> dict
bmp180.info() -> dictReturn BMP180 module state.
dict Dict with initialization state, I2C pins, address, chip id, oversampling, and calibration state.