1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- import time, sys, signal, atexit
- import pyupm_ppd42ns as upmPpd42ns
-
-
- myDustSensor = upmPpd42ns.PPD42NS(8)
-
-
-
-
- def SIGINTHandler(signum, frame):
- raise SystemExit
-
-
- def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-
- atexit.register(exitHandler)
- signal.signal(signal.SIGINT, SIGINTHandler)
-
-
- notice = ("This program will give readings "
- "every 30 seconds until you stop it")
- print notice
-
- while(1):
- data = myDustSensor.getData()
-
- time.sleep(.1)
- print "Low pulse occupancy: " + str(data.lowPulseOccupancy)
- print "Ratio: " + str(data.ratio)
- print "Concentration: " + str(data.concentration)
|