13. –Dylos Serial reading
port = ARGV[0]
logfile = ARGV[1]
ser = SerialPort.new(port, 9600, 8, 1, SerialPort::NONE)
loop do
line = ''
loop do
char = ser.getc
# .. normalize line format ..
sleep 0.1
end
File.open(logfile, "a+") do |f|
txt = "#{DateTime.now.strftime("%Y-%m-%d--%H-%M-%S")} #{line.strip}"
f.puts txt
end
end
19. –SHINYEI TECHNOLOGY Co., Ltd.
“Thank you for your inquiry of Shinyei Particle Sensor.
We usually do not disclose the information you have inquired.”
24. –flank Algorithm
# .. mcu loop ..
if digitalRead(pin) == LOW
unless was_low?
# just changed to low; lets save the start
start_low = millis
was_low? = true
end
else
if was_low?
# Low pulse complete
# Calculate the duration of the low pulse
duration = millis - start_low
# Valid low pulses are only 10ms to 90ms long
low_sum += duration if duration >= 10 && duration <= 90
not_low_anymore
end
end
25. –flank Algorithm
# .. mcu loop ..
if digitalRead(pin) == LOW
unless was_low?
# just changed to low; lets save the start
start_low = millis
was_low? = true
end
else
if was_low?
# Low pulse complete
# Calculate the duration of the low pulse
duration = millis - start_low
# Valid low pulses are only 10ms to 90ms long
low_sum += duration if duration >= 10 && duration <= 90
not_low_anymore
end
end
Low Flank
High Flank
34. –PWM based on low pulse ratio
# .. mcu loop ..
# acquire ratio (usually between 0% to 10%)
ratio = lowpulseoccupancy_ratio(sensor_pin)
# map 0-10% to full PWM range and
# re-use this ratio as duty cycle
analogWrite(fan_pin, 255 / 100 * ratio * 10)
40. Feature Wish List
Cloud Storage of Pollution
Remote Control
Time Scheduler
Automatic Filter Exchange Notification
History Graph of Pollution
Software Upgrade
41. 3. Version
• remote control via wlan
• air sensing and filter check
• data graphing and collection