DS18b20 reads +30 degrees or so but only on ESP8266
Posted: Tue Jan 16, 2018 11:49 am
Odd Problem. Sensors are checked and work OK on pro mini. As soon as I port the solution to ESP8266 80 odd degrees instead of 25 C. Temp sampled every 2 mins. Itemp and otemp are floats, tmpo and tmpi char arrays [10]. Pullup is with a 3.3K resister, though anything around that seems to work ~1k to 5.6k. leads are very short, parasitic mode. exactly the same setup on 3.3v pro mini works 100%, with normal temperatures reported.
// DS18B20 temperature sensor setup
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
Any help or thoughts much appreciated.
Best regards
dataguy
//setup stuff
DS18B20.begin();
DS18B20.setResolution(10);// 0.25 degrees
DS18B20.setWaitForConversion(false);
DS18B20.requestTemperatures();
void gettemp(){
otmp = DS18B20.getTempCByIndex(0);
itmp = DS18B20.getTempCByIndex(1);
dtostrf(otmp,5,1,tmpo);
dtostrf(itmp,5,1,tmpi);
sprintf(str1,"Temperatures: in %sC, out %sC \n",tmpi,tmpo);
sprintf(dstr3,"In%sC Out%sC",tmpi,tmpo);
Serial.print("Temp #1 ");
Serial.print(otmp);
Serial.print("C, Temp #2 ");
Serial.print(itmp);
Serial.println("C");
DS18B20.requestTemperatures(); // for next time round
}
Result is :-
IP address: 192.168.1.13
Temp #1 81.00C, Temp #2 76.75C
HTTP server started
Temp #1 81.00C, Temp #2 76.75C
Any help or ideas much appreciated.
Best Regards
Dataguy
// DS18B20 temperature sensor setup
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
Any help or thoughts much appreciated.
Best regards
dataguy
//setup stuff
DS18B20.begin();
DS18B20.setResolution(10);// 0.25 degrees
DS18B20.setWaitForConversion(false);
DS18B20.requestTemperatures();
void gettemp(){
otmp = DS18B20.getTempCByIndex(0);
itmp = DS18B20.getTempCByIndex(1);
dtostrf(otmp,5,1,tmpo);
dtostrf(itmp,5,1,tmpi);
sprintf(str1,"Temperatures: in %sC, out %sC \n",tmpi,tmpo);
sprintf(dstr3,"In%sC Out%sC",tmpi,tmpo);
Serial.print("Temp #1 ");
Serial.print(otmp);
Serial.print("C, Temp #2 ");
Serial.print(itmp);
Serial.println("C");
DS18B20.requestTemperatures(); // for next time round
}
Result is :-
IP address: 192.168.1.13
Temp #1 81.00C, Temp #2 76.75C
HTTP server started
Temp #1 81.00C, Temp #2 76.75C
Any help or ideas much appreciated.
Best Regards
Dataguy