This is an I2C driver for the Bosch BME280 temperature / humidity / pressure sensor. The SPI mode of this chip is not supported.
The default initialization using
bme-init puts the chip into
continuous conversion mode, which means that it can be read anytime using
bme-data. For low-power operation,
bme-init-sleep may be used instead
to leave the chip in sleep mode and set-up for one-shot conversions using
bme-calib must be called once after
to load the chip-specific calibration values.
: bme-init ( -- nak ) \ init the bme280 into continuous mode : bme-init-sleep ( -- nak ) \ init the bme280 into sleep mode : bme-calib ( -- )
To read the last conversion values call
bme-data and then
bme-calc. The humidity is returned in 1/100th percent of relative
humidity, the pressure is returned in Pascal, and the temperature is
returned in 1/100th degrees celsius.
: bme-data ( -- ) \ get a sensor reading from the BME280 : bme-calc ( -- h p t ) \ convert reading to calibrated values
bme-convert performs a one-shot conversion and returns the chip to
sleep mode. It returns the number of milliseconds to wait before the
data can be retrieved.
bme-sleep forces the chip to sleep mode. Use
of the init words to wake it up again.
: bme-convert ( -- ms ) \ perform a one-shot forced reading, return ms before data is ready : bme-sleep ( -- ) \ force bme280 to sleep
32 buffer: params \ calibration data
BME.ADDR constant can be defined before including this driver, to
override the default I2C address of $76.
bme-init . bme-calib params 32 dump bme-data bme-calc . . .