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.
-
altitude
¶ The altitude based on the sea level pressure (
sea_level_pressure
) - which you must enter ahead of time)
-
iir_filter
¶ Controls the time constant of the IIR filter Allowed values are set in the IIR_FILTER enum class
-
measurement_time_max
¶ Maximum time in milliseconds required to complete a measurement in normal mode
-
measurement_time_typical
¶ Typical time in milliseconds required to complete a measurement in normal mode
-
mode
¶ Operation mode Allowed values are set in the MODE enum class
-
overscan_pressure
¶ Pressure Oversampling Allowed values are set in the OVERSCAN enum class
-
overscan_temperature
¶ Temperature Oversampling Allowed values are set in the OVERSCAN enum class
-
pressure
¶ The compensated pressure in hectoPascals. returns
None
if pressure measurement is disabled
-
standby_period
¶ Control the inactive period when in Normal mode Allowed standby periods are set the STANDBY enum class
-
temperature
¶ The compensated temperature in degrees Celsius.
-
-
class
adafruit_bmp280.
Adafruit_BMP280_I2C
(i2c, address=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, cs, 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