Skip to main content

Module sim

Module sim 

Source
Expand description

A BME280 that is not there.

Standing a part up to run a driver against used to mean writing out its side of the conversation: the chip id, two calibration blocks, a status register, and eight burst bytes, as literals, in the order the datasheet lists them. That is a lot of bytes to get right before a driver has been run once, and it is the same bytes every time.

This is that part, already answering. part hands back something a Bme280 can be pointed at, holding a real calibration and a reading. reporting builds one that reads whatever you ask it for, by working out the raw values the compensation turns back into that reading.

The calibration here was read from a real BME280, and BURST is one measurement that part took. Together they compensate to 20.44 C, 848.05 hPa, and 44.65 %.

Constants§

BURST
One measurement that part took, as the eight data registers hold it.
CALIBRATION
The temperature and pressure calibration a real BME280 holds.
CALIBRATION_HUMIDITY
The humidity calibration that goes with it.
STATUS_IDLE
The status a part reports when it is neither measuring nor loading its calibration.

Functions§

burst_for
The eight data registers that compensate to a reading.
calibration
The calibration these registers decode to.
part
A BME280 answering at an address, holding a real calibration and one measurement.
registers_of
The eight data registers a raw measurement sits in.
reporting
A BME280 that reads what you ask it to.