Introduction: Water Meter Automation

Picture of Water Meter Automation

Have you got some water meters at your home? Probably you have. How do you like to check them every month? I do not like this process because my water meters are installed in tiny dark place under the kitchen sink. Usually you should use some kind of inspection light or torch to be able to see the water meter's values. Fortunately, my water meters have the pair of wire allowing to read the data remotely. The principle is very simple: each water meter has the reed switch inside which is short when the last digit goes through 0 to 3 and is "open" otherwise. This kind of water meter can be connected to the simple controller to count the amount of the water that have gone through the tube.

For convenience, it would be nice to see the water meter data through the Internet by using web server or Blynk and receive the e-mail notifications periodically. For this we can use esp8266 IOT controller!

In this guide we will build the two layer automation system: first layer is a battery powered controller that counts the water usage and the second layer is a IOT controller witch receives the messages from layer one controller and interacts with a user via web, Blynk and e-mail.

The project is based on arduino IDE, esp8266 micro controller and atmega328p-pu micro controller.

Step 1: Layer One. Water Meter Counter.

Picture of Layer One. Water Meter Counter.

The esp8266 controller is not very power efficient and cannot run on the batteries for long time. And we would like to use it as web server any time, so it must be powered by the external power supply. It is not good idea to connect the water meter directly to the esp8266 controller because usually the water meters are installed in the dark, tiny space without any access to the external power outlet and WiFi access.

The water meter controller can be placed near the water meters, for example under the kitchen sink, and powered by two AA batteries. This controller just counts the water passed through the water meter and periodically sends this data via the radio channel to the central IOT module (esp8266). The controller supports two water meters for hot and cold water. The data is sent by means of the packet that contain the following fields:

  • Uniq ID of the controller (hard coded in th the controller sketch).
  • Counter data for the hot water.
  • Counter data for the cold water.
  • Internal battery voltage in mV.

The controller is built on atmega328p-pu chip powered by two AA batteries and wireless transmitter si4432. You should program the atmega328p-pu micro controller to run at 1 MHZ and setup the minimum startup voltage 1.8 volts. There are a lot of instructables in the Internet about how to program fuses of this micro controller.

As to the wireless transmitter module, I have started with nrf2401 because it is widely used in the home automation projects. Unfortunately, in my concrete house the signal from this module was too weak to work properly. So, another, long-distance controller was selected for this project, si4432. This controller proves excellent signal quality and rich set of features.Surely, I can recommend it.

There is some hint that simplifies soldering of this radio module. The si4432 module have very small connector (1mm step). To simplify soldering or prototyping projects with this module on the breadboard, you can buy sop16/ssop16 adapter (see the photo) and cut if half by the metal-cut scissors. Actually we need just 8 pins to connect the module to the arduino controller.

Step 2: Layer 2. the IOT Controller.

Picture of Layer 2. the IOT Controller.

This module used to provide user friendly interface to all water meter data installed in your home. It receives the signal from one or several water meter controllers described in the previous step and presents this information to the user by means of set of interfaces: through internal WEB server, via Blynk or via e-mail notification. As you can see on the photo, this module is relatively small and can be placed inside old power adapter case. Then you can just plug this 'adapter' to the outlet.

The main component of this module is esp8266 micro controller. You can choose any available variant with at least 1MB of flash memory: esp-07, esp-12e, esp-12f, nodeMCU-0.9 or wemos. In the photo you can see the esp-07 variant. You should configure this module to use SPIFFS file system with space at least of 512kB. If you use exp12-e module or so, use 3 MB SPIFFS. The controller uses this space to store the configuration information and data log of the water meters.

If you use stand alone variant like i did, you probably should buy the adapter like shown in the photo. Note that there are three resistors already installed on the adapter and you should duplicate them. To communicate the controller you can use USB-to-Serial adapter? f like cp2102.

The radio module, si4432, is connected to the esp controller using SPI interface (see the schematics later on).

The module has one external led that used to show the current ruining status of the module.

Step 3: Blynk Setup.

Picture of Blynk Setup.

To publish water meter data in the Blynk cloud service you should create your account on blynk site and create new authentication key for this project. This key should be entered into the IOT module through the WEB setup form.

