1W Temperature Sensor 18s20 shows old values
-
Hello everybody,
I'm trying to transmit temperatures from 1Wire 18S20 Sensors via MySensors. However MySensors just works fine, but I always get old Data from the 18S20 Sensors using onewire and DallasTemperature libs.
I Transmit and get the temps in the following manner
TempSns.requestTemperatures(); gw.wait(750); for (i=0; i<j; i++) { uint8_t Adr[8]; temperature = TempSns.getTempCByIndex(i); Serial.println(temperature); gw.send(TempVals[i]->set(temperature,1)); }
However when I use a lighter to heaten up the Temperature Sensor I first get the old value. I have to request a second sample to get the "real value".
- TempSensor is at 20°C and reports 20°C
- I'm heating up the Sensor to e.g. 60°
- I reqeust the temperature, it tells me 20°C (although it is 60)
- I request temperature again, now its 60°C
- I wait for temp on sensor to settle back at 20°C
- I request temperature it tells me 60°C (altough it is 20)
- I request temperature again, it tells me 20°C
Is anyone able to help me, please
Thanks so much
Dirk H.
-
Ok, finally I found the Problem.
I changed the prescaler value of Timer0 becuase I needed a higher PWM Frequenciy.Unfortuneatly this also affects the millis() function that is used in gw.wait.
It turns out taht with the changed TImer 0 Prescaler 1ms was not 1ms anymore but less. So the gw.wait(750) where only 750ms/64 which is not enough for DS18S20 conversion to take place.