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?!

    0_1474473788932_image.jpg


  • 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.

    0_1474476662149_upload-55749161-dbba-4941-bbfe-c38322980283



  • @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...

    0_1474479958895_image.jpg



  • 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:

    0_1474539330333_Clipboard01.jpg

    /* 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_PARENT_NODE_IS_STATIC
    #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)
    #else
    #define DEBUG_SERIAL(x)
    #define DEBUG_PRINT(x) 
    #define DEBUG_PRINTLN(x) 
    #endif
    
    // #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 TEMP_TRANSMIT_THRESHOLD 0.5
    #define PRES_TRANSMIT_THRESHOLD 1.0
    #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_PRINT(readVcc()); 
      DEBUG_PRINTLN(" mV");
    /*
      delay(500);
      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!");
      
      raHum.clear();
      
    }
    
    void loop() { 
    
      measureCount ++;
      batteryReportCounter ++;
      bool forceTransmit = false;
      
      if (measureCount > FORCE_TRANSMIT_CYCLE) {
        forceTransmit = true; 
      }
      mySensor.begin();
      sendTempHumidityMeasurements(forceTransmit);
    /*
      // 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(" %");
        sendBatteryLevel(batteryPcnt);
        batteryReportCounter = 0;
      }
      
      sleep(SLEEP_TIME);
    //if(isTransportOK()){
    //    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 http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
    // 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 http://playground.arduino.cc/Main/InternalTemperatureSensor 
    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) {
        send(msgTemp.set(temperature,1));
        lastTemperature = temperature;
        measureCount = 0;
        DEBUG_PRINTLN("T sent!");
      }
      
      int humidity = mySensor.readFloatHumidity();
      DEBUG_PRINT("H: ");DEBUG_PRINTLN(humidity);
      raHum.addValue(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) {
        send(msgHum.set(humidity));
        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) {
        send(msgPres.set(pressure,1));
        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...

    Buuuuh.



  • 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?



  • @r-nox You mean too many readings per time unit?



  • That's my line of thought.



  • @r-nox Hm, it is reading every 15 seconds at the moment. Do you think this is too much?

    The current sensor is not completely broken, it seems. Sometimes it is showing "normal" values. I brought it into the house to test it, and in the house it seems to show normal values. I will know more tomorrow morning.

    According to its specs it is supposed to be good for weather monitoring. But then, it seems it does not like "weather" too much.

    I also found it strange that in the past 30 days the maximum humidity it read was 87 %. And for sure there were plenty of nights here with 100 %. But ok, I could live with that. But it has started to show far too low values for humidity, down to 0 %. I'll leave it in the house for 1-2 days and then see how it behaves outside.



  • I don't know the specs for reading it off hand. Perhaps your housing is holding humidity. I plan to add a fan to mine. Spin the fan for a few moments before reading to cycle the air.



  • So, this story also continues. After having these problems, I brought the sensor into the house and left it running for the past several weeks in the living room. Actually it is working fine. No more problems.

    Now, for Christmas, I have brought it back outside to the birdhouse. And it is still working fine, even at -10 °C. Let's see how long it will last this time.

    What I also noticed is that now I have a second of these in the greenhouse where the humidity is definitely from time to time 100%. At 4°C. But both outdoor sensors somehow never reach 100%, but stop somewhere between 85-90%. It seems they are not made to detect 100% humidity.



  • Now after 2-3 month more outside the sensor seems to be finally dead. No reaction anymore. Also the 2nd one in the greenhouse does not reply anymore. I'll have to check. The one in the living room is fine.

    It seems that at least the ones I bought are not really lasting long outdoors.



  • Time to try something else.



  • What about to use PTFE (teflon) tape to protect the sensor board, see this project. It seems, characteristics of the material (PTFE) enables it to use it for this purpose, it is mentioned also link text here



  • Interesting idea, the ptfe tape. I will try it with the next sensor!

    So, only the outdoor sensors fail. It is now more than one that failed.

    I have one in the living room -- perfect.

    And, very strange: I have one in the green house. Huge T differences, sometimes very hot, and often 100% humidity. Actually conditions should be worse for this sensor compared to the outdoor sensor. But: it is just fine.

    Weird.



  • @karl261 Do you happen to live near te sea? Because salty air wreaks havoc on anything sooner or later. Tiny electronics rather sooner...

    I have a BME280 outside and that's been running for over a year now. It's pretty well protected though, but it catches a few hours of direct sunlight per day.



  • Hi, no, I live rather far from the sea. I don't know what is killing the outdoor sensor. The same in the greenhouse survives much weirder temperatures and humidities.



  • @karl261 Any update on this topic?

    Are you still struggling with that your BME280s don't seem to last long time outdoors?



  • Anyway. My crappy BME280 clone that I bought on ebay for $8.98 (in December 2016) lasted only for 4 days.

    Now I will have to take down my weather station and repair it.

    I will now buy an original Adafruit BME280 for 289 SEK (32$) + postage. I hope that one will last.



  • @รอเร-อ

    I got 2x "BME280" from China today - they are not bosch sensors. If you are having problems, check carefully the markings with magnifying glass or microscope.

    This may be the problem.....??



  • @karl261 said in BME280 How to use it outdoors:

    Now after 2-3 month more outside the sensor seems to be finally dead.

    Quite old thread, but wanted to provide an update:
    I have a BME280 up and running since about 1 year now. It is in the weather station outside on the roof. It is vented very well but protected from direct exposure to sun, wind and rain. Readings are reliable. What I did is treating the whole board except the sensor chip with this:
    https://de.aliexpress.com/item/2pcs-lot-Genuine-Kafuter-k-705-RTV-Silicone-Rubber-Electronic-Glue-Sealant-Transparent-Organosilicon-45g/32649754904.html?spm=a2g0s.9042311.0.0.27424c4d0W1ssb


  • Hardware Contributor

    @parachutesj thank you for the link I never noticed those before.


Log in to reply
 

Suggested Topics

  • 87
  • 7
  • 6
  • 8
  • 3
  • 5

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts