DIY Water Flow Meter: A Step-by-Step Guide

To not miss my updates, remember to check the public account in the upper right corner and set it as a star, and give me a star!

DIY Water Flow Meter: A Step-by-Step Guide
DIY Water Flow Meter: A Step-by-Step Guide
Do you know what percentage of the Earth’s freshwater resources are available globally?It is estimated that by 2025, 3 billion people worldwide will face water shortages.Starting now, let’s save water from ourselves. Actions speak louder than words, today I will share with you a water flow meter that reads water usage in real time.
The hardware used for the flow meter is very common and easy to purchase: water flow sensor, Arduino Nano board, boost module, lithium battery charging module, waterproof switch and button, M3 screws, nuts, and brackets, USB cable, lithium battery.

Now let me teach you step by step how to make it:

Step One

Waterproofing

The water flow meter is used in the bathroom to monitor the water used for showering, so the most difficult part is to make the entire product waterproof.

DIY Water Flow Meter: A Step-by-Step Guide

There are two waterproofing options:design a custom 3D printed shell or try to fit it into a ready-made case. Here we share the option of making a custom 3D shell.If you can’t use a 3D printer, there are also some ready-made waterproof enclosures. Since I haven’t tested them, remember to do a test after purchasing these waterproof enclosures.
Here are two links where you can purchase:
https://www.banggood.com/custlink/DKGK9dlZJ2

https://www.digikey.ca/product-detail/en/bud-industries/PTK-18422-C/377-2758-ND/8602492

Step Two

Printing the Shell

This design isdrawn using Fusion 360for the shell. It has three circular cutouts to accommodate two3.5mm female ports and onetoggle switch.The lid has a 16mm hole for an instant button, a rectangular cutout for the screen, and four mounting holes to secure the screen in place.The lid is a separate part and has a lip to prevent moisture from entering through the seams.The four holes at the corners of the box are used to secure the lid with 30mm brackets.All screw holes have a diameter of 3mm, suitable for M3 screws.

DIY Water Flow Meter: A Step-by-Step Guide

To make the screen visible, it can either extend out of the cutout on the shell cover or be placed behind the cutout and then add a layer of transparent material.Since the screen should not be exposed to a humid environment, we choose to use the second method.
DIY Water Flow Meter: A Step-by-Step Guide

Darwin custom sweatshirt, sister Ni’s universal multimeter, click to draw!

However, 3D printing currently cannot produce transparent materials, so we must innovate.The solution is to make a rectangular cutout on the lid and glue a piece of transparent plastic (the kind used for fruit boxes, just cut a piece off) with strong glue on the inside of the corresponding part of the shell, making sure to trim it appropriately so it doesn’t block the mounting holes.
DIY Water Flow Meter: A Step-by-Step Guide

Step Three

Install the LCD Screen and Buttons

The LCD uses I2C for communication, which saves Arduino’s IO resources. The black board behind the LCD is used for I2C communication.
Use four 10mm copper pillars to secure the screen. The LCD display faces outward, and the 16-pin header on the LCD should be at the top – make sure not to install the LCD upside down!

DIY Water Flow Meter: A Step-by-Step Guide

This project also requires buttons to implement some functions, so a chrome button is used. The button is waterproof and has a rubber ring to prevent moisture from entering the shell through the threads.
DIY Water Flow Meter: A Step-by-Step Guide

Step Four

Power Supply and Charging Circuit

Now, assemble the battery power components:batteries, main switch, battery monitoring/charging board, and boost converter.

DIY Water Flow Meter: A Step-by-Step Guide

The battery used for the flow meter is a 3.7V 1500 mAh single-cell lithium-ion battery; any single-cell lithium-ion or lithium polymer battery that fits inside the shell can be used.
First, solder the battery to the TP4056 charging board. If necessary, you can solder a JST RCY connector (available on Taobao) to the battery and charger for convenience, but this is not required. The circuit board does not have protection against battery reverse connection, soyou needto ensure to follow the correct polarity indicated on the charger board.

DIY Water Flow Meter: A Step-by-Step Guide

Since the flow meter uses Arduino, both the LCD screen and the flow sensor require 5V, so the output of the boost converter must be set to 5V.

DIY Water Flow Meter: A Step-by-Step Guide

Since the custom shell is fixed with a few screws, and I don’t want to open the shell every time I need to charge it, I use a 3.5mm headphone jack.

Step Five

Charging Cable

Since a 3.5mm audio jack is used as the charging port, an adapter cable needs to be made with one end having a 3.5mm male plug and the other end having a USB A plug.This way, it can be charged with any universal mobile device charger.

