Skip to content

supersjellie/openhab-water-meter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openHAB-water-meter (pulse sensor)

Summary

Setup for using a watermeter in openHAB using a pulsecounter constructed with a Hall-effect proximity sensor. It's made with a few components (can be used independant). A Arduino sketch for the pulsecounting posting results over a serial USB connection. A nodeJS progam that reads this and creates an JSON webservice that openHAB can (optionally) use. Last a thing and widget to make this easier.

example 1

Features

  1. Measures total,current, recent water usage based on one of half liter pulses and (optionally) display it in an openHAB widget (optimized for tiled dashboard)
  2. http://hostname:3002/water
    • Water meter readings in JSON format of total, current flow, last useage and other statistics
  3. http://hostname:3002/total/number
    • Set total water in liters, so 2345 = 2,345 m3.
  4. http://hostname3002/p0/number
    • Set P0 calibration (0-10000). Will set P1 to 10000-P0.
  5. http://hostname3002/p1/number
    • Set P1 calibration (0-10000). Will set P0 to 10000-P1.
  6. http://hostname3002/calibrate
    • Perform (new) calibration of sensor. Make sure a steady waterflow is present.
  7. When set the calibration and total will be kept if system reboots (by using hard drive and/or openHAB)

Worklist

Using the releases in github now Using the issues in github now (I'm not using branches for work in progress (i.e. latest milestone), so download a release for a stable version)

Preperation

  1. Have an openhab installation 😁
  2. Own a water meter with magnetic wheel 😁
  3. Buy and create arduino hardware for pulse counting (check more information link below).
  4. Install nodeJS on your raspberry.
  5. Install in openhab the http binding, see documentation
  6. Install in openhab the jsonpath transformation, see documentation
  7. Install in openHAB the javascript scriping engine, see documentation

More information, check my dutch homepage. English? Google Translate will be your friend.

Flash Arduino Program

  1. Connect the hall proximity sensor to the arduino (manual on my website. English? Google Translation
  2. Assuming you're familiair with Arduino IDE. Copy the watermeter.ino program in the github arduino folder and flash it on the arduino
  3. If not, usefull links to the how-to on previous link.

Deploy nodeJS progam

  1. Assuming you're familair with nodeJS. Copy the water.js program to your program folder.
  2. Change the configurion (top of code) to your need.
  3. USE_DISK will save calibration and total to disk (to keep values on startup/powerloss). File will be watermeter.txt.
  4. OPENHAB (your openHAB server name) will load openHAB total value on startup/powerloss)
  5. PORT is the portnumber the service will use.
  6. Add it to PM2 programs to run and restart at startup (PM2 start water.js)
  7. If you're new to nodeJS. Check the link in preparation to install it. Also install PM2 and check how it is used. A brief summary can also be found on my website. English? Google Translation
  8. If succesfull http://hostname:3002/water will show a JSON string.
  9. The program has an option to double the accurancy. Place the sensor half on the wheel and calibrate it. Check website above.

Create thing

  1. Create a new thing
  2. Choose the HTTP binding
  3. Don't use GUI but move to tab code
  4. Copy and paste the yaml in the thing folder of this project
  5. Save the thing
  6. Don't close it

Create equipment

  1. If it's closed, navigate to your smart_meter thing
  2. Move to the tab 'channels'
  3. Use button 'Add equipment to model
  4. Select all channels and add-on
  5. Openhab will create/add equipment and items

Widget installation

  1. The widget needs 4 images. Copy the images in the github images folder to the html folder in your openHAB configuration.
  2. Add a new widget
  3. Remove default code
  4. Copy and past the yaml in the widget code of this project and save

Widget usage/configuration

  1. Add a new widget to your dashboard/page
  2. Select water_meter from the custom widgets
  3. Set the props (minimal is the item) and save

Versions

  • V1.0 - Initial release on github

Code

The code is pretty standard if you're familair with Arduino IDE and nodeJS. Know that I have plans, that's why some code has no use at this moment.