BME280 how to use forced mode with micropython library

Hi All,

I have recently got a BME280 and I am using the rpi pico micropython library (pimoroni-pico/micropython/modules/breakout_bme280 at main · pimoroni/pimoroni-pico · GitHub)

I would like to run this in forced mode, as per the documentation

I can see there is a bme.configure() method - but I cant figure out how to set the mode to forced using it - unless I am missing something stupid.

Doing bme.configure(FILTER_COEFF_2, STANDBY_TIME_0_5_MS, OVERSAMPLING_16X, OVERSAMPLING_2X, OVERSAMPLING_1X)

Results in NameError: name 'FILTER_COEFF_2' isn't defined - presumably since python doesnt know about the constants

However doing: bme.configure(bme.FILTER_COEFF_2) also doesnt work.

I tried looking at the c++ code for more insight but C isnt my strong point.

Does anyone have any ideas?

Many thanks

You’ll need to add the constants you want to use to your import line, try something like:

from breakout_bme280 import BreakoutBME280, FILTER_COEFF_2, STANDBY_TIME_0_5_MS, OVERSAMPLING_16X, OVERSAMPLING_2X, OVERSAMPLING_1X
2 Likes

Ah, that seems obvious in hindsight - I can confirm importing them worked.

Many thanks

1 Like