NodeMCU with smoke ,temperature and humidity sensor

How the tool works

We put the microcontroller in the room. DHT11 will take the Temperature and Humidity and MQ – 135 will take the parameter of Air Quality. We use blynk to monitoring the value. The microcontroller which connected to internet connection will send the Temperature, humidity and air quality data to blynk cloud and the cloud will send the data to our app.

Vedio

Hardware Component

  • ESP8266 module
  •  USB Cable
  •  DHT 11
  •  MQ – 135
  •  buzzer
  •  Wires
  • Software Os and Apps(Arduino IDE)

Temperature, Humidity and Air Quality Control

 Pin A0 to A0 on MQ – 135
 GND to GND on MQ – 135
 3V3 to VCC on MQ


 Pin D1(DHTPin 5) to pin DHT 11 data
 GND to GND on DHT 11
 3V3 to VCC on DHT 11

Pin D8( BuzzerPin 15) to Buzzer Pin +ve
GND to GND of Buzzer

Arduino Code

#include “DHTesp.h”              //Declarate DHT Library

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <SimpleTimer.h>

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space

#define DHTpin 5                                      //Pin of DHT 11 //D8 pin of nodemcu

DHTesp dht;

const int buzzerPin = 15; //buzzer to nodemcu D8

char auth[] = “XXXXXXXX”; // get code from bylnk server with new create project for NodeMCU

/* WiFi credentials */

char ssid[] = “satya_wifi”; //wifi ssid id to be connected

char pass[] = “123xxx444”; // wifi password

SimpleTimer timer;

int mq135 = A0; // smoke sensor is connected with the analog pin A0

int data = 0;

void setup()

{

  Serial.begin(115200);

  pinMode(buzzerPin, OUTPUT); // Set buzzer – D8

  Blynk.begin(auth, ssid, pass);

  dht.setup(DHTpin, DHTesp::DHT11); //for DHT11 Connect DHT sensor to GPIO 17

  timer.setInterval(1000L, getSendData);

}

void loop()

{

  timer.run(); // Initiates SimpleTimer

  Blynk.run();

}

/***************************************************

 * Send Sensor data to Blynk

 **************************************************/

void getSendData()

{

  float h = dht.getHumidity();                       //Read humidity and put it in h variable                            

  float t = dht.getTemperature();                    //Read temperature and put it in t variable

  Blynk.virtualWrite(V5, t);                          //Send t value to blynk in V5 virtual pin                                

  Blynk.virtualWrite(V6, h);                          //Send h value to blynk in V6 virtual pin

  if (isnan(h) ||isnan(t))  {

    Serial.println(“Cant read from DHT11”);

  }else{

    Serial.println(h);

    Serial.println(t);

    }                               

  data = analogRead(mq135);

  Blynk.virtualWrite(V2, data); //virtual pin V3

  if (data > 400 )                      //trigger buzzer if if smoke sensor value is greate than 400

  {

    tone(buzzerPin, 1000); // Send 1KHz sound signal…

    delay(1000);        // …for 1 sec

    noTone(buzzerPin);     // Stop sound…

    delay(1000);        // …for 1sec

    Blynk.notify(“Smoke Detected!!!”);

  }

  if (t>40) {  //trigger buzzer if the temperate exceed 40 c

    tone(buzzerPin, 1000); // Send 1KHz sound signal…

    delay(1000);        // …for 1 sec

    noTone(buzzerPin);     // Stop sound…

    delay(1000);        // …for 1sec

    Blynk.notify(“The Temperature is too high”);      //Blynk will send notify if t>40

  }

}

Leave a Reply

Your email address will not be published. Required fields are marked *