NodeMCU, DS18B20 sensor & Blynk comms issue

Hi there, I have setup my NodeMCU to read temperatures currently from 2no. DS18B20 sensors and this is being transmit through to Blynk. It works great and displays the temperatures as designed. However when I use the graph to plot the temperature trends i’m seeing momentary drops in the temperature being recorded down to -127, as if the probe momentarily disconnects & reconnects. I was wondering if anyone could be of assistance as to why this would happen.

I have attached my code below;

Many thanks,
Jim


#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2


OneWire oneWire(ONE_WIRE_BUS); // digital D2 pin

DallasTemperature sensors(&oneWire);
BlynkTimer timer;

// You should get Auth Token in the Blynk App.

char auth[] = "-----";
// Your WiFi credentials.
char ssid[] = "-----";
char pass[] = "-----";

float  temp1 = 0;
float  temp2 = 0;

uint8_t sensor1[8] = { 0x28, 0xF8, 0xC7, 0x81, 0x42, 0x20, 0x01, 0x09 };
uint8_t sensor2[8] = { 0x28, 0x5A, 0x33, 0x83, 0x42, 0x20, 0x01, 0x85 };


void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  sensors.begin();
// Setup a function to be called every second  
  timer.setInterval(1000L, sendTemps);
}

void sendTemps()
{
 sensors.requestTemperatures();
 temp1 = sensors.getTempC(sensor1);
 
 Serial.print(String("Boiler Flow Temp= ")+temp1+ String("°C        "));
 Blynk.virtualWrite(V1, temp1);


 temp2 = sensors.getTempC(sensor2);
 
 Serial.println(String("Boiler Return Temp= ")+temp2+ String("°C "));
 Blynk.virtualWrite(V2, temp2);

Serial.println ();

}


void loop()
{
  Blynk.run();
  timer.run();
}

-127 is the value that your sensor library returns when it can’t read your sensor(s) correctly.
This may be caused by the sensors being read too frequently, wiring issues, or some other random reason.

The solution is simple, reject the -127 values and don’t send them to Blynk.

It’s also worth you understanding how Superchart works…
For most screens except Live View, the values received over a 1 minute period are buffered and averaged, then the result written to the database. This means that if you are seeing -127 in these screens then you have had at least 60 failed readings.

More info on this in the Superchart documentation under the heading of Granularity.

Pete.