- Notifications
You must be signed in to change notification settings - Fork1
This is a MicroPython library for the Raspberry Pi Pico and allows communicating with the BMP280 pressure sensor through the SPI and I2C protocols.
License
flrrth/pico-bmp280
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a MicroPython library for the Raspberry Pi Pico and allows communicating with theBMP280 pressure sensorthrough the SPI and I2C protocols.
frommachineimportPin,SPIfromutimeimportsleepfrombmp280importBMP280SPIspi1_sck=Pin(10)spi1_tx=Pin(11)spi1_rx=Pin(12)spi1_csn=Pin(13,Pin.OUT,value=1)spi1=SPI(1,sck=spi1_sck,mosi=spi1_tx,miso=spi1_rx)bmp280_spi=BMP280SPI(spi1,spi1_csn)whileTrue:readout=bmp280_spi.measurementsprint(f"Temperature:{readout['t']} °C, pressure:{readout['p']} hPa.")sleep(1)
This is the circuit for the example code above. It uses theAdafruit BMP280breakout board.
frommachineimportPin,I2Cfromutimeimportsleepfrombmp280importBMP280I2Ci2c0_sda=Pin(8)i2c0_scl=Pin(9)i2c0=I2C(0,sda=i2c0_sda,scl=i2c0_scl,freq=400000)bmp280_i2c=BMP280I2C(0x77,i2c0)# address may be differentwhileTrue:readout=bmp280_i2c.measurementsprint(f"Temperature:{readout['t']} °C, pressure:{readout['p']} hPa.")sleep(1)
The default settings use theweather monitoring settings as specifiedby Bosch in thedatasheet(see table 15 on page 19). The configuration can be changed by overriding the defaults set inBMP280Configuration
.
The next example configures the BMP280 forindoor navigation:
frombmp280importBMP280I2C,BMP280Configurationconfig=BMP280Configuration()config.power_mode=BMP280Configuration.POWER_MODE_NORMALconfig.pressure_oversampling=BMP280Configuration.PRESSURE_OVERSAMPLING_16Xconfig.temperature_oversampling=BMP280Configuration.TEMPERATURE_OVERSAMPLING_2Xconfig.filter_coefficient=BMP280Configuration.FILTER_COEFFICIENT_16config.standby_time=BMP280Configuration.STANDBY_TIME__5_MSbmp280_i2c=BMP280I2C(0x77,i2c0,config)
About
This is a MicroPython library for the Raspberry Pi Pico and allows communicating with the BMP280 pressure sensor through the SPI and I2C protocols.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.