DIY Water Flow Meter: A Step-by-Step Guide

When soldering the USB cable and the 3.5mm plug, make sure to match the positive and negative poles.It is recommended to insert the 3.5mm plug before the USB plug, as inserting the cable may cause the plug to short circuit in the metal socket.
DIY Water Flow Meter: A Step-by-Step Guide

Step Six

Modifying the Flow Sensor

DIY Water Flow Meter: A Step-by-Step Guide
The flow sensor itself has an XH2.54 output interface, but it is too short, and the connector contacts are exposed, making it easy to short circuit due to splashing water, so it has been modified:replace the original wire with a long wire with a 3.5mm plug, and then solder it to the built-in Hall element board.Remove the screws from the sensor to see the Hall element board.The red wire is for 5V, the black wire is for ground, and the white wire is for signal.

DIY Water Flow Meter: A Step-by-Step Guide

After modification, it can be connected to the shower head. After removing the shower head, I found that a small part of the pipe deep in the wall has the same thread size as the flow sensor, but they are both external threads, so I bought a PVC coupling to screw into the pipe as a connector. With the connector, simply screw the flow sensor into the connector and then screw the other end of the connector into the pipe. The flow sensor has an arrow to indicate the expected flow direction. Make sure not to install it backwards, or the measurement may be inaccurate. Finally, screw the shower head onto the end of the flow sensor.
DIY Water Flow Meter: A Step-by-Step Guide

Step Seven

Connecting Everything

Solder the Arduino onto the perforated board, then use header pins to pull out the A4, A5 pins along with VCC and GND; connect A4 to the LCD’s SDA, A5 to the LCD’s SCL for I2C communication;connect VCC to the 5V of the boost module, and GND to the GND of the boost module.

DIY Water Flow Meter: A Step-by-Step Guide

For the flow sensor and button, use digital pins to connect, digital pin 2 connects to the flow sensor, digital pin 3 connects to the button.Then follow the wiring diagram shown in the picture to connect.To avoid confusion when plugging in the charging jack and the flow sensor jack (both use 3.5mm connectors), install the flow sensor’s interface on the side of the shell, while the battery charger interface is at the bottom of the shell.
DIY Water Flow Meter: A Step-by-Step Guide

Step Eight

Code

The program logic is as follows:

DIY Water Flow Meter: A Step-by-Step Guide

The program has the following functions:On the first line, it displays the real-time water usage.On the second line, it displays the total cost or flow of water used.When the shower is running, pressing the button switches between displaying cost or flow.When the shower is not running, pressing the button should clear all data and reset the screen, so an interrupt routine should be used to read the sensor to avoid always polling.When updating the screen, we should only update the changed values instead of overwriting the entire screen each time (this would cause noticeable flickering). The program follows a simple structure.By using the millis() function, we can achieve this without pausing the program’s execution.The millis() function returns the number of milliseconds since the Arduino was powered on.By creating a variable called “previousMillis” and subtracting millis() – previousMillis, we can see the elapsed time since previousMillis was updated.If we want something to happen every second, we can use the following code block:
if((millis() - previousMillis) >= 1000) { previousMillis = millis(); toggleLED(); }
This checks if the difference between millis() (current time) and previousMillis (last time) is greater than or equal to 1000 milliseconds. If so, the first thing we do is set previousMillis to equal the current time. Then, we perform any other steps required. In this example, we toggle an LED. After that, we exit this code block and complete the rest of the loop() function, then return to the start and repeat again. The benefit of using this method compared to a simple delay() function is that delay() places a pause between instructions but does not account for the time taken to execute other instructions in the loop() function. If what we are doing takes longer than the time it takes to blink the LED (like updating the LCD screen), then the time taken becomes significant, and after several cycles, the total adds up.
DIY Water Flow Meter: A Step-by-Step Guide

Darwin custom sweatshirt, sister Ni’s universal multimeter, click to draw!

If you want to change the water cost or change the units, you can modify it in the code.

Step Nine

Assembly and Testing

Securing the shell requires 30mm copper pillars.Four M3 screws were used to screw the four copper pillars into the holes at the bottom of the case (see figures 1 and 2).Make sure to tighten these screws firmly, but do not overtighten them, as this may damage the plastic shell.Now we can place all the electronics inside.I used double-sided tape to secure the charger and boost converter to the lid, as shown in the above picture.Then, I wrapped some tape around the exposed metal on the two 3.5mm jacks to ensure that the contact connectors do not short circuit.

