BME280 How to use it outdoors
-
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...
-
-
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_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!"); } } -
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.9Isn't that great? Now let's see how long the outdoor sensor lasts. I don't know what else to improve...
-
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.9Isn't that great? Now let's see how long the outdoor sensor lasts. I don't know what else to improve...
-
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.
-
:( 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...
-
@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.

