KEMBAR78
Ultimo Sketch de Arduino | PDF | Computer Engineering
0% found this document useful (0 votes)
7 views3 pages

Ultimo Sketch de Arduino

This document contains code for an air quality monitoring system using an ESP8266 microcontroller, Blynk platform, and DHT11 sensor. It reads temperature, humidity, and gas levels, displaying the data on an LCD and sending it to the Blynk app. Alerts are triggered when gas levels exceed a certain threshold, indicating poor air quality.

Uploaded by

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

Ultimo Sketch de Arduino

This document contains code for an air quality monitoring system using an ESP8266 microcontroller, Blynk platform, and DHT11 sensor. It reads temperature, humidity, and gas levels, displaying the data on an LCD and sending it to the Blynk app. Alerts are triggered when gas levels exceed a certain threshold, indicating poor air quality.

Uploaded by

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

#define BLYNK_TEMPLATE_ID "TMPL2PKfnJq2t"

#define BLYNK_TEMPLATE_NAME "MONITOR DE CALIDAD DE AIRE"


#define BLYNK_AUTH_TOKEN "qYwBi970kfr_1alH13IDNVeVtEqO7ORa"

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#include <DHT.h>

//#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

byte degree_symbol[8] =
{
0b00111,
0b00101,
0b00111,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "SHAW-FD3872"; // FiberCorp wifi285 2.4/5


char pass[] = "0N36X8XPF4X0"; // 01030657863056

BlynkTimer timer;

int gas = A0;


int sensorThreshold = 100;

#define DHTPIN 2 //Connect Out pin to D2 in NODE MCU


#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

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;
}
int analogSensor = analogRead(gas);
Blynk.virtualWrite(V2, analogSensor);
Serial.print("Gas Value: ");
Serial.println(analogSensor);
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V0, t);
Blynk.virtualWrite(V1, h);

Serial.print("Temperature : ");
Serial.print(t);
Serial.print(" Humidity : ");
Serial.println(h);

}
void setup()
{

Serial.begin(115200);

//pinMode(gas, INPUT);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(30000L, sendSensor);

//Wire.begin();
lcd.init();
lcd.clear();
lcd.backlight();
// lcd.clear();
lcd.setCursor(3,0);
lcd.print("Air Quality");
lcd.setCursor(3,1);
lcd.print("Monitoring");
delay(2000);
lcd.clear();
}

void loop()
{
Blynk.run();
timer.run();
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
int gasValue = analogRead(gas);
lcd.setCursor(0,0);
lcd.print("Temperature ");
lcd.setCursor(0,1);
lcd.print(t);
lcd.setCursor(6,1);
lcd.write(1);
lcd.createChar(1, degree_symbol);
lcd.setCursor(7,1);
lcd.print("C");
delay(4000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Humidity ");
lcd.print(h);
lcd.print("%");
delay(4000);
lcd.clear();
//lcd.setCursor(0,0);
// lcd.print(gasValue);
// lcd.clear();
if(gasValue<600)
{
lcd.setCursor(0,0);
lcd.print("Gas Value: ");
lcd.print(gasValue);
lcd.setCursor(0, 1);
lcd.print("Fresh Air");
Serial.println("Fresh Air");
delay(4000);
lcd.clear();
}
else if(gasValue>600)
{
lcd.setCursor(0,0);
lcd.print(gasValue);
lcd.setCursor(0, 1);
lcd.print("Bad Air");
Serial.println("Bad Air");
delay(4000);
lcd.clear();
}

if(gasValue > 600){


//Blynk.email("gabrielpuchetta@gmail.com", "Alerta", "Aire nocivo!");
Blynk.logEvent("pollution_alerta","Aire nocivo");
}
}

You might also like