node package manager

water-flow-sensor

Water flow sensor

Get flow rate and volume consumption from water flow sensors

Features

  • 🔌 Initialize sensor on GPIO pin
  • 🚛 Set the sensor model
  • 🚿 Flow detection
  • 💧 Get flow rate (L/m)
  • 🍼 Get volume consumption (L)

Install

cd <project-folder>
$ npm install water-flow-sensor --save

Usage

  1. Require water-flow-sensor module
  2. Initialize sensor with pin and model values and a callback
  3. The callback gives (when flow start/stop)
    • res.pin: sensor pin
    • res.model: sensor model
    • res.isRunning: whether the sensor is running or not
    • res.flow: instant flow rate in L/min
    • res.volume: volume in L
  4. Get status, as well as flow and volume data anytime
// Initialize the sensor 
var wfs     = require('water-flow-sensor')
  , sensor  = new wfs(17, 'POW110D3B', wfsCb)
 
// Callback 
function wfsCb(res) {
  console.info(`${res.pin} | ${res.model} | ${res.flow} L/m | ${res.volume} L | ${res.pulses}`)
}
 
// Access to status and data 
console.info(`Sensor is running: ${sensor.isRunning}`)
console.info(`Flow rate: ${sensor.flow} L/min`)
console.info(`Volume: ${sensor.volume} L`)

Contributing

Please read the Code of Conduct.

Technical details

Water flow sensor models

Platforms

Developed on Rapsberry Pi model B

Dependencies

  • onoff ^1.1.2