top of page

IOT-based Home Automation with NodeMCU

Now get your alerts & updates about home, wherever you are, with an SMS on your mobile! All with a simple NodeMCU project!



Products Links:




Node MCU (ESP8266) - https://bit.ly/3aRcNQ7


M to M Jumper Wires - https://bit.ly/3vrJ4qy


F to F Jumper Wires - https://bit.ly/3DUj6yT


PIR Motion Sensor - https://bit.ly/3jc2YB1


DHT11 Sensor Module - https://bit.ly/3jeLWSA






Story


We know about fire accidents due to gas leakages in residential and commercial places due to various reasons, and then if there is any ignition then the gas rapidly catches fire.




In vehicles which use CNG, if there is any leakage then there is also same possibility of the vehicle catching fire. Thus, we have developed a simple fire alarm circuit which provides you with alerts about your home/office/vehicle about fire, smoke or burglar intrusions.


The sensor in the circuit will sense the gas/smoke leakage, if the leakage is of high intensity it will alarm the buzzer so the owners will be alert to take precaution measures to minimize the possibility of fire accidents or any loss to life or property. A fire or alarm system is often monitored regionally within the premises, or remotely at an overseas place as per demand.


Remote alarm provides the owner of the premise with the advantage of observation from distant location associated taking immediate actions once an emergency message is received, unlike a manual system. With the advancement of human civilization, fire- safety has been a major concern. Fire hazards will be fatal and calumnious for industrial and unit security, conjointly alarming for human life. So, there comes the need of standalone autonomous and mobile fireplace detection systems. These systems render the works of fast detection, alarm notification, and generally initiation of fireside termination.


The systems, equipped with smoke, temperature sensors can detect unfavorable accidental situations and with the help of a processing unit can alert instantly for undertaking cautious measures. In these fatal things, early detection and quicker alert can yield lesser losses of property and life. The concentration of alcohol is calculated by using the highly sensitive alcohol sensor that can convert alcohol molecules volatilized from body fluids, which exposed to human skin contents a certain level of alcohol after drinking, correspondingly to electrical signals.


Using Internet of Things (IOT), we can control any electronic equipment in homes and industries. Moreover, you can read a data from any sensor and analyses it graphically from anywhere in the world.


Procedure to build the mechanism


We used the following sensors and components:

1. Humidity and Temperature Sensor

2. Gas Detection (also used as Alcohol Detection) sensor

3. PIR Motion Sensor

4. Buzzer

5. NodeMCU



In this circuit, if the smoke detector catches any traces of any smoke, alcohol or gas, then it will alert the user through the Blynk mobile app via IoT cloud. Similarly is in the case of any unwanted movements

Here, we can read temperature and humidity data from DHT11 sensor and upload it to a Thing Speak cloud using Arduino Uno and ESP8266-01 module. Arduino Uno is MCU, it fetches a data of humidity and temperature from DHT11 sensor and Process it and give it to a ESP8266 Module. ESP8266 is a WIFI module, it is one of the leading platforms for Internet of Things. It can transfer a data to IOT cloud.


























Circuit Diagram :





Code:




/*Modified by

* ProfessorHulk and HACKITT from TOAOST

*/

#define ledPin D7

#define pirPin D6 // Input for HC-S501


#define MQ2pin (0)

#define BLYNK_PRINT Serial

#define buzzerPin 16

#define DHTPIN 14

#include <ESP8266WiFi.h>

#include <SPI.h>

#include <BlynkSimpleEsp8266.h>]

#include <DHT.h>

#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

BlynkTimer timer;

char auth[] = "wKqP98rUsa--qZO-6XMHjvxy6W1whgNf";

char ssid[] = "Redmi Note 4";

char pass[] = "12345678";


float sensorValue,h,t;


int pirValue; // Place to store read PIR Value

int n,m;


void setup()

{


Serial.begin(9600);

Serial.println("Gas sensor warming up!");

delay(5000);


Blynk.begin(auth, ssid, pass);

// You can also specify server:

//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);

//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

dht.begin();

pinMode(ledPin, OUTPUT);

pinMode(pirPin, INPUT);

pinMode(4,OUTPUT);

pinMode(0,OUTPUT);

pinMode(5,OUTPUT);

pinMode(buzzerPin,OUTPUT);

digitalWrite(ledPin, LOW);

timer.setInterval(1000L, sendUptime);

}



void sendUptime()

{

Blynk.virtualWrite(V1, n); //V1 is for Gas

Blynk.virtualWrite(V2, m); //V2 is for Alcohol

Blynk.virtualWrite(V5, h); //V5 is for Humidity

Blynk.virtualWrite(V6, t); //V6 is for Temperature

}


void loop()

{

sensorValue = analogRead(MQ2pin); // read analog input pin 0

h = dht.readHumidity();

t = dht.readTemperature();

Serial.println("");

Serial.print("Sensor Value: ");

Serial.print(sensorValue);

Serial.println("");

if(sensorValue > 300 && sensorValue < 600)

{

Serial.print("Smoke detected!");

}

Serial.println("");

delay(2000);

if(sensorValue > 600)

{

digitalWrite(4,LOW);

digitalWrite(0,LOW);

digitalWrite(5,HIGH);

Serial.print("Alcohol detected!");

}

Serial.println("");

Serial.print("Temp: ");

Serial.print(t);

Serial.print("°C");

Serial.println("");

Serial.print("Humid: ");

Serial.print(h);

Serial.print("%");

delay(2000);// wait 2s for next reading

Blynk.run();

timer.run();

n=analogRead(A0);


if(n>600)

{

n==m;

m=analogRead(A0);

Serial.println(m);

}

if(n>300 && n<600)

{

digitalWrite(4,LOW);

digitalWrite(0,HIGH);

digitalWrite(5,LOW);

tone(buzzerPin,800,80);

delay(2000);

}

if(n<300)

{

digitalWrite(4,HIGH);

digitalWrite(0,LOW);

digitalWrite(5,LOW);

delay(2000);

noTone(buzzerPin);

}

getPirValue();

Blynk.run();

}


void getPirValue(void)

{

pirValue = digitalRead(pirPin);

if (pirValue)

{

Serial.println("==> Motion detected");

Blynk.notify("T==> Motion detected");

}

digitalWrite(ledPin, pirValue);

}





Recent Posts

See All

Comments


bottom of page