X-Git-Url: https://git.smho.de/gw/?p=owSlave2.git;a=blobdiff_plain;f=DS18B20_MAX44009_DS2438_SHT%2FDS18B20_DS2438.c;h=efd045489d23f26c2787ff7602c1c110e2f692ca;hp=4e8d28bce9d183579f43cecb1b9d2a697ec90685;hb=refs%2Fheads%2Fmaster;hpb=6467d8138460abffd9ddabc7b0a9f00c764af19c diff --git a/DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c b/DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c index 4e8d28b..efd0454 100644 --- a/DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c +++ b/DS18B20_MAX44009_DS2438_SHT/DS18B20_DS2438.c @@ -40,69 +40,21 @@ #include #include "../common/I2C/USI_TWI_Master.h" #include "../common/I2C/MAX44009.h" -#include "../common/I2C/SHT2x.h" +#include "../common/I2C/SHT2xV2.h" +#include "../common/calibr.h" +#include "../common/owSlave_tools.h" -extern void OWINIT(); -extern void EXTERN_SLEEP(); - +OWST_EXTERN_VARS uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/ uint8_t owid2[8]={0x26, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x67};/**/ uint8_t config_info1[26]={0x03,0x04, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x02,15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; uint8_t config_info2[26]={0x01,0x06, 0x05,0x08, 0x04,0x07, 0x00,0x00, 0x02,7,0x00,7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - - -#if (owid>128) -#error "Variable not correct" -#endif - -extern uint8_t mode; -extern uint8_t gcontrol; -extern uint8_t reset_indicator; -extern uint8_t alarmflag; -volatile uint8_t wdcounter=5; - - -#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) { -#endif - //sleep_disable(); // Disable Sleep on Wakeup - wdcounter++; - if (reset_indicator==1) reset_indicator++; - else if (reset_indicator==2) mode=0; -/* if (timeout==2) { - DIS_TIMER; - EN_OWINT; - mode=OWM_SLEEP; - } - timeout++;*/ - //sleep_enable(); // Enable Sleep Mode - -} - -int testSW(void) { - uint8_t r; - DDRB&=~(1<2) { - //PORTB|=(1<1000) humidityRH=1000; - if (testSW()) { - am2302_hum= humidityRH*10.0; - am2302_temp=temperatureC*25.6; - // - 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-45; - config_info2[5]=7; + getSHT2xHumTemp(&temperatureC,&humidityRH); + double RH=calibr_hum(temperatureC,-0.2,humidityRH)*10.0; + double TC =temperatureC *10.0-2; + + if (testSW()) { + DS2438_2_VAD=RH; + DS2438_2_TEMP=TC*25.6; + //am2302_temp=am2302_temp-20; + config_info2[5]=12; + DS2438_2_VDD=0x01F4; + + }else{ + + double hhum=(1.0546-0.000216*TC)*(RH); + //am2302_hum=0.318*hhum +76.0; + DS2438_2_VAD=0.31*hhum +80; + DS2438_2_TEMP=TC*25.6; + //am2302_temp=am2302_temp-20; + config_info2[5]=7; + DS2438_2_VDD=0x01F4; } wdcounter=0; } @@ -258,24 +186,7 @@ int main(void){ sei(); EXTERN_SLEEP(); } - - - -#if defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) - if (((TIMSK & (1<