Troubleshoot temperature reader DS18b20

Hi community, a pseudo newbie here. I developed a projects based on WemosMiniD2 that reads temperature (Ds18b20 reader), and controls an actuator to open/closes a greenhouse door and also turns on a PTC heater when very cold. It also sends update to ThingsSpeak. Problem is that a lot of the temperature updates show error. I've checked connections, they look good. Is there anything on the code that is not giving enough time? I have a 3 times try handlers, but still in many instances it doesn't record. It's in the measureTemperature() function. Image shows how much of the time temperature doesn't record (NAN)....

Please help!

Greenhouse_WemosD1_Mini_ds18b20_ThingSpeak_.ino (8.4 KB)

Show your circuit diagram (not fritzing) mark all connections, show code in code brackets.

WemosMiniD2 ?

The counterfeit DS18B20 stops working at a high temperature, they don't work very well with a long cable and they don't work very well at 3.3V.


It is probably a ESP8266 Mini D1 V2.
There is also a "S2" and a "D32" version of a LOLIN/Wemos ESP32 board.

LOLIN is at version 4 for the ESP8266 Mini D1: https://www.wemos.cc/en/latest/d1/d1_mini.html