This module provides a simple interface to [BME280/BMP280 temperature/air presssure/humidity sensors](http://www.bosch-sensortec.com/bst/products/all_products/bme280) (Bosch Sensortec).
Note that you must call [`setup()`](#bme280setup) before you can start reading values! Furthermore, there has to be a variable delay between some tens to hundreds of milliseconds between `setup()` and reading measurements. Instead of using a fixed delay you might also poll the sensor until data is delivered e.g. `humi()` not returning `nil` anymore.
Reads the sensor and returns the air pressure in hectopascals as an integer multiplied with 1000 or `nil` when readout is not successful.
Current temperature is needed to calculate the air pressure so temperature reading is performed prior reading pressure data. Second returned variable is therefore current air temperature.
Reads the sensor and returns the air relative humidity in percents as an integer multiplied with 100 or `nil` when readout is not successful.
Current temperature is needed to calculate the relative humidity so temperature reading is performed prior reading pressure data. Second returned variable is therefore current temperature.
#### Syntax
`bme280.humi()`
#### Parameters
none
#### Returns
-`H` last relative humidity reading in % times 1000
-`T` temperature in celsius as an integer multiplied with 100
For given altitude converts the air pressure to sea level air pressure.
#### Syntax
`bme280.qfe2qnh(P, altitude)`
#### Parameters
-`P` measured pressure
-`altitude` altitude in meters of measurement point
#### Returns
sea level pressure
## bme280.read()
Reads the sensor and returns the temperature, the air pressure, the air relative humidity and
#### Syntax
`bme280.read([altitude])`
#### Parameters
- (optional) `altitude`- altitude in meters of measurement point. If provided also the air pressure converted to sea level air pressure is returned.
#### Returns
-`T` temperature in celsius as an integer multiplied with 100
-`P` air pressure in hectopascals multiplied by 1000
-`H` relative humidity in percent multiplied by 1000
-`QNH` air pressure in hectopascals multiplied by 1000 converted to sea level
Any of these variables is `nil` if the readout of given measure was not successful.
## bme280.startreadout()
Starts readout (turns the sensor into forced mode). After the readout the sensor turns to sleep mode.
#### Syntax
`bme280.startreadout(delay, callback)`
#### Parameters
-`delay` sets sensor to forced mode and calls the `callback` (if provided) after given number of milliseconds. For 0 the default delay is set to 113ms (sufficient time to perform reading for oversampling settings 16x). For different oversampling setting please refer to [BME280 Final Datasheet - Appendix B: Measurement time and current calculation](http://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280_DS001-11.pdf#page=51).
-`callback` if provided it will be invoked after given `delay`. The sensor reading should be finalized by then so.
#### Returns
`nil`
## bme280.setup()
Initializes module. Initialization is mandatory before read values.
- (optional) `cold_start` - If 0 then the BME280 chip is not initialised. Usefull in a battery operated setup when the ESP deep sleeps and on wakeup needs to initialise the driver (the module) but not the chip itself. The chip was kept powered (sleeping too) and is holding the latest reading that should be fetched quickly before another reading starts (`bme280.startreadout()`). By default the chip is initialised.
Using forced mode is recommended for applications which require low sampling rate or hostbased synchronization. The sensor enters into sleep mode after a forced readout. Please refer to BME280 Final Datasheet for more details.