Then you should create the Blynk items for your project as described bellow. All the elements are 'connected' to the virtual pins of the esp micro controller. And all of them, expect the first one, are just a text fields.

  • V0: The menu item and name 'select the controller' or so. This element allows you to chose the water meter controller from the list of the available controllers in your home.
  • V1: The text item and name 'Serial number'. Here you will see the serial number of the water meter of cold water.
  • V2: The text item and name 'WM data'. Is used to display current data of cold water counter.
  • V3: The text item and name 'next inspection' Displays the date of the next inspection date of the water meter. Usually the water meter should be checked every 4-6 years.
  • V4: The text item and name 'Serial number'. Here you will see the serial number of the water meter of hot water.
  • V5: The text item and name 'WM data'. Is used to display current data of hot water counter.
  • V3: The text item and name 'next inspection' Displays the date of the next inspection date of the water meter.

The list of the menu element will be updated automatically from the main module.

Step 4: The IOT Controller Modes.

To achieve a stable production of the main module in case of Blynk or WiFi network failure, several working modes implemented:

  • Main mode: The controller is connected to WiFi and to the Blynk cloud service;
  • The module is trying to connect to WiFi network;
  • The module successfully connected to WiFi and is trying to connect to Blynk cloud;
  • The module is running Access Point mode for initial setup.

The led indicates the current running mode of the module:

  • Blinks every 5 seconds in main mode;
  • Blinks every 10 second while trying to connect to the WiFi;
  • Double blinks every 10 seconds while trying to connect to the Blynk;
  • Blinks twice every second in Access point mode;

When the module starts, it tries to load the configuration file from SPIFFS, if the configuration does not exist or WiFi ssid is not defined, the module switches to the Access Point mode and waits for the main setup parameters: wifi ssid, password and so on. In this mode you can connect to the module using WiFi ssid 'esp8266-wm' and typing '192.168.4.1' in the address field of your browser. The main setup page will be displayed. After all the parameters would be entered into the setup page, you should power-cycle the module.

If the module failed to connect to WiFi in 5 minutes after start, it again switched to the Access Point mode for initial setup. If the module have successfully connected to the WiFi it would never goes to the Access Point mode even after long period of WiFi inactivity. The module would be trying to reconnect to the WiFi network forever.

In the main running mode the module is running the WEB server showing the water meter data, updates the data in the Blynk cloud service and periodically sends e-mail alerts to the configured e-mail address. In case of Blynk connection failure, it tries to reconnect to Blynk cloud. The WEB and e-mail services are continue to work. In case of WiFi connection failure, the module tries to restore the network connection.

Step 5: The WEB Interface: Setup

Picture of The WEB Interface: Setup

The setup page is the first one you should visit. This page is available as a root document in the Access Point mode and can be examined in the main WEB mode through the upper menu by selecting 'setup' item.

In the setup page you can enter the flowing parameters:

  • wifi ssid
  • wifi password
  • blynk auth key
  • ntp server name
  • Greenwich time difference in minutes

ntp server is used to determine the current time and date. The module does not have internal clock. When the data received from the Water Meter controller (layer 1) it accomplished with the time stamp. This allows to check the communication with the layer1 controller. Also the time stamp is written to the log data file.

Step 6: The WEB Interface: Main Screen

Picture of The WEB Interface: Main Screen

The main scree shows the water meter data. It formatted into the table which has the following columns:

  • The water meter controller location. You can connect to the main module up to 4 controllers without the code modification;
  • The serial number of the water meter;
  • The current data of the water meter;
  • The next inspection date of the water meter;
  • The voltage of the Water meter controller battery;

The layer2 module receives the message from the layer1 module(s) and shows the information on the main page. Each layer1 controller has uniq ID witch is displayed on the controller setup page. You can setup the name (or location) of each controller. This name could be convenient one like a 'kitchen' or 'bath room' and the layer2 controller saves it into the SPIFFS file system. You can change the controller name as you like. If the layer2 module 'does not know' the name of the layer1 controller, the controller ID would be displayed in the table.

You should define configuration data for each layer1 controller by 'clicking' on the controller ID or its name in the table or use corresponding menu item.

Step 7: The WEB Interface: Layer1 Controller Setup

Picture of The WEB Interface: Layer1 Controller Setup

This page allows you to define the configuration of the water meters in the layer1 controller:

  • The controller name or location
  • Water meter serial numbers (both hot and cold water)
  • Water meter next inspection date
  • Water meter current data
  • The fraction size

The controller name is used for your convenience to remember the layer1 controller in case you have several layer1 controllers. The name can be up to 32 symbols.

Each water meter has uniq serial number which must be written in the form. This number will be shown in the main page, Blynk application and e-mail notifications.

Next inspection date is useful to send warning and alert e-mail messages to inform you about the date when the water meter should be inspected.

