bmp180 is a micropython module for the Bosch BMP180 sensor. It measures
temperature as well as pressure, with a high enough resolution to calculate
If you have any questions, open an issue.
Wiring the sensor to the pyboard
from bmp180 import BMP180 from machine import I2C, Pin # create an I2C bus object accordingly to the port you are using bus = I2C(1, baudrate=100000) # on pyboard # bus = I2C(scl=Pin(4), sda=Pin(5), freq=100000) # on esp8266 bmp180 = BMP180(bus) bmp180.oversample_sett = 2 bmp180.baseline = 101325 temp = bmp180.temperature p = bmp180.pressure altitude = bmp180.altitude print(temp, p, altitude)
Make sure to either use this in fast loops or call gauge() in fast loops to make sure to always get current values. If you call pressure() once and then again 10 seconds later, it will report a 10 seconds old value. Look at the gauge() function in the source to understand this. Alternatively use the blocking_read() method.
Returns a list of all compensation values.
Generator refreshing the measurements. Does not need to be called manually.
Nonblocking read of temperature in degree C.
Nonblocking read of pressure in Pascal (divide result by 100 for millibar/hP).
Trigger a read and wait until data is available.
Altitude in m.
ID of chip is hardcoded on the sensor.
Sets the accuracy. Default: 0
- 0 lowest accuracy, fastest
- 3 highest accuracy, slowest
Pressure at Main Sea Level. The default is 101325 Pa, but you can use your local QNH in Pa.
To get different altitudes, use this as baselines:
|pressure||101325 or None|