I have SDS021 air quality sensor. According to data sheet provided by vendor this sensor can be putted into sleep mode to extend it's lifetime.
When used in continious mode it can life up to 8000hrs (approx 1 year).
Here is sensor specs: https://cdn.sparkfun.com/assets/parts/1 ... n-V1.0.pdf
I found this script on the Internet (http://community.onion.io/topic/2020/ai ... ng-station):
Could you advise how to change it to put sensor into sleep?
Code: Select all
import serial import time def hexShow(argv): result = '' hLen = len(argv) for i in xrange(hLen): hvol = ord(argv[i]) hhex = '%02x'%hvol result += hhex+' ' t = serial.Serial('/dev/ttyS1',9600) while True: t.flushInput() time.sleep(1.5) retstr = t.read(10) hexShow(retstr) if len(retstr)==10: if(retstr==b"\xaa" and retstr==b'\xc0'): checksum=0 for i in range(6): checksum=checksum+ord(retstr[2+i]) if checksum%256 == ord(retstr): pm25=ord(retstr)+ord(retstr)*256 pm10=ord(retstr)+ord(retstr)*256 print "pm2.5:%.1f pm10 %.1f"%(pm25/10.0,pm10/10.0)
Moreover this script provides new measurement each second. I would like to have one measurement per run of the script and put this script into cron to run hourly. And when sensor is not used put it into sleep.