1.0.0 • Published 5 years ago

air-pollution-sensor-client-lib v1.0.0

Weekly downloads
-
License
beerware
Repository
-
Last release
5 years ago

TODO

  • all events callbacks should be streams or events emitters/Rx cause now we can attach only one action to each event
  • remove RTC?
  • remove /bin from import (copy bin files level up during publishing?)

SDS018.Client.Lib

It is a client for a SDS018 Air quality sensor in a form of library.
It is distributed as a node package with TypeScript types definitions.
Socket connector included.

Install

npm i sds018-client-lib

Import

import { SDS018Sensor, SDS018Socketconnector} from 'sds018-client-lib/bin'; // TODO: remove /bin

Usage

const connectionString = "http://192.168.1.100:3005";
const sensorConnector: ISensorConnector = new SDS018SocketConnector(connectionString);
const sensor: Sensor = new Sensor(sensorConnector);

sensor.OnChange((pm25, pm10) =>
{
    console.log('pm10:', pm10);
});

Connectors

Connector is a class implementing ISensorConnector interface.
It's destiny is communication with sensor host (daemon) located somewhere in the network.

How to run example?

Connect sensor to PC (or some kind of computer like Raspberry Pi) via USB or Serial Port. Determine it's port.
Start sensor's Daemon with appropriate params (host port and usb/serial port).
You are ready now to start sensor client.

Start sample app with node bin/TestApps/sample.app.js.

Publishing

  • Update version in package.json
  • npm publish