Ahmad Anas
Published © GPL3+

Pollution monitoring using drones during a pandemic lockdown

Detecting localized air pollution from miles away !!!

AdvancedShowcase (no instructions)Over 41 days546

Things used in this project

Hardware components

Drone
×2
Air Quality Module
×1

Software apps and online services

Arduino IDE
Arduplane Mission Planner
Blynk

Story

Read more

Schematics

Schematic

Code

Coding for temperature and humidity sensor

Arduino
#include <dht.h>
dht DHT;
int temp,humi;
#define DHT11_PIN A0
String str;
void setup(){
 Serial.begin(115200);
 Serial1.begin(115200);
 Serial.print(char(169)); // Copyright Symbol
 Serial.println(" Myengineeringstuffs.com");
 delay(2000);
}
void loop()
{
  DHT.read11(DHT11_PIN);
  humi=DHT.humidity;
  temp=DHT.temperature;
  Serial.print("H: ");
  Serial.print(humi); 
  Serial.print("% ");
  Serial.print(" T: ");
  Serial.print(temp); 
  Serial.print(char(176));
  Serial.println("C");
  str =String('H')+String(humi)+String('T')+String(temp);
  Serial1.println(str);
  delay(5000);
}

Coding for Air Quality Module

Arduino
#include <dht.h>
dht DHT;
#define DHT11_PIN 4
#include <MQ135.h>
#include <SoftwareSerial.h>
SoftwareSerial nodemcu(5,6);
#define pin A1
int air_quality;
#include <ArduinoJson.h>

void setup (){
pinMode(A0, INPUT);
Serial.begin (9600);
nodemcu.begin (9600);
}
void loop() {
StaticJsonBuffer<1000> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
MQ135 gasSensor = MQ135(A0); // Attach sensor to pin A0
float air_quality = gasSensor.getPPM();
root["S1"]= air_quality;
Serial.print("Air Quality = ");
Serial.println (air_quality);
int chk = DHT.read11(DHT11_PIN);
  Serial.print("Temperature = ");
  Serial.println(DHT.temperature);
  Serial.print("Humidity = ");
  Serial.println(DHT.humidity);
 root["S2"]= DHT.temperature;
 root["S3"]= DHT.humidity;
 
delay(2000);
if(nodemcu.available()>0)
{
root.printTo(nodemcu);
}
}

Coding for NodeMCU

Arduino
/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  This example runs directly on NodeMCU.

  Note: This requires ESP8266 support package:
    https://github.com/esp8266/Arduino

  Please be sure to select the right NodeMCU module
  in the Tools -> Board menu!

  For advanced settings please follow ESP examples :
   - ESP8266_Standalone_Manual_IP.ino
   - ESP8266_Standalone_SmartConfig.ino
   - ESP8266_Standalone_SSL.ino

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!
 *************************************************************/

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


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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "getyourtoken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "includeyourssid";
char pass[] = "includeyourpassword";

void setup()
{
  // Debug console
  Serial.begin(9600);

  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);
}

void loop()
{
  Blynk.run();
}

Credits

Ahmad Anas

Ahmad Anas

1 project β€’ 0 followers
Thanks to Muhammad Nor Aiman , Muhamad Firdaus , and Dhiya Syakir .

Comments