How to add slider in blynk to control temperature setpoint



And is it any different if you disconnect the relay wiring?


it is the same still failed to read from dht


Flash the DHT sketch that works OK and keep the same Blynk token etc.

Paste Serial Monitor and sketch that gives correct temperature readings.


here are the code that are working

#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
int LED  = 5;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
#define DHTPIN 0          // D3
// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11

BlynkTimer timer;
void sendSensor()
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
  if ((isnan(h)) || (isnan(t))) {
    Serial.println("Failed to read from DHT sensor!");
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, t);
  Blynk.virtualWrite(V6, h);

void setup()
  Blynk.begin(auth, ssid, pass);
  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
void loop()


This are the serial monitor, although it says failed to read but i can get reading normally on the blynk app


I don’t know how Blynk can have accurate data if the sensor is not being read correctly.

Do you have a 1K resistor between pins 1 and 2 on the DHT11?


Change the 1000L to 5000L.


iam using the dht11 module with build in resistor ( that what the seller said)


Are you connecting to 3.3 / 5V on the ESP? Needs to be 3.3V.


yup i connected to 3.3v on the esp


OK stick at it until you can get Serial Monitor to confirm actual DHT sensor readings.


i have another code that can display the reading from serial monitor but it doesnt connected to blynk


OK paste that for me to check it over but obviously we will need the Blynk stuff in the sketch to move forward.


here the code

// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 0     // what digital pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11   // DHT 11

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.

void setup() {
  Serial.println("DHTxx test!");


void loop() {
  // Wait a few seconds between measurements.

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  Serial.print("Humidity: ");
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(" *C ");
  Serial.print(" *F\t");
  Serial.print("Heat index: ");
  Serial.print(" *C ");
  Serial.println(" *F");


here’s the serial monitor


Change the delay(2000) to delay(5000). I would like to see a full page without errors before trying to move forward.

2000ms should be ok but you have any issue somewhere.

Do you just have the one DHT11?


Try this loop() which just reads temperature:

void loop() {
  // Wait a 5 seconds between measurements.
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();

  // Check if any reads failed and exit early (to try again).
  if (isnan(t)) {
    Serial.println("Failed to read temperature!");

  Serial.print("Temperature: ");
  Serial.println(" *C ");


i have 1 more dht for spare… Changed the delay to 5000 and here the result


So the 2000ms looks to be a problem and therefore the interval of 1000ms you had in the Blynk sketch will certainly be a problem.

You can probably switch back to the Blynk sketch but ensure the interval is 5000ms (or higher).

You probably only need temperature so you could cut out the humidity reading.