0% found this document useful (0 votes)
22 views5 pages

DHT11 Gas

The document describes code for an Arduino project that monitors temperature, humidity, and rainfall using a DHT sensor and analog sensor. It displays the readings on an LCD and sends them to a Blynk dashboard. The code initializes the sensors, LCD display, and WiFi and calls functions every 10 seconds to update the readings.

Uploaded by

shivang gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

DHT11 Gas

The document describes code for an Arduino project that monitors temperature, humidity, and rainfall using a DHT sensor and analog sensor. It displays the readings on an LCD and sends them to a Blynk dashboard. The code initializes the sensors, LCD display, and WiFi and calls functions every 10 seconds to update the readings.

Uploaded by

shivang gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include <Blynk.

h>

#include <LiquidCrystal_I2C.h>

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <DHT.h>

#define buzzerPin 16

LiquidCrystal_I2C lcd(0x3F, 16, 2);

// IF IN LCD IS NOT PRINTED ANY THING THEN CHANGE THIS VALUE 0x3F TO 0x27

DHT dht(D3, DHT11); //(sensor pin,sensor type)

BlynkTimer timer;

char auth[] = "J5ppSgySJmfzg9EyAJKRmmjgHJObWfAj"; //Enter the Auth code which was send by Blink

char ssid[] = "redmi"; //Enter your WIFI Name

char pass[] = "987654321"; //Enter your WIFI Password

void weather() {

float h = dht.readHumidity();

float t = dht.readTemperature();

int r = analogRead(A0);

bool l = digitalRead(D4);
r = map(r, 0, 1023, 100, 0);

if(r>40)

digitalWrite(13,LOW);

digitalWrite(14,HIGH);

lcd.print(r);

tone(buzzerPin,800,40);

if(r<40)

digitalWrite(13,HIGH);

digitalWrite(14,LOW);

lcd.print(r);

noTone(buzzerPin);

if (isnan(h) isnan(t)) {
Serial.println("Failed to read from DHT sensor!");

return;

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

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

Blynk.virtualWrite(V2, r); //V2 is for Rainfall

//if (l == 0) {

// WidgetLED led1(V3);

// led1.on();

// lcd.setCursor(9, 1);

// lcd.print("L :");

//lcd.print("High");

//lcd.print(" ");

//} else if (l == 1) {

// WidgetLED led1(V3);

// led1.off();

//lcd.setCursor(9, 1);

//lcd.print("L :");

// lcd.print("Low");

// lcd.print(" ");

//}

lcd.setCursor(0, 0);
lcd.print("T :");

lcd.print(t);

lcd.setCursor(0, 1);

lcd.print("H :");

lcd.print(h);

lcd.setCursor(9, 0);

lcd.print("G:");

lcd.print(r);

lcd.print(" ");

void setup() {

Serial.begin(115200); // See the connection status in Serial Monitor

pinMode(13,OUTPUT);

pinMode(14,OUTPUT);

pinMode(buzzerPin,OUTPUT);

pinMode(D7,OUTPUT);

pinMode(D8,OUTPUT)

lcd.init();

lcd.backlight();

digitalWrite(D7,HIGH);
digitalWrite(D8,HIGH);

Blynk.begin(auth, ssid, pass);

dht.begin();

// Setup a function to be called every second

timer.setInterval(10L, weather);

void loop() {

Blynk.run(); // Initiates Blynk

timer.run(); // Initiates SimpleTimer

You might also like