Code Monkey home page Code Monkey logo

py-sds011's People

Contributors

ikalchev avatar rsp2k avatar sieste avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py-sds011's Issues

Index Error in _get_reply routine

I have your code running on a Raspberry Pi. And for the most part it is working, but occasionally I get an IndexError that kills the program.

The problem occurs in the _get_reply(self) function on this line of the sds011.py file:

 if (sum(d for d in data) & 255 !+ raw[8]:
      return None

What I see on the console is as follows:

Traceback (most recent call last):
File "./Combo_ATH_AIO_Web_Thingspeak.py", line 141, in
pmt_2_5, pmt_10 = get_data()
File "./Combo_ATH_AIO_Web_Thingspeak.py", line 97, in get_data
AQISENSOR.sleep(sleep=False)
File "/home/pi/Combo-AIO-Web-Thingspeak/sds011.py", line 113, in sleep
self._get_reply()
File "/home/pi/Combo-AOI-Web-Thingspeak/sds011.py", line 57, in _get_reply
if (sum(d for d in data) & 255 != raw[8];
IndexError: index out of range

I'm not proficient enough with Python to see what the problem is here, so hoping you (or someone else) can help me with this.

Regards,

rgmcleod52

Physical unit

>>> sensor.query()
(0.8, 0.9)

What physical unit do I see in this output?

Set sensor sleep time?

Is there a way to set sensor sleep time? I set sleep = 10 in config.txt, but this value doesnt effect sensor sleep time.
My sensor always sleeps for minute and 30s, even if I don't open python app. I would like sensor to wake up every 10 minutes.

Initialize fails when device in sleep mode

I created the following test program:

#!/usr/bin/python3
import sds011
import time
sensor = sds011.SDS011( "/dev/ttyUSB2", use_query_mode=True )
sensor.sleep( sleep=False )
time.sleep( 15 )
pm25, pm10 = sensor.query()
sensor.sleep()
print( "PM2.5: %6.1f" % pm25 )
print( "PM10: %6.1f" % pm10 )

The first time after connecting the sensor it works, but after that when the sensor is in the sleep mode i get the following exception:

Traceback (most recent call last):
File "./readout.py", line 10, in
sensor = sds011.SDS011( "/dev/ttyUSB2", use_query_mode=True )
File "/home/mf/python/sensors/sds011/sds011/init.py", line 44, in init
self.set_report_mode(active=not use_query_mode)
File "/home/mf/python/sensors/sds011/sds011/init.py", line 76, in set_report_mode
self._get_reply()
File "/home/mf/python/sensors/sds011/sds011/init.py", line 55, in _get_reply
if (sum(d for d in data) & 255) != raw[8]:
IndexError: index out of range

To get it working I added a check for reply length in function _get_reply() near line 171:
if len(data) == 0:
return None

I assume there is a timeout and that's the reason that 0 bytes are received. I did not check if more changes are needed to make it work properly, it seems to work fine with this change alone.

how can I check if sensor is in sleep mode?

Hello,

how can I check if sensor is in sleep mode?

I am trying

sensor.sleep(sleep=True)
print (sensor.sleep(read=True))
sensor.sleep()
print (sensor.sleep(read=True))

but this won't work as expected.
I am getting two times

None
None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.