This is one of my electronic project. I am just a beginner in this field , but I always wanted to make electronic gadgets it has always fascinated me.I was keen since I was a kid infact there is not a single electronic item in my house which I would not have opened to peek inside and understand how its woks.
This is one of those projects that I have in mind . It was by chance I saw an Arduino UNO somewhere, I just fell in love with this platform. Working with microcontroler gives me the freedom to implement simple operations in code that would require a dedicated circuit implementation, you can write a code and get away from the complication of designing the circuit. As I am a software engineer by profession so I am very comfortable with writing codes.
Arduino is a very inexpensive platform and comes in different sizes and configuration you can choose it as per your need. I did this project as a side project as I wanted to measure how clean the air in the house is and how it changes over time.
Bangalore has major issue of Micro dust particles in the air and specially the area where I stay there is a lot of construction ongoing. These micro dust particles are also responsible for respiratory and Skin allergies. I am actually going to build an Air purifier for which this is a building block.
You can see the final display as below. It covers Temperature, Humidity, Time and Dust content level.
I am planning to add a gas sensor also to the system, still searching the rite sensor for this task. Arduino UNO does not keep the time to do this I have connected a RTC module which can persist the time information even when the device is switched off.
Real time sensor data is displayed on the LCD screen and is also logged to a file in the SD card so that it can be analysed later. For debugging purpose I am also writing the data to the serial port so that I can monitor it from a PC.
I have also made a case out of acrylic sheet to assemble every thing and keep it together. All the parts except the Acrylic sheet have been bought online. its very easy to purchase it once you know what all do you need.
In my initial design I was using the 16X2 LCD without the serial I2C module this was giving problem as it did not leave enough free I/O pins to connect other stuff on the Arduino. By switching to I2C module I am not loosing a single pin on Arduino as SDA and SLC pins used by I2C module is shared with RTC Clock. To minimize the noise in the reading I have taken an average of 1000 readings.
You can see the full circuit as below This is my first attempt to design a circuit diagram, Have used Fritzing which is a open source designer for this purpose.
the graph, you can see a sample graph just for couple of days as below. You will be surprised to see the results even in the graph below you can see the variation in the Dust levels.
This is one of those projects that I have in mind . It was by chance I saw an Arduino UNO somewhere, I just fell in love with this platform. Working with microcontroler gives me the freedom to implement simple operations in code that would require a dedicated circuit implementation, you can write a code and get away from the complication of designing the circuit. As I am a software engineer by profession so I am very comfortable with writing codes.
Arduino is a very inexpensive platform and comes in different sizes and configuration you can choose it as per your need. I did this project as a side project as I wanted to measure how clean the air in the house is and how it changes over time.
Bangalore has major issue of Micro dust particles in the air and specially the area where I stay there is a lot of construction ongoing. These micro dust particles are also responsible for respiratory and Skin allergies. I am actually going to build an Air purifier for which this is a building block.
You can see the final display as below. It covers Temperature, Humidity, Time and Dust content level.
I am planning to add a gas sensor also to the system, still searching the rite sensor for this task. Arduino UNO does not keep the time to do this I have connected a RTC module which can persist the time information even when the device is switched off.
Real time sensor data is displayed on the LCD screen and is also logged to a file in the SD card so that it can be analysed later. For debugging purpose I am also writing the data to the serial port so that I can monitor it from a PC.
I have also made a case out of acrylic sheet to assemble every thing and keep it together. All the parts except the Acrylic sheet have been bought online. its very easy to purchase it once you know what all do you need.
In my initial design I was using the 16X2 LCD without the serial I2C module this was giving problem as it did not leave enough free I/O pins to connect other stuff on the Arduino. By switching to I2C module I am not loosing a single pin on Arduino as SDA and SLC pins used by I2C module is shared with RTC Clock. To minimize the noise in the reading I have taken an average of 1000 readings.
You can see the full circuit as below This is my first attempt to design a circuit diagram, Have used Fritzing which is a open source designer for this purpose.
Graph
Log data is written to airlog.txt file on the SD Card. Each line in the file corresponds to a log entry. log entry are separated by a comma CSV. I have created a small program in C# to plotthe graph, you can see a sample graph just for couple of days as below. You will be surprised to see the results even in the graph below you can see the variation in the Dust levels.
Parts Used
The list of all the parts used is as below, I would say its very easy if you have worked on circuits before this will be a piece of cake.
Arduino UNO | |
IIC/I2C/TWI/SP | |
DHT11Temperature & HumiditySensor | |
Sharp OpticalDust Sensor(GP2Y1010AU0F) | |
SD Card | |
RTCClock | |
16X2 LCD |
Code
Below is the code that I have used in programing, you can modify it as per your requirement or use it as such.
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <Wire.h>
#include "RTClib.h"
#include <SPI.h>
#include <SD.h>
#define DHTTYPE DHT11
// select the pins used on the LCD panel
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7);
DHT dht(A1, DHTTYPE);
const int chipSelect = 4;
int measurePin = A2;
int ledPower = A3;
int thermistorPin = A1;
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
float avgDust = 0;
int avgDustCnt = 0;
byte termometru[8] = //icon for termometer
{
4, 10, 10, 10, 14, 31, 31, 14
};
byte picatura[8] = //icon for water droplet
{
4, 4, 14, 14, 31, 31, 31, 14
};
byte threeIco[8] = //raise to power 3 character
{
24, 4, 24, 4, 24, 0, 0, 0
};
byte miliIco[8] = //micrograms character
{
0, 17, 17, 17, 19, 29, 16, 16
};
boolean backlit = true;
RTC_DS1307 rtc;
void setup()
{
lcd.begin (16, 2); // for 16 x 2 LCD module
lcd.createChar(1, termometru);
lcd.createChar(2, picatura);
lcd.createChar(3, threeIco);
lcd.createChar(4, miliIco);
lcd.setBacklightPin(3, POSITIVE);
lcd.setBacklight(HIGH);
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
Wire.begin();
rtc.begin();
//Uncomment this line and upload the sketch to arduino after uploading
//again comment it and upload the sketch again this will set the date and time
//rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
pinMode(A3, OUTPUT);
lcd.home();
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
lcd.print("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
lcd.print("Card Initialized");
}
void loop()
{
DateTime now = rtc.now();
digitalWrite(ledPower, LOW); // power on the dust sensor LED
delayMicroseconds(samplingTime);
voMeasured = analogRead(measurePin); // read the dust value
delayMicroseconds(deltaTime);
digitalWrite(ledPower, HIGH); // turn the dust sensor LED off
delayMicroseconds(sleepTime);
// 0 - 5V mapped to 0 - 1023 integer values
// recover voltage
calcVoltage = voMeasured * (5.0 / 1024.0);
// linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
// Chris Nafis (c) 2012
dustDensity = (0.172 * calcVoltage - 0.0999) * 1000;
avgDust += dustDensity;
avgDustCnt++;
if (avgDustCnt == 1000)
{
// make a string for assembling the data to log:
String dataString = "";
dataString += "Dst" + String(avgDust / avgDustCnt) + ",";
dataString += "Tmp" + String(dht.readTemperature()) + ",";
dataString += "Hum" + String(dht.readHumidity()) + ",";
dataString += String(now.year()) + "/" + String(now.month()) + "/" + String(now.day()) + " ";
dataString += String(now.hour()) + ":" + String(now.minute()) + ":" + String(now.second());
File dataFile = SD.open("airlog.txt", FILE_WRITE);
lcd.clear();
lcd.home();
lcd.write(1);
lcd.print(dht.readTemperature(), 0);
lcd.print((char)223);
lcd.print("C ");
lcd.write(2);
lcd.print(dht.readHumidity(), 0);
lcd.print("%");
lcd.print(" ");
if (now.hour() < 10)
{
lcd.print('0');
}
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute());
lcd.setCursor(0, 1);
lcd.print("Dust: ");
lcd.print(avgDust / avgDustCnt, 1);
lcd.print(" ");
lcd.write(4);
lcd.print("g/m");
lcd.write(3);
// if the file is available, write to it:
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
// print to the serial port too:
Serial.println(dataString);
} else {
Serial.println("error opening datalog.txt");
}
avgDust = 0;
avgDustCnt = 0;
}
}
Next step to this will be working on the Air-purifier. Even in itself its a very good gadget to monitor your home environment.You can go ahead and try it in-case you are not able to locate any of the parts online feel free to contact me and I can guide you to the sites from where I purchased these.