Introduction: Full Home Nice Automation System

In this poject, we make A Full Home Nice Automation system using the Nodemcu board and the New Blynk app. This system includes GAS level monitoring system and water level monitoring system. For that, we used the MQ135 sensor and Ultrasonic sensor. Also, we can monitor these data on the LCD display, smartphone or computer. For that, we can use the Blynk new update and can recreate this project to automate devices in our room.

The video is provided in the last step. Ok, let's go ahead.

Supplies

You will need the following components

  • Nodemcu ESP8266 x 1
  • Ultrasonic sensor x 1
  • MQ 135 air quality sensor module x 1
  • LCD display x 1
  • Buzzer x 1
  • Breadboard x 1
  • Jumper wires

Among the required items :

Ultrasonic https://my.cytron.io/p-5v-hc-sr04-ultrasonic-sens...

Mq135 air quality sensor module https://my.cytron.io/p-mq135-air-quality-sensor-m...

Lcd https://my.cytron.io/p-i2c-1602-serial-lcd-for-ar...

Jumper https://my.cytron.io/p-male-to-male-jumper-wire?s...

Breadboard https://my.cytron.io/p-breadboard-8.5x5.5cm-400-h...

Step 1: How It Works

Firstly, attach these components to the breadboard as we like such as NodeMCU, buzzer, ultrasonic sensor and MQ135 sensor. Secondly, connect these components to the NodeMCU board. For that, use the circuit diagram below. For that, use the circuit diagram below. We connect ultrasonic sensor, LCD display to the NodeMCU board.

We use ultrasonic sensor for mainly measuring distance. Therefore, we can get the water level in the water. But we recommend, please use a waterproof ultrasonic sensor so you can use it for a long time.

Through MQ135 sensor, we can get the Botane, Smoke, Hydrogen, Propane, Methane, and Carbon monoxide. The MQ-135 sensor module comes with a Digital Pin which makes this sensor to operate even without a microcontroller and that comes in handy when you are only trying to detect one particular gas. If you are looking for a sensor to detect or measure common air quality gases such as CO2, Smoke, NH3, NOx, Alcohol, Benzene then this sensor might be the right choice for you.

Make sure you have colorwise arrangement as in the image to avoid confusion at a late stage.

Step 2: Connect Blynk App Web

Next, the circuit is done. Now lets set up the Blynk app web dashboard. For that, first you have to create an account on the Blynk platform.

Our choice app for this assignment is Blynk. The Blynk app website dashboard was initially configured.

Step 1: Log into your account and make a new template of your choosing.

Step 2: Select the "datastreams" tab and manually create each datastream.

Step 3: Select the "Web Dashboard" tab, then drag the four Gauges and the Buttons it onto interface.

Step 4: Click the gear wheel icons one by one in the widgets and select the datastreams.

Step 5: Add your own customizations to these widgets and save them.

OK, the blynk web app is ready for us.

Step 3: Arduino Code

#include

#define BLYNK_PRINT Serial

#include

#include

#define BLYNK_TEMPLATE_ID "TMPLiq9X51rA"

#define BLYNK_DEVICE_NAME "Full Nice Home Automation"

#define BLYNK_AUTH_TOKEN "d-sgSL_PdqOKvWTvrQbR956O9LUUAJfk"

int lcdColumns = 16;

int lcdRows = 2;

int buzzerPin = 0;

//lcd display address

LiquidCrystal_I2C lcd(0x27, 16, 2);

char auth[] = "d-sgSL_PdqOKvWTvrQbR956O9LUUAJfk";//Enter your Auth token

char ssid[] = "UniSZA-WiFi";

char pass[] = "unisza2016";

BlynkTimer timer;

#define Buzzer D0

#define MQ135 A0

#define trig D4

#define echo D5

//Dapatkan value dari button

BLYNK_WRITE(V0) {

}

void setup() {

Serial.begin(9600);

lcd.init();

lcd.backlight();

pinMode(Buzzer, OUTPUT);

pinMode(trig, OUTPUT);

pinMode(echo, INPUT);

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

Wire.begin(D2,D1);

lcd.begin(16,2);

lcd.init();

lcd.backlight();

lcd.setCursor(0, 0);

lcd.print("Home Automation");

lcd.setCursor(4, 1);

lcd.print("System");

delay(4000);

lcd.clear();

//Functionkan dia

timer.setInterval(100L, gassensor);

timer.setInterval(100L, ultrasonic);

}

