adafruit_bmp280
¶
CircuitPython driver from BMP280 Temperature and Barometric Pressure sensor
Author(s): ladyada
Implementation Notes¶
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_bmp280.Adafruit_BMP280[source]¶
Base BMP280 object. Use
Adafruit_BMP280_I2C
orAdafruit_BMP280_SPI
instead of this. This checks the BMP280 was found, reads the coefficients and enables the sensor for continuous readsNote
The operational range of the BMP280 is 300-1100 hPa. Pressure measurements outside this range may not be as accurate.
- property altitude: float¶
The altitude based on the sea level pressure (
sea_level_pressure
) - which you must enter ahead of time)
- property iir_filter: int¶
Controls the time constant of the IIR filter Allowed values are set in the IIR_FILTER enum class
- property measurement_time_max: float¶
Maximum time in milliseconds required to complete a measurement in normal mode
- property measurement_time_typical: float¶
Typical time in milliseconds required to complete a measurement in normal mode
- property overscan_pressure: int¶
Pressure Oversampling Allowed values are set in the OVERSCAN enum class
- property overscan_temperature: int¶
Temperature Oversampling Allowed values are set in the OVERSCAN enum class
- property pressure: float | None¶
The compensated pressure in hectoPascals. returns
None
if pressure measurement is disabled
- class adafruit_bmp280.Adafruit_BMP280_I2C(i2c: I2C, address: int = 119)[source]¶
Driver for I2C connected BMP280.
- Parameters:
Quickstart: Importing and using the BMP280
Here is an example of using the
BMP280_I2C
class. First you will need to import the libraries to use the sensorimport board import adafruit_bmp280
Once this is done you can define your
board.I2C
object and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c)
You need to setup the pressure at sea level
bmp280.sea_level_pressure = 1013.25
Now you have access to the
temperature
,pressure
andaltitude
attributestemperature = bmp280.temperature pressure = bmp280.pressure altitude = bmp280.altitude
- class adafruit_bmp280.Adafruit_BMP280_SPI(spi: SPI, cs: DigitalInOut, baudrate=100000)[source]¶
Driver for SPI connected BMP280.
- Parameters:
spi (SPI) – SPI device
cs (DigitalInOut) – Chip Select
baudrate (int) – Clock rate, default is 100000. Can be changed with
baudrate()
Quickstart: Importing and using the BMP280
Here is an example of using the
BMP280_SPI
class. First you will need to import the libraries to use the sensorimport board from digitalio import DigitalInOut, Direction import adafruit_bmp280
Once this is done you can define your
board.SPI
object and define your sensor objectcs = digitalio.DigitalInOut(board.D10) spi = board.SPI() bme280 = adafruit_bmp280.Adafruit_bmp280_SPI(spi, cs)
You need to setup the pressure at sea level
bmp280.sea_level_pressure = 1013.25
Now you have access to the
temperature
,pressure
andaltitude
attributestemperature = bmp280.temperature pressure = bmp280.pressure altitude = bmp280.altitude