node-usb232-pir
A Node.js module for CL-USB232-PIR sensor. This module used node-serialport which is awesome module to help communicate with sensor with serial port.
Installation
yarn add node-usb232-pir
Usage
; const PORT_PATH = 'COM6'; // Sensor serial port path. const sensor = PORT_PATH autoRead: true ; sensor;sensor;sensor;sensor;
Options
Name | Type | Description |
---|---|---|
autoRead |
boolean | Automatically opens the port and read sensor data. Default is true . |
customSerialPortModule |
SerialPort |
Custom serial port module. Check out here. |
Events
Name | data | Description |
---|---|---|
open |
- | Called when the sensor's port is opened and ready for writing. |
close |
- | Called when the sensor's port is closed. |
data |
1 or 0 |
Called when the sersor's status changed. If the data returns 1 , the target is near from sensor. And 0 , the target is far. |
error |
Error |
Called when the error occurred. |
Test
yarn run test
License
This is MIT licensed and all it's dependencies are MIT or BSD licensed.