X-Git-Url: http://git.smho.de/gw/?p=owSlave2.git;a=blobdiff_plain;f=DS18B20_BMP280_DS2438_SHT%2FDS18B20_DS2438.c;fp=DS18B20_BMP280_DS2438_SHT%2FDS18B20_DS2438.c;h=d8b04bd8f6008a4ac23d8fe12df1779950428cdf;hp=b4b62d0dd2c0c96434d0ff403182036e7e87a3b1;hb=cd92472e6fd63693741f8e168123a4182802651b;hpb=0f5b4d994ac87afdd294f6fc79692bcf92e337de diff --git a/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c index b4b62d0..d8b04bd 100644 --- a/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c +++ b/DS18B20_BMP280_DS2438_SHT/DS18B20_DS2438.c @@ -40,7 +40,7 @@ #include "../common/I2C/USI_TWI_Master.h" #include "../common/I2C/SHT2x.h" #include "../common/I2C/BMP280.h" - +#include "../common/calibr.h" extern void OWINIT(); extern void EXTERN_SLEEP(); @@ -64,8 +64,9 @@ volatile uint8_t wdcounter=3; #if defined(__AVR_ATtiny24__)||defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny24A__)||defined(__AVR_ATtiny44A__) || defined(__AVR_ATtiny84A__) ISR(WATCHDOG_vect) { -#else -ISR(WDT_vect) { + #else + ISR(WDT_vect) { + #endif //sleep_disable(); // Disable Sleep on Wakeup wdcounter++; @@ -180,7 +181,7 @@ int main(void){ ACSR|=(1<3) { + + } + + if (wdcounter>2) { SHT2x_MeasurePoll(HUMIDITY, &sRH); // --- measure temperature with "Polling Mode" (no hold master) --- SHT2x_MeasurePoll(TEMP, &sT); //-- calculate humidity and temperature -- - temperatureC = SHT2x_CalcTemperatureC(sT)*10.0; - humidityRH = SHT2x_CalcRH(sRH)*10.0; - double hhum=(1.0546-0.000216*temperatureC)*(humidityRH); - am2302_hum=0.318*hhum +76.0; - am2302_temp=temperatureC*25.6; + temperatureC = SHT2x_CalcTemperatureC(sT); + humidityRH = SHT2x_CalcRH(sRH); + humidityRH=calibr_hum(temperatureC,-0.45,humidityRH)*10.0; + temperatureC=temperatureC*10.0-4.5; + if (testSW()) { + am2302_hum= humidityRH*10.0; + am2302_temp=temperatureC*25.6; + am2302_temp=am2302_temp-20; + config_info2[5]=8; + + }else{ + + double hhum=(1.0546-0.000216*temperatureC)*(humidityRH); + //am2302_hum=0.318*hhum +76.0; + am2302_hum=0.31*hhum +80; + am2302_temp=temperatureC*25.6; + am2302_temp=am2302_temp-20; + config_info2[5]=7; + } wdcounter=0; } @@ -243,9 +259,13 @@ int main(void){ //pack.temp++; alarmflag=af; sei(); + gcontrol=0; EXTERN_SLEEP(); } - + if (gcontrol) { + gcontrol=0; + + } #if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)