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.
Features
- 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)
- http://hostname:3002/water
- Water meter readings in JSON format of total, current flow, last useage and other statistics
- http://hostname:3002/total/number
- Set total water in liters, so 2345 = 2,345 m3.
- http://hostname3002/p0/number
- Set P0 calibration (0-10000). Will set P1 to 10000-P0.
- http://hostname3002/p1/number
- Set P1 calibration (0-10000). Will set P0 to 10000-P1.
- http://hostname3002/calibrate
- Perform (new) calibration of sensor. Make sure a steady waterflow is present.
- When set the calibration and total will be kept if system reboots (by using hard drive and/or openHAB)
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)
- Have an openhab installation 😁
- Own a water meter with magnetic wheel 😁
- Buy and create arduino hardware for pulse counting (check more information link below).
- Install nodeJS on your raspberry.
- Install in openhab the http binding, see documentation
- Install in openhab the jsonpath transformation, see documentation
- Install in openHAB the javascript scriping engine, see documentation
More information, check my dutch homepage. English? Google Translate will be your friend.
- Connect the hall proximity sensor to the arduino (manual on my website. English? Google Translation
- Assuming you're familiair with Arduino IDE. Copy the watermeter.ino program in the github arduino folder and flash it on the arduino
- If not, usefull links to the how-to on previous link.
- Assuming you're familair with nodeJS. Copy the water.js program to your program folder.
- Change the configurion (top of code) to your need.
- USE_DISK will save calibration and total to disk (to keep values on startup/powerloss). File will be watermeter.txt.
- OPENHAB (your openHAB server name) will load openHAB total value on startup/powerloss)
- PORT is the portnumber the service will use.
- Add it to PM2 programs to run and restart at startup (PM2 start water.js)
- 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
- If succesfull http://hostname:3002/water will show a JSON string.
- The program has an option to double the accurancy. Place the sensor half on the wheel and calibrate it. Check website above.
- Create a new thing
- Choose the HTTP binding
- Don't use GUI but move to tab code
- Copy and paste the yaml in the thing folder of this project
- Save the thing
- Don't close it
- If it's closed, navigate to your smart_meter thing
- Move to the tab 'channels'
- Use button 'Add equipment to model
- Select all channels and add-on
- Openhab will create/add equipment and items
- The widget needs 4 images. Copy the images in the github images folder to the html folder in your openHAB configuration.
- Add a new widget
- Remove default code
- Copy and past the yaml in the widget code of this project and save
- Add a new widget to your dashboard/page
- Select water_meter from the custom widgets
- Set the props (minimal is the item) and save
- V1.0 - Initial release on github
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.