Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. BME280 How to use it outdoors

BME280 How to use it outdoors

Scheduled Pinned Locked Moved Hardware
36 Posts 9 Posters 29.6k Views 10 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R r-nox

    Here's a link

    http://www.affordablewindowscreens.com/products/custom-window-screens.html?page=shop.product_details&flypage=vmj_naru.tpl&product_id=40&category_id=1

    karl261K Offline
    karl261K Offline
    karl261
    wrote on last edited by
    #10

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

    1 Reply Last reply
    0
    • karl261K Offline
      karl261K Offline
      karl261
      wrote on last edited by
      #11

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

      1 Reply Last reply
      0
      • karl261K Offline
        karl261K Offline
        karl261
        wrote on last edited by
        #12

        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!");
          }
        
        }
        
        1 Reply Last reply
        0
        • karl261K Offline
          karl261K Offline
          karl261
          wrote on last edited by
          #13

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

          1 Reply Last reply
          0
          • karl261K Offline
            karl261K Offline
            karl261
            wrote on last edited by karl261
            #14

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

            R 1 Reply Last reply
            0
            • karl261K karl261

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

              R Offline
              R Offline
              r-nox
              wrote on last edited by
              #15

              @karl261 hopefully a longer time.

              1 Reply Last reply
              0
              • karl261K Offline
                karl261K Offline
                karl261
                wrote on last edited by
                #16

                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.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  r-nox
                  wrote on last edited by
                  #17

                  Seems short lived...

                  1 Reply Last reply
                  0
                  • Nca78N Offline
                    Nca78N Offline
                    Nca78
                    Hardware Contributor
                    wrote on last edited by
                    #18

                    :( 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...

                    1 Reply Last reply
                    0
                    • karl261K Offline
                      karl261K Offline
                      karl261
                      wrote on last edited by karl261
                      #19

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

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        r-nox
                        wrote on last edited by
                        #20

                        Are you over working it? Is that even possible?

                        karl261K 1 Reply Last reply
                        0
                        • R r-nox

                          Are you over working it? Is that even possible?

                          karl261K Offline
                          karl261K Offline
                          karl261
                          wrote on last edited by
                          #21

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

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            r-nox
                            wrote on last edited by
                            #22

                            That's my line of thought.

                            karl261K 1 Reply Last reply
                            0
                            • R r-nox

                              That's my line of thought.

                              karl261K Offline
                              karl261K Offline
                              karl261
                              wrote on last edited by
                              #23

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

                              1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                r-nox
                                wrote on last edited by
                                #24

                                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.

                                1 Reply Last reply
                                0
                                • karl261K Offline
                                  karl261K Offline
                                  karl261
                                  wrote on last edited by
                                  #25

                                  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.

                                  1 Reply Last reply
                                  0
                                  • karl261K Offline
                                    karl261K Offline
                                    karl261
                                    wrote on last edited by
                                    #26

                                    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.

                                    parachutesjP 1 Reply Last reply
                                    0
                                    • R Offline
                                      R Offline
                                      r-nox
                                      wrote on last edited by
                                      #27

                                      Time to try something else.

                                      1 Reply Last reply
                                      0
                                      • ferroF Offline
                                        ferroF Offline
                                        ferro
                                        wrote on last edited by
                                        #28

                                        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

                                        1 Reply Last reply
                                        1
                                        • karl261K Offline
                                          karl261K Offline
                                          karl261
                                          wrote on last edited by karl261
                                          #29

                                          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.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          19

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular