요새 미세먼지 때문에 큰일입니다. 청소 때문에 환기를 안할수도 없고 환기를 하자니 미세먼지 때문에 걱정되고…
그래서 미세먼지 측정기를 만들어서 실내 공기 상태를 확인해 봅니다.
사용부품:
- Arduino Nano
- 1602 i2c lcd
- Nova PM sensor SDS011
주의 : SDS011의 최대 전류가 80mA이기 때문에 전원 공급을 따로 해야 합니다.
SDS011 Datasheet 다운: SDS011_laser_PM2.5_sensor_specification-V1.3
버튼 누르면 5초동안 팬이 돌면서 공기가 들어간 다음에 데이터를 읽어서 LCD 화면에 보여준 다음에 Sleep모드로 들어갑니다. Sleep모드에 안들어가면 이 센서에 있는 팬이 계속해서 돕니다. 가정에서는 필요할때마다 버튼 눌러서 확인하는게 좋겠네요.
sds011 라이브러리 : https://github.com/ricki-z/SDS011
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#include <JC_Button.h> #include <SDS011.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> // Set the LCD address to 0x38 for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x38, 16, 2); SDS011 my_sds; const byte ON_PIN = 8; Button onBtn(ON_PIN); float p10, p25; int error; void setup() { my_sds.begin(5, 4); //RX, TX onBtn.begin(); lcd.begin(); lcd.backlight(); lcd.print("PM Sensor Starts"); } void loop() { onBtn.read(); if (onBtn.wasPressed()) { lcd.clear(); lcd.setCursor(0,0); lcd.print("Wait 5 Seconds"); pmRead(); delay(1000); } delay(100); } void pmRead(){ my_sds.wakeup(); delay(5000); error = my_sds.read(&p25, &p10); if (!error) { printData(); } } void printData(){ lcd.clear(); lcd.setCursor(0,0); lcd.print("PM 2.5 : " + String(p25)); lcd.setCursor(0,1); lcd.print("PM 10 : " + String(p10)); my_sds.sleep(); } |
Full size image : http://weallplay.co.kr/wp-content/uploads/2018/11/pmSensor_org.png