DS18B20 reading
Posted: Wed Apr 27, 2016 2:49 pm
Hi,
When reading more sensors in basic program and only one sensor (or no sensor) is connected basic show readings from other sensor
when You connect only one sensor you get same temperature on curr, curs, curt variable
so i made simple change (maybe this is bad change but it works for me)
I also add next parametr which set resolution of DS18B20 reading. For this You must declare variable tempDeviceAddress with
When reading more sensors in basic program and only one sensor (or no sensor) is connected basic show readings from other sensor
Code: Select all
temp 0 curr
temp 1 curs
temp 2 curt
when You connect only one sensor you get same temperature on curr, curs, curt variable
so i made simple change (maybe this is bad change but it works for me)
Code: Select all
if ( Param0 == "temp" | Param0 == "ti")
{
valParam1 = GetMeThatVar(Param1).toInt();
valParam3 = GetMeThatVar(Param3).toInt();
if(sensors.getAddress(tempDeviceAddress, valParam1)) {
if( valParam3 >= 9 && valParam3 <= 12 ) {
sensors.setResolution(tempDeviceAddress, valParam3);
}
sensors.requestTemperatures();
SetMeThatVar(Param2, String(sensors.getTempC(tempDeviceAddress)));
}
else
{
SetMeThatVar(Param2, String(F("No sensor")));
}
return;
}
I also add next parametr which set resolution of DS18B20 reading. For this You must declare variable tempDeviceAddress with
Code: Select all
DeviceAddress tempDeviceAddress;