@serialpilot/driver-plantower
v0.1.0
Published
Plantower PM sensor driver for serialpilot — PMS5003, PMS1003, PMS3003 particulate matter readings.
Maintainers
Readme
@serialpilot/driver-plantower
Plantower PM sensor driver for SerialPilot. Reads particulate matter data from PMS5003, PMS1003, and PMS3003 sensors.
Active mode only — the sensor sends readings automatically every ~1 s; the driver listens, frames, parses, and emits typed events. No write API in v0.1.
Install
npm install serialpilot @serialpilot/driver-plantowerQuick start
import { SerialPilot } from 'serialpilot'
import { Plantower } from '@serialpilot/driver-plantower'
const port = new SerialPilot({ path: '/dev/ttyUSB0', baudRate: 9600 })
const sensor = new Plantower({ transport: port })
sensor.on('reading', r => {
console.log(`PM2.5: ${r.pm2_5} μg/m³, PM10: ${r.pm10} μg/m³`)
})
sensor.on('reading-compact', r => {
console.log(`PMS3003 — PM2.5: ${r.pm2_5} μg/m³`)
})
sensor.on('parse-error', e => console.warn('bad frame:', e.reason))
await sensor.open()
await sensor.start()
// later: await sensor.stop(); await sensor.close()Events
| Event | Payload | Notes |
| --- | --- | --- |
| 'reading' | Reading | PMS5003 / PMS1003 13-field frame |
| 'reading-compact' | CompactReading | PMS3003 7-field frame (no atmospheric, no particle counts) |
| 'reading-raw' | RawReading | Every valid frame, regardless of model |
| 'parse-error' | ParseError | Bad start bytes, length mismatch, failed checksum |
| Inherited | 'open' \| 'close' \| 'state' \| 'error' \| 'data' | From Device |
Limitations (v0.1)
- Active mode only. No passive-mode read/sleep/wake commands.
- PMS5003 and PMS1003 are indistinguishable on the wire. Both produce 32-byte frames with the same field layout.
RawReading.modeldefaults to'PMS5003'for 32-byte frames. - No PMS5003ST support. That variant adds an HCHO field; deferred.
- No inter-frame timing. Frames are detected by start bytes + length, which is reliable for single-sensor active mode.
License
MIT
