MojoScale Studio Docs
API Reference

bmp180

BMP180 temperature and pressure module.

Studio Docs Sensors & I/O

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.

API 9 available

bmp180.begin(sda: int, scl: int, address: int = None, frequency: int = None, port: int = None) -> bool

Initialize a BMP180 sensor on I2C.

Parameters
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.
Returns

bool True when a BMP180 with chip id 0x55 is detected and calibration is loaded.

bmp180.configure(oversampling: int = None) -> bool

Set the default pressure oversampling mode.

Parameters
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.
Returns

bool True when the oversampling value is accepted.

bmp180.read(oversampling: int = None) -> dict

Read temperature and pressure.

Parameters
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.
Returns

dict Dict with ``ok``, ``c``, ``f``, ``temperature``, ``pressure_pa``, ``pressure_hpa``, raw ADC values, ``oversampling``, and ``address``.

bmp180.temperature() -> float

Read temperature in Celsius.

Returns

float Float temperature in degrees Celsius.

bmp180.pressure(oversampling: int = None) -> float

Read barometric pressure.

Parameters
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.
Returns

float Float pressure in hPa.

bmp180.altitude(sea_level_hpa: float = None, oversampling: int = None) -> float

Estimate altitude from pressure.

Parameters
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.
Returns

float Float estimated altitude in meters.

bmp180.reset() -> bool

Soft-reset the BMP180 and reload calibration.

Returns

bool True when reset and calibration reload succeed.

bmp180.id() -> int

Read the BMP180 chip id register.

Returns

int Integer chip id. A BMP180 reports 0x55.

bmp180.info() -> dict

Return BMP180 module state.

Returns

dict Dict with initialization state, I2C pins, address, chip id, oversampling, and calibration state.