<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/accurate-water-measurement-with-esp32-snfskpc5f" -->

---
title: Accurate Water Measurement with ESP32 | daily.dev
description: A DIY project using an ESP32 (specifically the Olimex ESP32-PoE board) to measure household water consumption via two NSF-certified pulse-output water meters...
canonical: https://daily.dev/posts/accurate-water-measurement-with-esp32-snfskpc5f
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Accurate Water Measurement with ESP32 | daily.dev
og:description: A DIY project using an ESP32 (specifically the Olimex ESP32-PoE board) to measure household water consumption via two NSF-certified pulse-output water meters...
og:url: https://daily.dev/posts/accurate-water-measurement-with-esp32-snfskpc5f
og:image: https://api.daily.dev/og/posts/sNFskPc5f.png
og:image:alt: Accurate Water Measurement with ESP32
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Accurate Water Measurement with ESP32

**[apalrd's adventures](https://daily.dev/sources/apalrd)** · 8 min read · 0 upvotes · 0 comments

## Summary

A DIY project using an ESP32 (specifically the Olimex ESP32-PoE board) to measure household water consumption via two NSF-certified pulse-output water meters installed on cold water lines. The electronics use simple pull-up resistors and RCA connectors, with firmware built in PlatformIO using ESP-IDF. Pulse counts are debounced in software, published via MQTT every 30 seconds (or instantly on change), then processed through Node-RED, stored in InfluxDB, and visualized in Grafana with InfluxQL queries for daily consumption, flow rate, and cumulative totals.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.apalrd.net/posts/2021/water_meter>

## Questions this post answers

### How do I debounce a pulse-counter input on ESP32 in firmware without hardware debouncing?

Store the last 32 pin states in a bit-shifted integer sampled every 10 ms. Only accept a state change when the last 6 consecutive samples all agree (all high or all low). This gives 60 ms of debounce time, which is sufficient for pulse-output water meters at maximum flow rate and provides resilience to electrical noise alongside a 4.7 kΩ pull-up resistor.

_Developers building ESP32 pulse-counting sensors share debounce patterns like this on daily.dev._

### What InfluxQL query shows daily water consumption from a cumulative pulse counter that resets on reboot?

Use non_negative_difference() to eliminate resets, then cumulative_sum() to rebuild the running total: SELECT cumulative_sum(non_negative_difference(mean("Cold"))) FROM "mqtt_consumer" WHERE ("topic" = 'energy/water/meters') AND $timeFilter GROUP BY time($__interval) fill(null). For a Gauge total, replace cumulative_sum with a plain non_negative_difference(max("Cold")) query.

_Teams logging sensor data to InfluxDB and Grafana find query patterns like these on daily.dev._

## Similar posts on daily.dev

- [Dealing With Intermittent Water Utilities](https://daily.dev/posts/dealing-with-intermittent-water-utilities-hoeqazcdg) · Hackaday · 0 upvotes · 0 comments
- [An Automated Water Tank Controller](https://daily.dev/posts/an-automated-water-tank-controller-etkmpnont) · Hackaday · 0 upvotes · 0 comments
- [6 smart home devices anyone can build with a cheap ESP32 and an even cheaper sensor](https://daily.dev/posts/6-smart-home-devices-anyone-can-build-with-a-cheap-esp32-and-an-even-cheaper-sensor-alpetqwxv) · XDA Developers · 0 upvotes · 0 comments
- [DIY ESP32-P4 weather station & air quality monitor connects to LoRa and ESP-NOW sensors, various weather APIs](https://daily.dev/posts/diy-esp32-p4-weather-station-air-quality-monitor-connects-to-lora-and-esp-now-sensors-various-wea-fyniccq3k) · CNX Software · 0 upvotes · 0 comments
- [5 ESP32 projects a total beginner can finish in an afternoon](https://daily.dev/posts/5-esp32-projects-a-total-beginner-can-finish-in-an-afternoon-mo2inkqke) · XDA Developers · 1 upvotes · 0 comments

---

Tags: [#backend](https://daily.dev/tags/backend), [#iot](https://daily.dev/tags/iot), [#grafana](https://daily.dev/tags/grafana), [#influxdb](https://daily.dev/tags/influxdb)

[View this post on daily.dev](https://daily.dev/posts/accurate-water-measurement-with-esp32-snfskpc5f)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Accurate Water Measurement with ESP32","url":"https://daily.dev/posts/accurate-water-measurement-with-esp32-snfskpc5f","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/accurate-water-measurement-with-esp32-snfskpc5f"},"datePublished":"2026-08-11T08:55:30.963Z","dateModified":"2026-08-11T09:24:44.680Z","description":"A DIY project using an ESP32 (specifically the Olimex ESP32-PoE board) to measure household water consumption via two NSF-certified pulse-output water meters...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/61216d9e27113b1429375da09a44d5f2?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/61216d9e27113b1429375da09a44d5f2?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"apalrd's adventures","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"apalrd's adventures","logo":"https://media.daily.dev/image/upload/s--4zkx8dRj--/f_auto,q_auto/v1786438309/logos/apalrd?_a=BAMAMicg0","url":"https://daily.dev/sources/apalrd"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/accurate-water-measurement-with-esp32-snfskpc5f","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"backend,iot,grafana,influxdb","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"apalrd's adventures","item":"https://daily.dev/sources/apalrd"},{"@type":"ListItem","position":3,"name":"Accurate Water Measurement with ESP32"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/accurate-water-measurement-with-esp32-snfskpc5f#faq","mainEntity":[{"@type":"Question","name":"How do I debounce a pulse-counter input on ESP32 in firmware without hardware debouncing?","acceptedAnswer":{"@type":"Answer","text":"Store the last 32 pin states in a bit-shifted integer sampled every 10 ms. Only accept a state change when the last 6 consecutive samples all agree (all high or all low). This gives 60 ms of debounce time, which is sufficient for pulse-output water meters at maximum flow rate and provides resilience to electrical noise alongside a 4.7 kΩ pull-up resistor. Developers building ESP32 pulse-counting sensors share debounce patterns like this on daily.dev."}},{"@type":"Question","name":"What InfluxQL query shows daily water consumption from a cumulative pulse counter that resets on reboot?","acceptedAnswer":{"@type":"Answer","text":"Use non_negative_difference() to eliminate resets, then cumulative_sum() to rebuild the running total: SELECT cumulative_sum(non_negative_difference(mean(\"Cold\"))) FROM \"mqtt_consumer\" WHERE (\"topic\" = 'energy/water/meters') AND $timeFilter GROUP BY time($__interval) fill(null). For a Gauge total, replace cumulative_sum with a plain non_negative_difference(max(\"Cold\")) query. Teams logging sensor data to InfluxDB and Grafana find query patterns like these on daily.dev."}}]}
```

