DS18B20 value -127º, but only when connecting to Blynk, on ESP32

This is the first time…
I’ve got other two DS18B20 working 24/7, my code checks if the temperature goes to -127.00 and send Notification and stops the machine…At the moment everything is up and running with them… The MCUs are the ESP8266, not ESP32

Do you get the compiler warning?


@psoro have you changed the default settings in the compiler to show verbose output and you are compiling for WEMOS LOLIN32, right?

Yep, there’s no warning:

Se encontraron múltiples librerías para "WiFi.h"
Usado: C:\Users\Pepe\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi
 No usado: C:\Users\Pepe\Desktop\Arduino\arduino-1.8.4\libraries\WiFi
Usando librería WiFi con versión 1.0 en la carpeta: C:\.......................
Usando librería Blynk con versión 0.4.8 en la carpeta: C:\......................
Usando librería OneWire con versión 2.3.3 en la carpeta: C:\.........................
Usando librería DallasTemperature con versión 3.7.7 en la carpeta: C:\.................
Usando librería Time con versión 1.5 en la carpeta: C:\........................
El Sketch usa 484455 bytes (36%) del espacio de almacenamiento de programa. El máximo es 1310720 bytes.
Las variables Globales usan 37872 bytes (12%) de la memoria dinámica, dejando 257040 bytes para las variables locales. El máximo es 294912 bytes.

The library “WiFi.h” used is the one from espressif, not Arduino.

And is your OneWire Arduino, ESP8266 or a special ESP32?


Usando librería OneWire con versión 2.3.3 en la carpeta: C:\Users\Pepe\Documents\Arduino\libraries\OneWire 

the hardware update I referred to is the esp32 firmware update that I did not do.

I did not understand the question, I’m still a beginner in that area.

I used the same ARDUINO IDE to compile the NODEMCU code (esp8266) that worked fine and to compile the ESP32 code that I am having this problem.

I’m a little confused now … are you using ESP8266 or ESP32?

Try updating the “firmware” e.g. run the Git GUI update process as listed above.

That just may be the solution, as it appears @psoro can get that same sensor working, more often than not, on his ESP32.


Desculpe por confundi-lo :wink:

now I’m not confused anymore.


Hi there,
maybe you can put some sort of condition there.
First define your min temperature and max temperature.


int failed = 0;

void leeTEMP()
  temp = sensors.getTempCByIndex(0);
if (temp == NAN
        || temp > MAX_TEMPERATURE
        || temp < MIN_TEMPERATURE
        // if any sensor failed, bail on updates
        failed = 1;
    failed = 0;
         Serial.println("TEMPERATURE: ");
         Blynk.virtualWrite(V0, sensors.getTempCByIndex(0));

The error is still there, but you wont see it because the program will skip the reading.

will not be the solution because the correct reading sometimes takes a lot of time and would disrupt the project. I would need to read at least every 1 minute.
thank you anyway.

I am experiencing the same problem. It seems to be an issue when running Wifi & OneWire. Seems strange cause it works fine with the 8266 and the ESP32 is suppose to have a separate processor for the Wifi so it should be better. I posted an issue on the ESP32 GitHub but not sure if anything will be done about it soon. For my project I might have to move away from the ESP32 for now and go back to the 8266 until they get things worked out with the ESP32.

@Northernboy it’s strange that @psoro has an almost working system with his ESP32 i.e 1 in 50 bad readings and he could code around that margin of error. Suggest you try his exact sketch.

I tested psoro’s code just and I get about 1 in 50 good readings. If I comment out the Blynk starts and run that all readings are good all the time. The only difference is I am using Pin 14 instead of Pin 12 because I get a bunch of resets and script doesn’t run. I am also using DFRobot ESP-Wroom-32.

I’m still thinking about this issue and I had the idea to use the two cores of the ESP32 for different purposes, the Core 1 to do Blynk Stuff and the Core 0 to read the sensor and update a few virtual pins… easy…

The result is that the sensor is giving me always -127.00, obviously I’m doing something wrong but I can’t see where…

@Gunner, you were interested about the two cores and their loops time ago, could you please be so kind to have a look and let me know where the mistake is located?

The sketch of the code goes like this:

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include _Sensor libraries and other stuff...._
void setup()
sensors.begin();// Sensor  
_Blynk stuff_ 
xTaskCreatePinnedToCore(loop1, "loop1", 4096, NULL, 1, NULL, 0);
xTaskCreatePinnedToCore(loop2, "loop2", 4096, NULL, 1, NULL, 1);


void loop1(void *pvParameters) //Core 0
while (1){
temp = sensors.getTempCByIndex(0);
Updating Vpins
delay(2000); //Core 0, nothing to do with Core1, delays are allowed.

void loop2(void *pvParameters) //Core 1
while (1){
if (Blynk.connected()){; 

void loop()
// Emtpy loop!

Using this code the Virtual pins are updated every 2 seconds so loop1 is working. On the other hand, Blynk is up and running so loop2 is fine also…
Despite this statements, the sensor is not working…it should be the way I have to “start” the sensor or something similar but I can’t see it…

Do I have to write an extra setup for the other core?

Any help will be appreciated…