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

My problem I don't see any value on serial monitor for Dht 22 on BLYNK 2.0 .PLEASE HELP

Hi Blinkers,
I want to use DHT 22 Sensor in my project on Bylnk 2.0.I used this code for this but I don’t see any value.If I run a test code for DHT 22 Its working,but I dont see any value on this code or bylnk 2.0.I used adafuit DHT library .Please help.

#define BLYNK_TEMPLATE_ID "TMPLprft7B8M"
#define BLYNK_DEVICE_NAME "Sera OTM"

#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
#define APP_DEBUG
#define DHTPIN 4 //D5 pin of Node MCU 
#define DHTTYPE DHT22
#include <Adafruit_Sensor.h>
#define MODE
#include "BlynkEdgent.h"
#include <DHT.h>



DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer1;
float h , t;

void sendSensor()
{
 h = dht.readHumidity();
 t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  Blynk.virtualWrite(V0, h);
  Blynk.virtualWrite(V1, t);
}


void setup()
{
  Serial.begin(115200);
  delay(100);
  
  dht.begin();
  BlynkEdgent.begin();
  timer1.setInterval(2000L, sendSensor);
}

void loop() 
{
  
 BlynkEdgent.run();
 timer1.run();
  
  h = dht.readHumidity();
  t = dht.readTemperature();
  
 Serial.println("HUMİDİTY:");
 Serial.println(h);
  Serial.println("TEMPERATURE:");
 Serial.println(t);
}

You haven’t defined a board type, so when you look at the Settings.h tab the Custom board configuration will be used….

  #warning "Custom board configuration is used"

  #define BOARD_BUTTON_PIN            0                     // Pin where user button is attached
  #define BOARD_BUTTON_ACTIVE_LOW     true                  // true if button is "active-low"

  #define BOARD_LED_PIN               4                     // Set LED pin - if you have a single-color LED attached

As you can see, GPIO4 is already in use, and this is the pin you are using for your DHT sensor.

Also, this code…

Should be in your sendSensor function (without these two lines)…

Pete.

Sir ,Thank you for answer but there is no different

[Unformatted code removed by moderator]

What can I do I must solve this poblem

Your code has been deleted because you didn’t use the correct triple backtick characters, despite having used these correctly previously.

Also, I’d success that you copy/paste your serial monitor (also with triple backticks) rather than posting a photograph of your screen.

Pete.

@Haydar5988 try this :

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;
  }
  else {
    h = dht.readHumidity();
    t = dht.readTemperature();
  Serial.println("HUMİDİTY:");
  Serial.println(h);
  Serial.println("TEMPERATURE:");
  Serial.println(t);
}
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

Hii You are right I couldn’t use characters.
There is code here before and after but result is same .I don’t see any value on serial monitor.
Code before :

#define BLYNK_TEMPLATE_ID "TMPLprft7B8M"
#define BLYNK_DEVICE_NAME "Sera OTM"

#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
#define APP_DEBUG
#define DHTPIN 4 //D5 pin of Node MCU 
#define DHTTYPE DHT22
#include <Adafruit_Sensor.h>
#define MODE
#include "BlynkEdgent.h"
#include <DHT.h>



DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer1;
float h , t;

void sendSensor()
{
 h = dht.readHumidity();
 t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  Blynk.virtualWrite(V0, h);
  Blynk.virtualWrite(V1, t);
 Serial.println("HUMİDİTY:");
 Serial.println(h);
 Serial.println("TEMPERATURE:");
 Serial.println(t);
}
//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;
//  }
//  else {
//    h = dht.readHumidity();
//    t = dht.readTemperature();
//  Serial.println("HUMİDİTY:");
//  Serial.println(h);
//  Serial.println("TEMPERATURE:");
//  Serial.println(t);
//}
//  Blynk.virtualWrite(V5, h);
//  Blynk.virtualWrite(V6, t);
//}


void setup()
{
  Serial.begin(115200);
  delay(100);
  
  dht.begin();
  BlynkEdgent.begin();
  timer1.setInterval(2000L, sendSensor);
}

void loop() 
{
  
 BlynkEdgent.run();
 timer1.run();
  
  h = dht.readHumidity();
  t = dht.readTemperature();


}



Code after:

#define BLYNK_TEMPLATE_ID "TMPLprft7B8M"
#define BLYNK_DEVICE_NAME "Sera OTM"

#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
#define APP_DEBUG
#define DHTPIN 4 //D5 pin of Node MCU 
#define DHTTYPE DHT22
#include <Adafruit_Sensor.h>
#define MODE
#include "BlynkEdgent.h"
#include <DHT.h>



DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer1;
float h , t;

//void sendSensor()
//{
// h = dht.readHumidity();
// t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
//
//  if (isnan(h) || isnan(t)) {
//    Serial.println("Failed to read from DHT sensor!");
//    return;
//  }
//  Blynk.virtualWrite(V0, h);
//  Blynk.virtualWrite(V1, t);
// Serial.println("HUMİDİTY:");
// Serial.println(h);
// Serial.println("TEMPERATURE:");
// Serial.println(t);
//}
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;
  }
  else {
    h = dht.readHumidity();
    t = dht.readTemperature();
  Serial.println("HUMİDİTY:");
  Serial.println(h);
  Serial.println("TEMPERATURE:");
  Serial.println(t);
}
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}


void setup()
{
  Serial.begin(115200);
  delay(100);
  
  dht.begin();
  BlynkEdgent.begin();
  timer1.setInterval(2000L, sendSensor);
}

void loop() 
{
  
 BlynkEdgent.run();
 timer1.run();
  
  h = dht.readHumidity();
  t = dht.readTemperature();


}

The result is same…

What can I do

You haven’t changed the pin you are using. Have you modified the Settings.h file instead?

These lines of code in your void loop are trying to read your DHT sensor every time the void loop executes, which is hundreds if not thousands of times per second. You sensor can’t cope with being read more than about once every second. If you re-read what I wrote, I told you that all DHT code should be moved from your void loop, and that the dht.read lines were not required, as they already existed in the sendData function.

Read the answers that are provided more carefully!

Pete.

Very very fhanks I solved t,his problem :slight_smile: :blush::blush::blush: