Giter Club home page Giter Club logo

sds011's Introduction

sds011

This module is a Python3 based client for the sds011 fine dust (smog) sensor. The sds011 is a cheap sensor from Nova Fitness Co., Ltd. capable to measure pm2.5 and pm10 particle density in the air. See the Spec Sheet for further info.

some things to know about the sensor

  • It is active fan and takes about 100mA when the fan is running.
  • The critical component is the laser diode inside which has a lifetime of a few 1000 hours, so if using the sensor for permanent measurements, it will not last a year. Setting the working period to about 5 minutes is a decent choice for granularity and lifetime.
  • The sensor usually comes with a chinese CH341 USB2.0 serial adapter which is not a problem for linux systems but for windows and mac as the drivers sometimes are hard to get. In case you're planning to use the sensor on windows, get an FTDI USB to 5V-TTL converter cable.
  • The sensor has 2 basic modes of operation "active" and "query". Only "active" mode has been tested. The low level commands for "query" are implemented but untested. In active mode the sensor makes a measurement every working period and sends that measurement. This leads to the behaviour that the sensor does not necessarily start measure after the object is generated. It stays in it's working period.

basic gui

A PyQt5 APP provides basic sensor information and a plot function.

python3 sds011_pyqt5app.pyw

or running the script as executable

SDS011Plot

how to use the module

define a serial port usually a "ttyUSB" or a "com" port

port = "/dev/ttyUSB0"

make an instance of the SDS011 class

sds = SDS011(port=port)

get some info on the sensor to check if it's working fine

print(sds)

set a working period for the sensor

sds.set_working_period(rate=5)

get a dictionary with the keys "timestamp","pm2.5","pm10","devid" from the measurement queue

meas = sds.read_measurement()

This is a blocking function, so it waits until a measurement is received from the sensor, which can take some time depending on the working period.

getting values by socket

If the module is called with socket option,

sds = SDS011(port=port,use_socket=True,socket_portnum=9999)

it will open a socket on localhost and the given port which defaults to 9999. You can check the output via netcat

nc localhost 9999

which outputs timestamp, pm2.5, pm10, device id

2018-06-02 10:36:04.980272,33.5,53.6,43897
2018-06-02 10:41:04.981235,39.5,145.3,43897
2018-06-02 10:54:14.573174,29.5,61.4,43897

database option

If the module is called with database option,

sds = SDS011(port=port,use_database=True)

it will write values to an sqlite database.

sds011's People

Contributors

menschel avatar erriez avatar int-ua avatar

Watchers

 avatar

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.