//--------------------------------------------------------------------- void loop() { // comming from wake-up? //pinMode(DALLAS_SENSOR_PIN, OUTPUT); LaCrosse.setTxPinMode(OUTPUT); power_adc_enable(); delay(500); // ms, needed for settling DS18B20 //--- [0] Betriebsspannung auslesen lngVcc = getVcc(); // as long controller_VCC = (lngVcc/1000.0); // as float in Volt, not millivolts (sent as HUM ! //--- [2] read Dallas-Sensor float theta = ReadSingleOneWireSensor(dallas); #ifdef USE_SOFT_SERIAL_FOR_DEBUG //--- debug-output-block //softSerial.print("Vcc: "); //softSerial.print( (float) controller_VCC, 1); //softSerial.print(" Vcc_read: "); //softSerial.print((long) lngVcc); //softSerial.print(" "); softSerial.print("Feuchte: "); softSerial.print( (float) bodenfeuchte, 1); softSerial.print(" "); softSerial.print("Temp: "); softSerial.println( (float) theta, 1); #endif //--- transfer measured values to LaCrosse-instance LaCrosse.bSensorId = SENSOR_ID; LaCrosse.t = theta; //--- alias temperature; LaCrosse.sendTemperature(); LaCrosse.sleep(1); /* 1 second, no power-reduction! */ #ifdef USE_SEPARATE_BATTERIE_ID LaCrosse.bSensorId = SENSORID_BATTERIE; #endif //LaCrosse.h = bodenfeuchte/1000; // controller_VCC; //LaCrosse.sendHumidity(); //LaCrosse.sleep(1); /* 1 second, no power-reduction! */ //--- preserve more power during sleep phase pinMode(DALLAS_SENSOR_PIN, INPUT); LaCrosse.setTxPinMode(INPUT); //--- switch AD-converter off power_adc_disable(); //--- fall to deep powersave-sleep, see notes in comments and Narcoleptic.delay_minutes(DEEP_SLEEP_MINUTES); //--- deep sleep or test? //delay(10000); // 10 Sec }
void SCKAmbient::updateSensors(byte mode) { boolean ok_read = false; byte retry = 0; #if F_CPU == 8000000 getSHT21(); ok_read = true; #else base_.timer1Stop(); while ((!ok_read)&&(retry<5)) { ok_read = getDHT22(); retry++; if (!ok_read)delay(3000); } base_.timer1Initialize(); #endif if (((millis()-timeMICS)<=6*minute)||(mode!=ECONOMIC)) //6 minutes { #if F_CPU == 8000000 getVcc(); #endif getMICS(); value[5] = getCO(); //ppm value[6] = getNO2(); //ppm } else if((millis()-timeMICS)>=60*minute) { GasSensor(true); timeMICS = millis(); } else { GasSensor(false); } if (ok_read ) { #if ((decouplerComp)&&(F_CPU > 8000000 )) uint16_t battery = base_.getBattery(Vcc); decoupler.update(battery); value[0] = getTemperature() - (int) decoupler.getCompensation(); #else value[0] = getTemperature(); #endif value[1] = getHumidity(); } else { value[0] = 0; // ºC value[1] = 0; // % } value[2] = getLight(); //mV value[3] = base_.getBattery(Vcc); //% value[4] = base_.getPanel(Vcc); // % value[7] = getNoise(); //mV if (mode == NOWIFI) { value[8] = 0; //Wifi Nets base_.RTCtime(time); } else if (mode == OFFLINE) { value[8] = base_.scan(); //Wifi Nets base_.RTCtime(time); } }