Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

NotificationsYou must be signed in to change notification settings

flrrth/pico-bmp280

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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.

SPI Example

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.

Fritzing wiring for the SPI example code .

I2C Example

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)

Fritzing wiring for the I2C example code .

Customizing configuration

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp