BME280 How to use it outdoors

  • I've been playing around with the bme280 for a while. I like this sensor, it seems to be very accurate and it is easy to install.

    Now, one of them is running outdoors. It is in a plastic box, I made a little hole of 4 mm diameter in the box and placed the sensor behind the hole. I thought like this it is well protected. The sensor points north and it sits in an open bird house 2 m above ground. No rain should be able to reach the box and sensor.

    However, recently I brought it into the house and noticed that the humidity is off by 15 %. Too high compared to all other bme280 and other sensors I have.

    Could it have been damaged sitting outside?

    I tried to recondition the sensor like written in the specs, but the humidity value is still too high.

    That is bad news, because I cannot put a new bme280 every 3 weeks... That gets too expensive.

    So, what to do? The Bosch specs clearly say it's ideal for outdoor weather monitoring. That is great, but how do I prevent this thing from showing wrong values?.

    Or maybe it is just bad luck?

    What do you suggest?!


  • Hero Member

    @karl261 Is the photo upside down? It is probably bad luck but you you should take care that the box is well ventilated. Most commercial housings look like the one below. The ventilation makes sure that there is limited condensation. When a closed box (or one with only a small hole inside) cools down in high humidity there will likely be condensation which is not good for the sensor.

    So, my advice would be to dril some more holes and protect it agains rain. Also cover the holes with some fabric (i.e fiberglass) to protect it against insects.


  • @AWI No, it's standing on a table on the photo...

    Hm.... I did not find any moisture in the box. So you think I need plenty of more holes? Hm, the sensor was directly behind the hole. On the picture one cannot see the sensor.

    Rain normally cannot reach the box. But ok, I could think of something more special.

    The housing on your photo, where can you buy it?

    Another thing: if I protect the holes against insects, what would I use? Because I don't want to measure wet tissue or so. So it would be some synthetics. Or a fine mesh of something. But in this moment I have no idea...

    Thanks for the advice!

  • 0_1474479329532_image.jpg

  • @karl261

    You can use window screen from the hardware store.

  • @r-nox window screen? What is that? Do you have a link?

    Ah, now I know: these anti insect meshes, one puts in front of the window... They should be good...

    Now the box is full of 2 mm holes...


  • Your fine then.

    Window screen is a mesh material that doesn't absorb water. It is sometimes made from metal.

  • @r-nox ok, thanks. I try to google it. Somehow I can't picture the material.

    @AWI Maybe it has to do with the box. Hm. Because I had another node out there, same sensor, and it was just hanging in the bird house protected against rain. And it still works fine. Still, there was no sign of any moisture in the box...

  • @r-nox ok, thanks. It is exactly what I was talking about. Insect protection! 😃

  • Why are all my photos upside down? That's weird. They display right on the tablet, but on the PC in FireFox they are upside down...

  • By the way: This is the sketch I use. It is made for a 1 MHz Atmega328p. If anyone has some code suggestions... 🙂

    I use a board that looks like this:


    /* Sketch with Si7021 and battery monitoring.
    by m26872, 20151109 
    modified for BME280 by karl261 using Sparkfun library
    // Enable and select radio type attached
    // MIN, LOW, HIGH, MAX
    #define MY_RADIO_NRF24
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    #define MY_PARENT_NODE_ID 99
    #define MY_NODE_ID 6
    //#define MY_DEBUG
    #define MY_BAUD_RATE 9600
    #include <MySensors.h>  
    #include <Wire.h>  //This library allows you to communicate with I2C / TWI devices. 
    #include <SPI.h>
    #include <RunningAverage.h>
    #include <SparkFunBME280.h>
    //#define DEBUG   // local debug
    #ifdef DEBUG
    #define DEBUG_SERIAL(x) Serial.begin(x)
    #define DEBUG_PRINT(x) Serial.print(x)
    #define DEBUG_PRINTLN(x) Serial.println(x)
    #define DEBUG_SERIAL(x)
    #define DEBUG_PRINT(x) 
    #define DEBUG_PRINTLN(x) 
    // #define NODE_ID 132             // <<<<<<<<<<<<<<<<<<<<<<<<<<<   Enter Node_ID
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_PRES 2
    #define SLEEP_TIME 15000 // 15s for DEBUG
    //#define SLEEP_TIME 300000   // 5 min
    #define FORCE_TRANSMIT_CYCLE 36  // 5min*12=1/hour, 5min*36=1/3hour 
    #define BATTERY_REPORT_CYCLE 2880   // Once per 5min   =>   12*24*7 = 2016 (one report/week)
    #define VMIN 1900
    #define VMAX 3300
    #define HUMI_TRANSMIT_THRESHOLD 3.0  // THRESHOLD tells how much the value should have changed since last time it was transmitted.
    #define AVERAGES 2
    int batteryReportCounter = BATTERY_REPORT_CYCLE - 1;  // to make it report the first time.
    int measureCount = 0;
    float lastTemperature = -100;
    float lastPressure = -100;
    int lastHumidity = -100;
    RunningAverage raHum(AVERAGES);
    //SI7021 humiditySensor;
    BME280 mySensor;
    // MyMessage to controler
    MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP); // Initialize temperature message
    MyMessage msgHum(CHILD_ID_HUM,V_HUM);
    MyMessage msgPres(CHILD_ID_PRES,V_PRESSURE);
    void presentation()
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("OUTSIDE P&T&H", "1.2");
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_PRES, S_BARO);
      present(CHILD_ID_HUM, S_HUM);  
      DEBUG_PRINT("Node and "); DEBUG_PRINTLN("3 children presented.");
    void setup() {
      DEBUG_SERIAL(9600);    // <<<<<<<<<<<<<<<<<<<<<<<<<< Note BAUD_RATE in MySensors.h
      DEBUG_PRINTLN("Serial started");
      DEBUG_PRINT("Voltage: ");
      DEBUG_PRINTLN(" mV");
      DEBUG_PRINT("Internal temp: ");
      DEBUG_PRINT(GetInternalTemp()); // Probably not calibrated. Just to print something.
      DEBUG_PRINTLN(" *C");
      mySensor.settings.commInterface = I2C_MODE;
      mySensor.settings.I2CAddress = 0x77;
      //runMode can be:
      //  0, Sleep mode
      //  1 or 2, Forced mode
      //  3, Normal mode
      mySensor.settings.runMode = 1;
      mySensor.settings.filter = 0;
      mySensor.settings.tempOverSample = 1;
      mySensor.settings.pressOverSample = 1;
      mySensor.settings.humidOverSample = 1;
      delay(500); // Allow time for radio if power used as reset
      if (!mySensor.begin())
        Serial.println("BME init failed!");
        while (1);
      else Serial.println("BME init success!");
    void loop() { 
      measureCount ++;
      batteryReportCounter ++;
      bool forceTransmit = false;
      if (measureCount > FORCE_TRANSMIT_CYCLE) {
        forceTransmit = true; 
      // Read and print internal temp
      float temperature0 = static_cast<float>(static_cast<int>((GetInternalTemp()+0.5) * 10.)) / 10.;
      DEBUG_PRINT("Internal Temp: "); DEBUG_PRINT(temperature0); DEBUG_PRINTLN(" *C");        
      // Check battery
      if (batteryReportCounter >= BATTERY_REPORT_CYCLE) {
        long batteryVolt = readVcc();
        DEBUG_PRINT("Battery voltage: "); DEBUG_PRINT(batteryVolt); DEBUG_PRINTLN(" mV");
        uint8_t batteryPcnt = constrain(map(batteryVolt,VMIN,VMAX,0,100),0,255);   
        DEBUG_PRINT("Battery percent: "); DEBUG_PRINT(batteryPcnt); DEBUG_PRINTLN(" %");
        batteryReportCounter = 0;
    //    sleep(SLEEP_TIME);  // transport is OK, node can sleep
    //  } 
    //  else {
    //    wait(5000); // transport is not operational, allow the transport layer to fix this
    //  }
    // function for reading Vcc by reading 1.1V reference against AVcc. Based from
    // To calibrate reading replace 1125300L with scale_constant = internal1.1Ref * 1023 * 1000, where internal1.1Ref = 1.1 * Vcc1 (per voltmeter) / Vcc2 (per readVcc() function) 
    long readVcc() {
      // set the reference to Vcc and the measurement to the internal 1.1V reference
      ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      delay(2); // Wait for Vref to settle
      ADCSRA |= _BV(ADSC); // Start conversion
      while (bit_is_set(ADCSRA,ADSC)); // measuring
      uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
      uint8_t high = ADCH; // unlocks both
      long result = (high<<8) | low;
      result = 1178053L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
      //Node 6 = 1178053L
      return result; // Vcc in millivolts
    // function for reading internal temp. From 
    double GetInternalTemp(void) {  // (Both double and float are 4 byte in most arduino implementation)
      unsigned int wADC;
      double t;
      // The internal temperature has to be used with the internal reference of 1.1V. Channel 8 can not be selected with the analogRead function yet.
      ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));   // Set the internal reference and mux.
      ADCSRA |= _BV(ADEN);  // enable the ADC
      delay(20);            // wait for voltages to become stable.
      ADCSRA |= _BV(ADSC);  // Start the ADC
      while (bit_is_set(ADCSRA,ADSC));   // Detect end-of-conversion
      wADC = ADCW;   // Reading register "ADCW" takes care of how to read ADCL and ADCH.
      t = (wADC - 88.0 ) / 1.0;   // The default offset is 324.31.
      return (t);   // The returned temperature in degrees Celcius.
     * * Sends temperature and humidity from Si7021 sensor
     * Parameters
     * - force : Forces transmission of a value (even if it's the same as previous measurement)
    void sendTempHumidityMeasurements(bool force) {
      bool tx = force;
      float temperature = mySensor.readTempC();
      DEBUG_PRINT("T: ");DEBUG_PRINTLN(temperature);
      float diffTemp = abs(lastTemperature - temperature);
      DEBUG_PRINT(F("TempDiff :"));DEBUG_PRINTLN(diffTemp);
      if (diffTemp > TEMP_TRANSMIT_THRESHOLD || tx) {
        lastTemperature = temperature;
        measureCount = 0;
        DEBUG_PRINTLN("T sent!");
      int humidity = mySensor.readFloatHumidity();
      DEBUG_PRINT("H: ");DEBUG_PRINTLN(humidity);
      humidity = raHum.getAverage();  // MA sample imply reasonable fast sample frequency
      float diffHum = abs(lastHumidity - humidity);  
      DEBUG_PRINT(F("HumDiff  :"));DEBUG_PRINTLN(diffHum); 
      if (diffHum > HUMI_TRANSMIT_THRESHOLD || tx) {
        lastHumidity = humidity;
        measureCount = 0;
        DEBUG_PRINTLN("H sent!");
      float pressure = mySensor.readFloatPressure()/100.0;
      DEBUG_PRINT("P: ");DEBUG_PRINTLN(pressure);
      float diffPress = abs(lastPressure - pressure);
      DEBUG_PRINT(F("PressDiff :"));DEBUG_PRINTLN(diffPress);
      if (diffPress > PRES_TRANSMIT_THRESHOLD || tx) {
        lastPressure = pressure;
        measureCount = 0;
        DEBUG_PRINTLN("P sent!");

  • Well, I guess then I will change the BME280 to a new one and see how it goes. Let's see how long it lasts. If it is made for weather monitoring, it should withstand normal weather conditions if not exposed to rain???

  • Ok, I changed the BME280. Now it is better.

    I like this sensor, I have right now 3 of them running next to each other:

    T    20.8        21.2       21.1
    H    60%         60%        60%
    P    1015.3      1015.0     1014.9

    Isn't that great? Now let's see how long the outdoor sensor lasts. I don't know what else to improve...

  • @karl261 hopefully a longer time.

  • It does not look that it was much longer time. But instead like the sensor before, the current one is now showing values between 0-22% humidity. T seems to be fine. That is SO disappointing. It seems that these things are not suitable for outdoor use. Lasted only a month...


  • Seems short lived...

  • Hardware Contributor

    😞 Sounds bad 😞
    Next step for you is to try with a SHT21 with the protective film it might get a better chance than the BME280...

  • @r-nox Somehow, doesn't it? A bit too short for my taste. It should not see any rain, I wonder what is killing it. Or, how I can protect it even better.

    @Nca78 I had a SI7021 with protective foil before, but it was not very accurate. Actually it was quite far off, that's why I started to look for something more accurate.

    When I look around online there seems to be some connection/confusion with the SI7021 and SHT21. But I did not really understand it. Does anybody know more about it?

    EDIT: Hm, seems to be two different sensors, but the board is always the same. So I would need to check to really get a SHT21 and with a protective cover...

    EDIT2: I do not seem to find any SHT21 with protective cover...

  • Are you over working it? Is that even possible?

Log in to reply





Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.