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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login