I have chosen to utilize a fluid flow sensor for monitoring water consumption through ESP and Tasmota.
![](https://private-user-images.githubusercontent.com/8713959/303923431-fc14041e-acdd-4a08-a7b2-2f5931868207.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1MDU1MjgsIm5iZiI6MTcyNDUwNTIyOCwicGF0aCI6Ii84NzEzOTU5LzMwMzkyMzQzMS1mYzE0MDQxZS1hY2RkLTRhMDgtYTdiMi0yZjU5MzE4NjgyMDcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjRUMTMxMzQ4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzBhMGNkOTViMjQ0NWFiYjFhYjJhOTVlNjcyYWExNzc1OGI0MTA3MWFhMGUzYTljZGNkODU0MDdkZDViMWJlNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ._yH-H9d3kwtC63H6MNecdKb4qfWztW_lVyDbrI6-HWA)
Many developers employ a script that tallies pulses, and based on the pulse count, calculates water consumption. However, a common challenge arises as the sensor exhibits nonlinear characteristics, causing the number of pulses per liter to be heavily influenced by water flow. Consequently, developers use varying coefficients depending on the pulse count to derive the flow rate in liters.
In an effort to address this issue, I delved into understanding this sensor. According to information from the manufacturer, the signal frequency (F) is correlated with the instantaneous flow rate (Q) as follows: F(Hz)=6.6×Q(liters/ minute). However, there is no direct measure of total water consumption. The sensor solely gauges instantaneous water flow. The instantaneous water flow per minute is Q=F/6.6, and per second, Q=F/6.6/60. To obtain the total water flow, we need to integrate (sum up) the instantaneous water flow for each second. You can find the script for this process in the FlowMeter-script.txt file.
For the ESP, it is crucial to use firmware that supports scripts. Detailed instructions on how to achieve this can be found on the official page: Tasmota Documentation.