pimoroni-pico/micropython/modules/breakout_bme280
Phil Howard 6a3ba0d421 MicroPython: Shim MP_REGISTER_MODULE for >1.18 compat.
MicroPython has changed MP_REGISTER_MODULE to use only *two* args and now runs the preprocessing stage on files before running makemoduledefs.py.

This change avoids the build exploding, since the new regex matches the last two args as a single argument and generates a malformed module defs include.

The pattern here exploits the fact that 1.18 and below do not preprocess files, so *both* MP_REGISTER_MODULE lines are included in the source, but *only* the three arg version is matched by regex.

In >1.18 the files will be processed and the three arg version removed before makemoduledefs.py processes it.
2022-06-14 12:08:47 +01:00
..
README.md Add documentation and features to BMx280 modules 2021-08-02 14:21:00 +01:00
breakout_bme280.c MicroPython: Shim MP_REGISTER_MODULE for >1.18 compat. 2022-06-14 12:08:47 +01:00
breakout_bme280.cpp MicroPython: Drop redundant Print. Saves 4K. 2022-06-13 18:59:51 +01:00
breakout_bme280.h MicroPython: Drop redundant Print. Saves 4K. 2022-06-13 18:59:51 +01:00
micropython.cmake Add MicroPython bindings for BME280 and BMP280 2021-08-02 14:20:59 +01:00
micropython.mk Add MicroPython bindings for BME280 and BMP280 2021-08-02 14:20:59 +01:00

README.md

BME280

Getting Started

Construct new PimoroniI2C and BreakoutBME280 instances:

from breakout_bme280 import BreakoutBME280
from pimoroni_i2c import PimoroniI2C

PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}

i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
bme = BreakoutBME280(i2c)

Reading Temperature, Pressure & Humidity

The read method will return a tuple containing Temperature (degrees C), Pressure (Pa) and Humidity (RH %) values:

temperature, pressure, humidity = bme.read()

Configuring The Sensor

The configure method allows you to set up the oversampling, filtering and operation mode.

bmp.configure(filter, standby_time, os_pressure, os_humidity, os_temp, mode)

The breakout_bme280 module includes constants for these:

Filter Settings

  • FILTER_COEFF_OFF
  • FILTER_COEFF_2
  • FILTER_COEFF_4
  • FILTER_COEFF_8
  • FILTER_COEFF_16

Oversampling Settings

  • NO_OVERSAMPLING
  • OVERSAMPLING_1X
  • OVERSAMPLING_2X
  • OVERSAMPLING_4X
  • OVERSAMPLING_8X
  • OVERSAMPLING_16X

Mode Settings

  • SLEEP_MODE
  • FORCED_MODE
  • NORMAL_MODE

Standby/Output Data Rate Settings

  • STANDBY_TIME_0_5_MS
  • STANDBY_TIME_62_5_MS
  • STANDBY_TIME_125_MS
  • STANDBY_TIME_250_MS
  • STANDBY_TIME_500_MS
  • STANDBY_TIME_1000_MS
  • STANDBY_TIME_2000_MS
  • STANDBY_TIME_4000_MS

Defaults

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