Posts: 3
Joined: Sat Oct 27, 2012 9:20 pm

SDS021 sleep/wake with python

Tue Dec 12, 2017 10:59 pm


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):

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:
   retstr = t.read(10)
   if len(retstr)==10:
       if(retstr[0]==b"\xaa" and retstr[1]==b'\xc0'):
           for i in range(6):
           if checksum%256 == ord(retstr[8]):
               print "pm2.5:%.1f pm10 %.1f"%(pm25/10.0,pm10/10.0)
Could you advise how to change it to put sensor into sleep?
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.

User avatar
Posts: 692
Joined: Tue Aug 01, 2017 10:06 am

Re: SDS021 sleep/wake with python

Wed Dec 13, 2017 7:32 am

With a bit of googling and the links that you posted I can't find any info on how this can be done. It does say that it has a sleep mode but nothing tells you how to use it.

User avatar
Posts: 485
Joined: Wed Dec 31, 2014 8:21 am
Location: Netherlands

Re: SDS021 sleep/wake with python

Wed Dec 13, 2017 11:51 am

I hope to receive my SDS021 soon, I am surprised the datasheet does not mention how to go to sleep mode.

Maybe is the same as the SDS011 sensor for which I found this datasheet:

https://www.google.nl/url?sa=t&rct=j&q= ... rzNFCotsDz

Posts: 3
Joined: Sat Oct 27, 2012 9:20 pm

Re: SDS021 sleep/wake with python

Thu Dec 14, 2017 1:17 am

Found this script for SDS011:


Sleeps/wakes SDS021.
But sometimes (after 2nd or 3rd run) it restarts the Pi. :(

Return to “Python”