BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

How to add slider in blynk to control temperature setpoint


#81

is it could be that my arduino IDE is wrongly setting?


#82

Serial Monitor certainly needs to be 115200.
Try reflashing the sketch again.


#83

yup already done that still blank


#84

Which IDE version are you using? I have 1.8.8.


#85

same here 1.8.8


#86

In the IDE under tools set erase flash to “All Flash Contents” and flash a blank sketch. Then change the settings back to erase “Only Sketch” and flash my latest sketch again.


#87

done according to your instruction but still to get any value


#88

Good at least the sketch is “working”. You need to check the DHT11 etc.


#89

i checked all my sensor and they working using DHTtester code, i wonder what would seem the problem


#90

should i change my sensor? or my nodemcu?


#91

You shouldn’t have to change either. I think without Blynk your DHTtester sketch runs OK.

At the moment I can’t work out why adding Blynk is a problem.

Do any Blynkers have a DHT11 that they can test a sketch with?


#92

iam planning to change the dht11 to dht22


#93

Sounds to me like there’s some newbie mistake happening here.
I’m reading this on an iPhone (sat in a very nice, and hot, beach bar in Thailand by the way :sunglasses:) so following the ins-and-outs of the thread is tricky. Has the OP posted his DHT test code, and does it use the same DHT pins, library etc as is being used in the other code?

Also, if this is lashed-up on a breadboard then there’s every chance that there are some dodgy connections in there somewhere.

A more forensic approach to the fault-finding process would no doubt reveal the problem, but that’s not really possible with the OP’s obvious lack of experience and language issues.

Pete.


#94

Yes iam actually very fresh newbie in programming :sweat_smile:. Iam sure the connection is right. Btw iam not using breadboard just straight jumper wire connection. I already download the library for blynk and the dht sensor. What do you mean that library being used in another code?


#95

A freezing 8 degrees here in the Eastern med.


#96

Yes we have the DHTtester sketch and we are using the same pins when we add Blynk.


#97

Still warmer than Blighty though.
Currently 31° and Factor 50 here!

Pete.


#98

@PeteKnight don’t you travel with a WeMos and a DHT in your case?


#99

After changing all the jumper wire to new one and i using below code , it is functioning correctly! Unfortunately the serial monitor still showing " Failed to read from DHT sensor". :disappointed_relieved:
Iam planning to put LED widget as notification when the relay module is on and Button widget for manually operate the relay.

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

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

 
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
 
float setpoint = 0;
bool relaystatuschanged = false;
const int relayPin = 5;  // D1;

BLYNK_WRITE(V0)// slider widget
{
  setpoint = param.asFloat();  
   relaystatuschanged = true; 
}
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!");
    return;
  }
  // 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);
   if((setpoint < t) && (relaystatuschanged == true))
  { 
    digitalWrite(relayPin, 0); // assuming relay is active HIGH
   relaystatuschanged = false;
  }  
  if((setpoint > t) && (relaystatuschanged == true))
  { 
    digitalWrite(relayPin, 1); // assuming relay is active HIGH
    relaystatuschanged = false;
  }
}

void setup()
{
 
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  dht.begin();
  pinMode(relayPin, OUTPUT);
 
  // Setup a function to be called every second
  timer.setInterval(5000L, sendSensor);
}
 
void loop()
{
  Blynk.run();
  timer.run();
}```

#100

Can you describe what you mean by this as I find it hard to believe it is anything like “working” if the DHT is failing to read a temperature.