Cindy
Created July 31, 2017 © MIT

Air Pollution Analyzer

PM2.5 harmful to health and research on historical record.

IntermediateWork in progress2 hours95

Things used in this project

Hardware components

Intel Edison
Intel Edison
×1
SW-PWM-01 smart air pollution sensor
×1

Software apps and online services

MRAA on python

Hand tools and fabrication machines

sparkfun edison pack

Story

Read more

Code

pm2.5_sensing

Python
pm2.5_sensing
# PM2.5 

import mraa
import time


#LowPassFilter parameters
PARAM_A = -0.0058
PARAM_B = 0.42
PARAM_C = 11.5
PARAM_D = 5
FILTER_A=0.98

#init pins
print (mraa.getVersion())
# GP14 for x and GP15 for y
x = mraa.Gpio(36)
x.dir(mraa.DIR_IN)
y = mraa.Gpio(48)		
y.dir(mraa.DIR_IN)
time.sleep(0.05)
# init values
lastValue=0


while True:
	value= 0.0
	t_x = 0
	t_x2 = 0
	TimesOfInt = 0
	CntOfLP = 0
	reading = 0
	if value >= 1:
			CntOfLP+=1
	TimesOfInt+=1
	if TimesOfInt >= 5000:
		lastValue = (1-FILTER_A) * CntOfLP + FILTER_A * lastValue	
		#converting LPO to dust concentration
		t_x = lastValue/ 50.0
		t_x2 = t_x * t_x
		reading = (PARAM_A * t_x2 * t_x + PARAM_B * t_x2 + PARAM_C * t_x + PARAM_D)
		print(reading)
		CntOfLP = 0
		TimesOfInt = 0
	time.sleep(1)
	

Credits

Cindy

Cindy

3 projects • 3 followers
bonjour

Comments