Skip to content

Installation and Setup

J-Pipe edited this page Jul 25, 2021 · 11 revisions

Hardware

Water Meter

I purchased my water meter online from EKM Metering. The water meter is basically a standard analog water meter, but it is also equipped with a hall-effect sensor, which acts like an electronic switch turning on/off when the flow dials are spinning. I purchased this one for $140, which is their "High Definition" meter. This meter will send a "pulse" every .075 gallons of water that flows through it. It does not require batteries or any power like some other smart flow meters. They also have a "non-HD" meter for $75, but it only sends a pulse after every .75 gallons so the I don’t think you could calculate the flow rate in a useful manner, since the pulses would be sent 4-10 minutes apart (vs 0.5-60 seconds with the HD one). Verify the size of your water supply line (most residential lines will be 3/4") and also the orientation that you will need to mount it (vertical or horizontal) before ordering, as you will need to buy a meter specific to your layout.

ESP8266/ESP32

I bought these but you can use any ESP based device. This is used to monitor the pulses from the water meter and calculate the rate of flow and gallons used, appropriately.

Hardware Installation

You have to do a little bit of basic plumbing to install the water meter. You can call a plumber or DIY. First, figure out where you will install it. Ideally, try to install it just after the city water meter. Just make sure that all your water (including your sprinklers) will travel through it.

Water Main Shutoff Valve

Before cutting any pipes, be sure to turn off your water valve from the street and the one going into your house. You'll need a PVC pipe cutter to cut the water supply line. My water line is polyethylene and I was able to find some PVC compression fittings and some brass couplings to attach my new water meter.

Installed Meter

I installed an irrigation box and some electrical conduit to run the wires through

Conduit

There are three wires coming off the water meter. You only need two. Doesn't matter which ones you use. I used the red and black wires.

Inside

To run the wire inside, I cutout a hole for the junction box (which houses the ESP) near an outlet (be careful not to cut into an electrical) and then drilled a small hole through the brick with a mason bit on a drill bit extender. Connect wires to the ESP by crimping on some female jumper wires. Connect the red wire to Pin 5 of the ESP and the other one to Ground.

Inside

I installed a brush plate to run the power cable to the ESP8266.

Software Config

I'm not going to get into setting up ESPHome here. Read the documentation to learn how to flash ESPHome and get it discovered in Home Assistant. I do recommend naming your esp "water_flow" when integrating it with Home Assistant so that there are minimal changes you need to make to my code. ESPHome has a pulse counter component, but I could not get it work properly, so I created my own custom Water Flow component. Copy the water_flow.yaml code to the esp configuration and the water_flow.h file to the \esphome\YOUR_WATER_FLOW_ESP\src\ directory. The water_flow.h file has some "User Specific Settings" that can be adjusted to meet the requirements of your setup. Compile and upload the config and this will expose a "Total Water Used" sensor, a "Water Flow Rate" sensor, and a "Water Running" sensor. Hopefully these will now update when water is running in your house.

Extra Notes

The esp config also exposes two services to Home Assistant. One called "esphome.water_flow_set_total_water_used" with "value" as the data. It can be used to change the "total_water_used" value that the sensor is outputting. This is useful if you want to reset the gallons count back to zero at the start of your billing period. The other service is called "esphome.water_flow_power_cycle_restore." This should be used to restore the "total_water_used" if the ESP ever loses power. You should setup an automation to trigger when the "sensor.total_water_used" is "unknown" and call the "esphome.water_flow_power_cycle_restore" service. Maybe someone who is smarter than me can figure out how to reset the variable in an on_boot automation on the ESP. I could not find a clean way to do it.

For calculating the current running cost of your water bill and days left in cycle, reference the template sensors I created in the Home Assistant yaml. You will need to update them to work for your specific billing rates. You should be able to find all that info on your city's website.

For Node Red automations, I am including two of my flows that you can reference in the flow.json file

One thing to note is that after I installed my meter it was sometimes detecting a slow flow when no water was running. This was because of all the air that was in my water lines. So this might happen till you get all the air out. Maybe after a day or so.