DIY Water Flow Meter: A Step-by-Step Guide

First, insert the 3.5mm connector into the flow sensor interface. I recommend doing this before turning on the device, as inserting it while powered can cause unexpected issues (hot plugging). Next, turn on the main power switch. When there is no water, pressing the button on the front panel can only clear the total and clear the screen.

DIY Water Flow Meter: A Step-by-Step Guide

If the shower is turned on, the total water usage should start to increase, and by default, it displays the cost. If you press the button on the front panel, the flow will be displayed instead of the cost on the bottom line. As long as the shower is running, pressing the button on the front panel will toggle between displaying flow and displaying cost. After the shower stops, pressing the button on the front panel will reset the measurement and clear the screen.
DIY Water Flow Meter: A Step-by-Step Guide

Darwin custom sweatshirt, sister Ni’s universal multimeter, click to draw!

Project source: instructables.com
Maker:LiamOSM

Compiled by:Wang Tongxue

END
DIY Water Flow Meter: A Step-by-Step Guide

More Practical Project Recommendations:

STM32 IoT Smart Home Project

Project Sharing | Hand-in-Hand Face Recognition with MATLAB + Raspberry Pi

Raspberry Pi + Compute Stick 2 Complete Real-Time Face Recognition Project

Building a Cloud Computing Platform for Embedded Development Boards

STM32 Achieves the Simplest Air Mouse

Arduino Rubik’s Cube Robot

STM32 Version “AI Soul Painter”

STM32 Electronic Photo Album Production

STM32 + DDS Homemade Signal Generator

Using Raspberry Pi and Web Interface to Remotely Control Home Appliances

STM32 “Cloud” Music Player

Remote Monitoring with Raspberry Pi

Design of Neon Tube Clock Based on STM32

Homemade FPGA Minimal System Board (PCB can be directly made)

Building NAS with Raspberry Pi 4 to Easily Network Hard Drives

ESP32 Car Practical Sharing of Software and Hardware

Only 79 Lines of Code to Complete Creative Gesture Recognition

IoT + Electronic Ink Screen Can Create Custom Displays

Build a Pathfinding Robot Worth Over a Thousand with Just Dozens of Dollars

Stereoscopic 3D Holographic Display, Visual Persistence POV Project

DIY Gesture Recognition Module

Practical Small Designs You Can DIY with No Foundation

Raspberry Pi Creates a Smart Doorbell + Smart Door Lock with Video

Strange! My Development Board Can Play Games Automatically

Homemade Breathing Machine

ESP8266 + Zigbee Network Transformation of Wall Switch

Wireless Home Monitoring System

DIY Bionic Arm, A Tool to Free Your Hands

Handmade Air Purifier, All Design Data Open Source

Tech Toy: Bluetooth Artillery That Can Be Controlled Remotely

Using ST Sensors to Create a LittleBee Monitoring System to Let Bees “Talk”

Homemade Cat Toy

STM32 + Raspberry Pi Achieves 6s Rubik’s Cube Robot

Blindly Modifying Drone Controller, DIY “Foam” Drone

Making a Smart Relay Without Arc Using STM32

Making a Practical New Model Necklace with Just 5 Components

The Simplest Method for Measuring Heart Rate (Suitable for Secondary Development)

Cracking a Magnetic Levitation Globe

The Amazing Light Can Transmit Video? Revealing the Production Process

STM32 Homemade Smart Watch 60FPS Animation

Paying Tribute to the Classic Radio, Observing the Production Process

DIY Third Eye: “Special” Glasses with Bluetooth/OLED/Lens Functionality

Homemade Solar Charger That Tracks Maximum Power Point

No MCU Night Vision Goggles, Just Connect the Wires

Recommended Reading:

Project Sharing | Electric Competition Series | Artificial Intelligence | Graduate School Entrance Exam
Essential Knowledge Points | Graduation Project | Switching Power Supply | Job Hunting
We are Ni Mo, the founder of Darwin, a sister who only talks about technology and doesn’t flirt. The Darwin online education platform aims to serve professionals in the electronics industry, providing skill training videos covering popular topics in various subfields such as embedded systems, FPGA, artificial intelligence, etc. It tailors layered learning content for different audiences, such as common knowledge points, disassembly assessments, electric competitions/intelligent vehicles/graduate entrance exams, etc. Welcome to follow.
Official website: www.darwinlearns.com
Bilibili: Darwin
QQ Group: Group 1: 786258064 (full)
Group 2: 1057755357
DIY Water Flow Meter: A Step-by-Step Guide

Leave a Comment