How frequently should I read the BME280 sensor?

I'm a beginner trying to go further than the example sketches in the Adafruit library (which I was able to run correctly).

I would like my device (placed outside), to send me readings every 30min, as well as to Thingspeak. I've read the datasheet for the sensor, particularly the different sampling modes, and I'm not sure if I need to keep updating the values from the sensor continuously in the loop() function.

float temp, hum, pres;

setup(){
// get things ready, etc
}

loop(){
temp = bmp.readTemperature();
temp = bmp.readTHumidity();
pres = bmp.readPressure() / 100;
 
if (30minHavePassed){
sendToMe();
sendToThingspeak();
}

Or otherwise only call the functions and read the sensor when 30min have passed:

float temp, hum, pres;

setup(){
// get things ready, etc
}

loop(){
if (30minHavePassed){
readings();
sendToMe();
sendToThingspeak();
}

readings(){
temp = bmp.readTemperature();
temp = bmp.readTHumidity();
pres = bmp.readPressure() / 100;
}

There's no need to read data you don't use or save. Alternatively, you could choose to do averaging or trending, allowing for things like sending the most recent reading with a marker for 'rising' vs 'falling'. This is beyond your stated simple implementation, but is a logical extension.

2 Likes

The sensor should be read every 60 seconds when in Forced mode, according to the datasheet and Adafruit library

https://www.esp8266.com/viewtopic.php?f=13&t=8030&start=28

    // weather monitoring
    Serial.println("-- Weather Station Scenario --");
    Serial.println("forced mode, 1x temperature / 1x humidity / 1x pressure oversampling,");
    Serial.println("filter off");
    bme.setSampling(Adafruit_BME280::MODE_FORCED,
                    Adafruit_BME280::SAMPLING_X1, // temperature
                    Adafruit_BME280::SAMPLING_X1, // pressure
                    Adafruit_BME280::SAMPLING_X1, // humidity
                    Adafruit_BME280::FILTER_OFF   );
                      
    // suggested rate is 1/60Hz (1m)
    delayTime = 60000; // in milliseconds```

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.