The controller counters the amount of water through the water meter, it could not know the current value on the water meter. You must specify the actual data of each water meter only once. The layer2 controller saves in the configuration the starting data value of each water meter then it calculates the actual water meter data accordingly.

The fraction size determines how many decimal digits are meaningful after the cubic meters. The water meter of the first picture has three decimal digits after integer part. But the controller cannot count the last digit. Remember, the switch is short whel the las digit is going through 0 to 3. In this example, the fraction size is 2.

Step 8: The WEB Interface: E-mail Notofications.

Picture of The WEB Interface: E-mail Notofications.

The layer2 controller supports sending e-mail notifications. You have to configure the relay server that will be used to send e-mail messages, source and destination e-mail addresses. Also, you can configure the period of the regular e-mail notification of current data of the water meter. The parameter 'send at' is validated depending on the period:

  • the hour of the daily notification
  • the weekday for every week notification
  • the day of month for every month notification

This version of the software support open relay server configuration only.

Step 9: The Component List.

Picture of The Component List.

Here is the hardware component list to build the project.

layer1 controller

  • atmega328p-pu microcontroller
  • si4432 radio module
  • SOP16/SSOP16 to DIP16 converter board (used for two modules)
  • resistor 220 Ohm
  • resistor 10 kOhm
  • resistor 1 MOhm - 2 pcs
  • ceramic capaticor 100n - 4 pcs
  • capacitor 10 uF
  • AA battery case
  • pin headers

layer2 controller

  • esp8266-07
  • controller board
  • si4432 radio module
  • SOP16/SSOP16 to DIP16 converter board
  • resistor 220 Ohm
  • resistor 1 kOhm
  • resistor 10 kOhm
  • ceramic capatitor 100n - 2 pcs
  • capaitor 1000 uF
  • capacitor 10 uF
  • general purpose bipolar npn transistor, 2n2222 or analog
  • ams1117-3.3 voltage regulator
  • AC-DC 5v power supply

The source of both modules available in the git hub repository.

Step 10: Conclusion.

The project describes the automation system that simplifies procedure of home water meter accounting. The water meter data is available through the web interface and blynk. This allow you to monitor your water meters remotely. Also, the e-mail notifications are implemented about current status of the water meter and about the time of the next inspection.

The project uses the brilliant software library written for esp8266 micro controller that supports WiFi connectivity and web server requests. I believe that esp8266 and arduino IDE integration provides the great platform for many interesting projects.

Comments

pgs070947 (author)2017-11-15

You are lucky to have a meter with some sort of pulse output. A bit of a rarity in the UK unless you install one of your own as a secondary meter.

I've done just the same as you, but had to resort to fitting a Hall sensor to pick up the little magnet that usually is fitted on the last dial.

I think it's a sensible thing to do and I've got all mine connected up (gas, water, electricity). I used XBees as they are very easy to network and Digi's software to set up is the best I've seen.

Far better to get the readings onto a PC than grovel around in a 3-feet deep mud filled hole in the pavement.

For what it's worth, all UK meters have to be at least 3-feet deep to protect from frost and I don't think metal covers affect the range too much. You can always use a local radio link using 433-MHz to get it out of the ground then onto your 2.4-GHz network.

One of the real benefits is being able to see if anything weird is going on like gas or water leaks. And I've heard tales of new "smart" meters being installed where the dials go round but no electronic readout or vice versa.

Mark 42 (author)2017-11-13

Why would a person need to read a water meter?
Our utility company reads them and sends us a bill.
I suppose if you don't trust the utility company, you might want your own meter so you can check on their numbers - but arguing with them if they are wrong is probably futile anyway.

pgs070947 (author)Mark 422017-11-15

Depends

If your meter has a nice long underground pipe to the house, the first you are going to know about a leak is when you get a large bill for thousands of dollars/euros etc

As more "smart" meters get installed with radio links only, would you believe it?

The smart thing to do is take your own readings

diy_bloke (author)2017-11-12