//dapatkan value daripada sensor gas MQ135

void gassensor() {

int value = analogRead(MQ135);

Serial.println(value);

value = map(value, 0, 2000, 0, 200);

if (value <= 50) {

digitalWrite(Buzzer, LOW);

tone(buzzerPin,0);

} else if (value > 50) {

Blynk.notify("Warning! Gas leak detected");

digitalWrite(Buzzer, HIGH);

tone(buzzerPin,1000);

}

Blynk.virtualWrite(V1, value);

lcd.setCursor(0, 0);

lcd.print("G:");

lcd.print(" ");

lcd.print(value);

}

//dapatkan value daripada sensor ultrasonic

void ultrasonic() {

digitalWrite(trig, LOW);

delayMicroseconds(4);

digitalWrite(trig, HIGH);

delayMicroseconds(10);

digitalWrite(trig, LOW);

long t = pulseIn(echo, HIGH);

long cm = t / 29 / 2;

Blynk.virtualWrite(V4, cm);

lcd.setCursor(8, 1);

lcd.print("W:");

lcd.print(cm);

lcd.print(" ");

}

void loop() {

Blynk.run();//Run the Blynk library

timer.run();//Run the Blynk timer

}

V

V

#include

#define BLYNK_PRINT Serial

#include

#include

#define BLYNK_TEMPLATE_ID "TMPLiq9X51rA"

#define BLYNK_DEVICE_NAME "Full Nice Home Automation"

#define BLYNK_AUTH_TOKEN "d-sgSL_PdqOKvWTvrQbR956O9LUUAJfk"

int lcdColumns = 16;

int lcdRows = 2;

int buzzerPin = 0;

//lcd display address

LiquidCrystal_I2C lcd(0x27, 16, 2);

char auth[] = "d-sgSL_PdqOKvWTvrQbR956O9LUUAJfk";//Enter your Auth token

char ssid[] = "UniSZA-WiFi";

char pass[] = "unisza2016";

BlynkTimer timer;

#define Buzzer D0

#define MQ135 A0

#define trig D4

#define echo D5

//Dapatkan value dari button

BLYNK_WRITE(V0) {

}

void setup() {

Serial.begin(9600);

lcd.init();

lcd.backlight();

pinMode(Buzzer, OUTPUT);

pinMode(trig, OUTPUT);

pinMode(echo, INPUT);

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

Wire.begin(D2,D1);

lcd.begin(16,2);

lcd.init();

lcd.backlight();

lcd.setCursor(0, 0);

lcd.print("Home Automation");

lcd.setCursor(4, 1);

lcd.print("System");

delay(4000);

lcd.clear();

//Functionkan dia

timer.setInterval(100L, gassensor);

timer.setInterval(100L, ultrasonic);

}

//dapatkan value daripada sensor gas MQ135

void gassensor() {

int value = analogRead(MQ135);

Serial.println(value);

value = map(value, 0, 2000, 0, 200);

if (value <= 50) {

digitalWrite(Buzzer, LOW);

tone(buzzerPin,0);

} else if (value > 50) {

Blynk.notify("Warning! Gas leak detected");

digitalWrite(Buzzer, HIGH);

tone(buzzerPin,1000);

}

Blynk.virtualWrite(V1, value);

lcd.setCursor(0, 0);

lcd.print("G:");

lcd.print(" ");

lcd.print(value);

}

//dapatkan value daripada sensor ultrasonic

void ultrasonic() {

digitalWrite(trig, LOW);

delayMicroseconds(4);

digitalWrite(trig, HIGH);

delayMicroseconds(10);

digitalWrite(trig, LOW);

long t = pulseIn(echo, HIGH);

long cm = t / 29 / 2;

Blynk.virtualWrite(V4, cm);

lcd.setCursor(8, 1);

lcd.print("W:");

lcd.print(cm);

lcd.print(" ");

}

void loop() {

Blynk.run();//Run the Blynk library

timer.run();//Run the Blynk timer

}

Step 4: Upload Video

I will show you how to make an Full Home Automation system using Arduino and Nodemcu.

OK enjoy it now.