- New Device compinations
[owSlave2.git] / DS18B20_VOC_DS2438_SHT / DS18B20_DS2438.c
index d455f89..5a0094e 100644 (file)
@@ -190,6 +190,7 @@ uint8_t cmode=0;
 double R0=0;
 int16_t hr;
 uint8_t startup=5;
+uint8_t reset_R0=0;
 
 int main(void){
     PRR|=(1<<PRADC);  // adc for save Power
@@ -261,9 +262,32 @@ int main(void){
        sei();
        //DDRB|=(1<<PINB1);
     while(1)   {
+               if (pack1.config==0x1F) {
+                       if (reset_R0==0) {
+                               reset_R0=1;
+                               pack1.config=0x7F;
+                               R0=0;
+                               hr=R0*100;
+                               pack2.page3[0]=hr&0xFF;
+                               pack2.page3[1]=(hr>>8)&0xFF;
+                               
+                               while(EECR & (1<<EEPE));
+                               EECR = (0<<EEPM1)|(0<<EEPM0);
+                               EEARL = 0;
+                               EEDR = hr&0xFF;
+                               EECR |= (1<<EEMPE);
+                               EECR |= (1<<EEPE);
+                               while(EECR & (1<<EEPE));
+                               EECR = (0<<EEPM1)|(0<<EEPM0);
+                               EEARL = 1;
+                               EEDR = hr>>8;
+                               EECR |= (1<<EEMPE);
+                               EECR |= (1<<EEPE);
+
+                       }
+               } else reset_R0=0;                      //PORTB|=(1<<PINB1); //Dauer 440ms
                if (wdcounter>0) {
                        if (startup!=0) startup--;
-                       //PORTB|=(1<<PINB1); //Dauer 440ms
                        SHT2x_MeasurePoll(HUMIDITY, &sRH);
                        // --- measure temperature with "Polling Mode" (no hold master) ---
                        SHT2x_MeasurePoll(TEMP, &sT);
@@ -310,7 +334,8 @@ int main(void){
                        pack2.page3[6]=(hr>>8)&0xFF;
                        
                        l=l/ip;
-                       if (startup!=0){
+                       
+                       if (startup==0){
                        if (l>R0) {
                                R0=l;
                                hr=R0*100;
@@ -334,7 +359,7 @@ int main(void){
                        }
                         l=l/R0;
                        l=log(1/l);
-                       l=l*160; //fuer DS18B20
+                       l=l*160*4; //fuer DS18B20
                        wdcounter=0;
                        
                }