Very interesting, but I lost you somehere in Step 1. You say the watermeter is no place for an ESP8266 because it is ofthen in dark remote places, so you come up with another device that you place 'near the water meter' like 'under the kitchen sink'.
Is the cord from yr water meter going all the way to the kitchen sink?
Perhaps I just have a complete wrong image about watermeter placement. Where I live in 99% of cases they are in a hole in the ground, usyally right behind the front door (indeed, the exact place where you'd want to have a hole)

UncleEd (author)diy_bloke2017-11-13

I live in the USA and the places I have lived usually have only one water meter for a home. It is usually somewhere near the edge of the property some distance below ground level to protect it from freezing. There is a cast iron cover over it that can be removed easily so the person reading the meter can get to it easily. Having separate meters inside the house is a new idea to me.

diy_bloke (author)UncleEd2017-11-14

indeed, new to me too

sfrwmaker (author)UncleEd2017-11-13

Hello!

I am not sure that radio module will work correctly in such place: underground and covered by metal cover. You should chevk the radio channel first.

sfrwmaker (author)diy_bloke2017-11-13

hello.

The layer1 controller based on arduino (atmega328p-pu) is connected by wires to the both mater meters (cold and hit water). This controller is powered by the batteries that allowing to place near the water meters without any external power outlets. The layer1 module uses radio channel to send water meter counts to the main unit, layer2 controller.

ЕвгенийС37 (author)2017-11-10

а если стоит магнит?

В каком смысле магнит? Каков принцип работы счетчика с магнитом?

принцип работы такой - стоит магнит, вода идет через счетчик, а показания не меняются

А на кой Вам тогда сабж и тратить время на чтение, если стоит магнит? :-)

JeffM15 (author)2017-11-13

Very Nice.

DmitriyU2 (author)2017-11-13

nice job! I liked layer2 module inside the old power supply unit most :)

Missed what flashed to esp8266 and layer1 sketch?

sfrwmaker (author)DmitriyU22017-11-13

The source code in the github repository, https://github.com/sfrwmaker/WaterMeter, this link you can find on step 9.

string2004 (author)2017-11-10

хорошая работа!
А есть где-нибудь русская версия текста?
очень хотелось бы исключить ошибки перевода...

sfrwmaker (author)string20042017-11-10

hello.

I would like to ask you use english. It is not polite for other visitors to speak russian here. They could think that we are some kind of spies. :)

There is no russian version awailable in the Internet because i could not find a site to publish the project. The only one is a forum on arduino.ru, but it is very unconvenient to publish project in the forum.

If you like, can contact me directly. Also i have russian version of the sketch if you do like.

steveastrouk (author)sfrwmaker2017-11-12

How does a Cyrillic writer write code on Arduino ? Do you still have to use the latin keyboard for the Arduino code, and Cyrillic for the comments ?

sfrwmaker (author)steveastrouk2017-11-12

Hello!

You kidding me, right? The most problem are bears walking around... :)

steveastrouk (author)sfrwmaker2017-11-12

Meh, I have bears wandering through my yard.

Seriously, I've never seen source code written on non-latin systems, so I was curious.

sfrwmaker (author)steveastrouk2017-11-12

It easy to use multiple languages on the keyboard, we just use the shortcut key combinations like <ctrl+shift> to shift keyboard. There are just 33 cyrillic symbols in Russian alphabet. Today, all operating systems have multilangual support and utf-8 encoding.

steveastrouk (author)sfrwmaker2017-11-12

So is the code in Cyrillic or Latin ?

DmitriyU2 (author)steveastrouk2017-11-13

sketch coded using arduino language. there no russian version of it, thanks god :)

But we have local systems like 1C:ERP - it's very popular now in Russia, and it has internal development engine based on the cyrylic alphabet and Russian words.

[code]Процедура ЗдравствуйМир()
Сообщить("Здравствуй, Мир!");
КонецПроцедуры

[/code]

Also we had RAPIRA for old 80s machines (https://en.wikipedia.org/wiki/Rapira)

Naevus (author)string20042017-11-12

Do you need only THIS project? Or similar, having similar functionality? if the second, then look at wifi-iot.com

ВладиславБ5 (author)2017-11-12

Oh, now I make a similar project on Wemos

ZeipiT (author)2017-11-12

Excellent instruction.

sfonseca (author)2017-11-12

Nice work.. thanks for taking the time to post..

jseager64 (author)2017-11-12

Nice project. Reading it left me pondering how I could incorporate the meter with my aquaponics greenhouse. My unresolved mental image of where I could locate it then left me thinking, "Can I reset the meter back to zero each day"? This would come in handy timing my pumps turning on and off.

akiraly (author)2017-11-12

Exelent solution!

I made it with an IP Camera.

Greatings

tcs79 (author)2017-11-12

Excellent project!

About This Instructable

13,734views

113favorites

More by sfrwmaker:Water Meter AutomationAttiny85 Wireless Weather Sensor5 minutes Christmas neopixel led strip
Add instructable to: