BME280Data
is a structure which contains the result of BME280.readAll(data)
where data
is a BME280Data
object.
If you want to read the temperature
load('api_timer.js');
load('api_bme280.js');
// https://github.com/mongoose-os-libs/bme280/blob/4f17b96aa8153c5eb07583dcd0ee669fc4234134/mjs_fs/api_bme280.js#L59-L66
let myBME = BME280.createI2C(0x76); // Have to check the datasheeet of your sensor. Might be 0x76 or 0x77
Timer.set(10000, Timer.REPEAT, function () {
print('Temperature: ', myBME.readTemp()); // https://github.com/mongoose-os-libs/bme280/blob/4f17b96aa8153c5eb07583dcd0ee669fc4234134/mjs_fs/api_bme280.js#L93-L98
}, null);
To read temperature, humidity and pressure:
load('api_timer.js');
load('api_bme280.js');
// https://github.com/mongoose-os-libs/bme280/blob/4f17b96aa8153c5eb07583dcd0ee669fc4234134/mjs_fs/api_bme280.js#L59-L66
let myBME = BME280.createI2C(0x76);
let myBMEData=BME280Data.create(); // create the data object
Timer.set(10000 , Timer.REPEAT, function () {
myBME.readAll(myBMEData); // https://github.com/mongoose-os-libs/bme280/blob/4f17b96aa8153c5eb07583dcd0ee669fc4234134/mjs_fs/api_bme280.js#L86-L91
print('Temperature:', myBMEData.temp(), 'Humidity:', myBMEData.humid(), 'Pressure:', myBMEData.press());
}, null);