I’m using pulseIn() for reading Low Pulse Occupancy Time from Dust Sensor PPD42NS and the process is taking too long to complete and blocks other functions of the project! In this project, I want a loop to be executed every second, but with pulseIn() its not able to…
Without pulseIn():-
Timer: 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40
Executes every second consistently
With pulseIn():-
Timer: 31, 32, 33, 36, 37, 40, 42, 43, 45, 45, 46, 50
Gets blocked at 34 & 35, then 38 & 39, then 41, then 44, then 47,48,49. And at 45 gets executed twice rapidly…
Option #1:-
Well, I’m still not sure of this is a solution, but can anyone let me know if this will work?
pulseIn() on Arduino has a timeout feature for this function…
Arduino Syntax: pulseIn(pin, value, timeout)
particle Photon Syntax: pulseIn(pin, value)
Can you add this feature or is there a way to add this feature myself manually? Code level changes? Dust Sensor connectivity changes? Anything?
If this feature is included, how will it affect the Dust Sensor’s readings?
Option #2:-
Can I add, a dedicated simple cheap device, which can read Low Pulse Occupancy Time and report the results to particle photon? What’s the best way to do this? Hardware options?