1W Temperature Sensor 18s20 shows old values


  • Contest Winner

    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".

    1. TempSensor is at 20°C and reports 20°C
    2. I'm heating up the Sensor to e.g. 60°
    3. I reqeust the temperature, it tells me 20°C (although it is 60)
    4. I request temperature again, now its 60°C
    5. I wait for temp on sensor to settle back at 20°C
    6. I request temperature it tells me 60°C (altough it is 20)
    7. I request temperature again, it tells me 20°C

    Is anyone able to help me, please
    Thanks so much
    Dirk H.


  • Contest Winner

    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.


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.