Devices & Components
Arduino Uno Rev3
ESP8266 ESP-01
SHARP GP2Y1014AU0F Dust Sensor
Hardware & Tools
Premium Female/Male Extension Jumper Wires, 40 x 6" (150mm)
Breadboard, 270 Pin
Soldering iron (generic)
Software & Tools
Blynk
Arduino IDE
Project description
Code
Dust_density monitor
arduino
1#define BLYNK_PRINT Serial 2#include <ESP8266_Lib.h> 3#include <BlynkSimpleShieldEsp8266.h> 4#include <SimpleTimer.h> 5 6char auth[] = "fI1Hhyw20XUE7WmUhcJhJ_QAFHVYkPxQ"; //The authentication token send to your email 7//Your WIFI credentials 8char ssid[] = "ABID"; 9char pass[] = "8901234567"; 10 11#define ESP8266_BAUD 115200 12ESP8266 wifi(&Serial); 13 14int SensorPin = A5; 15int led = 7; 16float SensorOut = 0; 17float SensorVo = 0; 18float Dust = 0; 19float Voltage_noDust = 0.12; //calibrate by changing this 20float K = 0.5; //Sensitivity from the datasheet 0.5V/ugm/m^3 21SimpleTimer timer; 22 23void sendSensor(){ 24 digitalWrite(led,LOW); //turning on the led 25 delayMicroseconds(280); //wait for 0.28ms 26 SensorOut = analogRead(SensorPin); //read the sensor output voltage 27 delayMicroseconds(50); //wait for 50us 28 digitalWrite(led,HIGH); //turning off the led 29 delayMicroseconds(9670); //wait for (10000-280-50)=9670us 30 SensorVo = SensorOut*(5.0/1024); //calculating sensor output voltage 31 Dust = (SensorVo-Voltage_noDust)*100/K; //calculating Dust density(ugm)/m^3 32 33 if ( Dust < 0) 34 { 35 Dust = 0.00; 36 } 37 Blynk.virtualWrite(V1,Dust); //sending data to the cloud 38} 39 40void setup() 41{ 42 pinMode(led,OUTPUT); 43 Serial.begin(115200); 44 delay(10); 45 Serial.begin(ESP8266_BAUD); 46 delay(10); 47 Blynk.begin(auth, wifi, ssid, pass); 48 timer.setInterval(1000L, sendSensor); //set timer interval of 1s 49} 50 51void loop() 52{ 53 Blynk.run(); 54 timer.run(); 55} 56 57
Dust_density monitor
arduino
1#define BLYNK_PRINT Serial 2#include <ESP8266_Lib.h> 3#include <BlynkSimpleShieldEsp8266.h> 4#include <SimpleTimer.h> 5 6char auth[] = "fI1Hhyw20XUE7WmUhcJhJ_QAFHVYkPxQ"; //The authentication token send to your email 7//Your WIFI credentials 8char ssid[] = "ABID"; 9char pass[] = "8901234567"; 10 11#define ESP8266_BAUD 115200 12ESP8266 wifi(&Serial); 13 14int SensorPin = A5; 15int led = 7; 16float SensorOut = 0; 17float SensorVo = 0; 18float Dust = 0; 19float Voltage_noDust = 0.12; //calibrate by changing this 20float K = 0.5; //Sensitivity from the datasheet 0.5V/ugm/m^3 21SimpleTimer timer; 22 23void sendSensor(){ 24 digitalWrite(led,LOW); //turning on the led 25 delayMicroseconds(280); //wait for 0.28ms 26 SensorOut = analogRead(SensorPin); //read the sensor output voltage 27 delayMicroseconds(50); //wait for 50us 28 digitalWrite(led,HIGH); //turning off the led 29 delayMicroseconds(9670); //wait for (10000-280-50)=9670us 30 SensorVo = SensorOut*(5.0/1024); //calculating sensor output voltage 31 Dust = (SensorVo-Voltage_noDust)*100/K; //calculating Dust density(ugm)/m^3 32 33 if ( Dust < 0) 34 { 35 Dust = 0.00; 36 } 37 Blynk.virtualWrite(V1,Dust); //sending data to the cloud 38} 39 40void setup() 41{ 42 pinMode(led,OUTPUT); 43 Serial.begin(115200); 44 delay(10); 45 Serial.begin(ESP8266_BAUD); 46 delay(10); 47 Blynk.begin(auth, wifi, ssid, pass); 48 timer.setInterval(1000L, sendSensor); //set timer interval of 1s 49} 50 51void loop() 52{ 53 Blynk.run(); 54 timer.run(); 55} 56 57
Downloadable files
Dust_density monitor
Dust_density monitor

Comments
Only logged in users can leave comments