As I while away my time under the current circumstances I thought I would put together a PM2.5 detector. PM2.5s can impair lung function so the Gov recently said that certain types of open fire / stove fuels would be banned e.g un-seasoned (wet) wood.
The hardware I used was (from top to bottom in the pic):
Arduino Nano V3 (clone)
A 16x2 HD44780 LCD with a FC-113 I2C display driver
A Sharp GP2Y1014AU PM2.5 detector (from Keyestudio)
I connected everything up using jumper jerky wires and mounted everything on an mdf door hanger.
I used the 5V pin on the ICSP connector to power the LCD rather than splice two wires together.
I had to finesse the sample code from the Keyestudio wiki (which is quite a useful resource) to get the data displayed on the 16x2 lcd as it was written for a 20x4 lcd.
My code (where SV = raw signal voltage, CV = calculated voltage and DD = dust density … I must put these in the sketch as comments):
#define BACKLIGHT_PIN 13
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
int measurePin = 0; //Connect dust sensor to Arduino A0 pin
int ledPower = 2; //Connect 3 led driver pins of dust sensor to Arduino D2
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
// Switch on the backlight
pinMode ( BACKLIGHT_PIN, OUTPUT );
digitalWrite ( BACKLIGHT_PIN, HIGH );
lcd.begin(16,2); // initialize the lcd
digitalWrite(ledPower,LOW); // power on the LED
voMeasured = analogRead(measurePin); // read the dust value
digitalWrite(ledPower,HIGH); // turn the LED off
// 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 © 2012
dustDensity = 0.17 * calcVoltage - 0.1;