Skip to the content
2 layers62 × 38.1 mmWater meter counter, the printed circuit board in 3D

Water meter counter

usimd/water-meter-counter1

Inductive water meter counting module for B-meters GSD8

Size
62 × 38.1 mm
Copper layers
2
Thickness
1.58 mm
Parts
46
Nets
39
Pads
106
Tracks, vias
161, 21
Pours
3
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
25 Nov 2025
Updated
28 Oct 2026

Overview

Water meter counter is an open-source printed circuit board by usimd, from the usimd/water-meter-counter repository on GitHub. It is a 2-layer board of 62 × 38.1 mm with 46 parts on 39 nets, routed with 161 tracks and 21 vias.

It is built around the PIC18F25K80-I/MM, HCPL-817-30DE and 06035C104JAT2A, with the SS14MH, ESR03EZPJ103 and B5819W among its other parts. Its parts include 11 resistors, 7 capacitors, 4 connectors, 3 diodes and 2 ICs. It belongs with the home automation and IoT boards and the PIC boards of this library.

Main components

7

README

README.md

Hardware: CERN-OHL-S-2.0 Firmware: Apache-2.0 REUSE status Upload to  - AISLER

Inductive water meter counter with S0 interface for GSB-8 meters

This is a custom water meter counter project to get an interface to analog water meter readings for subsequent usage in Homeassistant. The project is outputting its readings via a generic S0 interface, though, to enable other use cases as well.

It features a custom 3D-printable model to snap on to the GSB-8 meter that houses the PCB. The software doing the actual work is located in the firmware folder. Since it is based on a Microchip PIC controller, it requires the respective infrastructure to build.

Render of PCB

Bundled assets are available as GitHub releases, created by CI for every v* tag:

  • firmware *-production.hex (normal use) and *-debug.hex (additionally prints every sample on the UART, 9600 8N1, for re-tuning), plus the matching .elf files,
  • Gerber and drill files (*-gerbers.zip), BOM and pick-and-place CSVs, schematic PDF,
  • 3MF file and FreeCAD model of the housing.
  • license texts (LICENSE-*.txt).

To build the firmware locally, open firmware with the MPLAB extensions for VS Code, or run cmake --preset water_meter_counter_default_conf -S firmware/cmake/water-meter-counter/default followed by cmake --build firmware/_build/water-meter-counter/default. Each build writes both firmware/out/water-meter-counter/default.hex (production) and default-debug.hex; the debug variant is defined in firmware/cmake/water-meter-counter/default/user.cmake.

How the firmware counts

The meter's half-disc turns once per litre and passes two LC tanks, A and B. Every ~70 ms the PIC18F25K80 wakes from Sleep, rings both tanks and sleeps again until the watchdog wakes it.

Both tanks are read the same way. After the tank is excited and released, comparator 1 compares its sense pin with CVREF, and its output gates Timer1. Timer1 adds up how long the ring-down spends below the threshold. This is timed in hardware, so it reads the same after a wake from Sleep.

  • Tank B (CVREF 17/32 VDD) alternates once per revolution between a rest level and a higher pass level (~107 and ~134 ticks of 0.25 µs on the bench). Each pass is one litre. The rest level is tracked down quickly but up only slowly, so at a slow trickle the baseline cannot follow B's ramp into the pass.
  • Tank A (CVREF 16/32 VDD) gives the direction. Its level changes in the middle of a B pass: A falling across the pass (~70 → ~60 ticks) means forward, rising means reverse.

Each revolution is counted in two half steps of 0.5 L: the B pass, and the rest phase between two passes. The rest phase is decided like the pass, mirrored: A recovers (rises) over a forward rest phase. Where A barely changes outside the pass, the next decided pass corrects the rest half step, so the total stays two half steps per litre. The halves are not equal in time: the pass covers about two thirds of a revolution, so the rate derived from single pulses jitters while the volume is exact.

Each forward half step emits a 100 ms S0 pulse on RB4, so 1 pulse = 0.5 L (2000 pulses/m³). Pulses are queued and kept at least one sample apart. Reverse half steps are counted and have to be made up by forward ones before pulses resume, so the pulse total follows the net volume. If B sits in its pass level at power-up, that first pass is skipped while the baseline settles.

The ADC is not used and stays off with its input selector on the unconnected RA0. The pin the selector points at sources about 2 µA, even with the ADC off. On a 165 kΩ sense node that lifts the bias by ~0.35 V, more than two comparator steps, which made B unreadable while the selector sat on it.

Measured at 5 V with the production firmware: ~350 µA idle (no flow) and up to ~5 mA during an S0 pulse, when the CPU stays awake and the optocoupler LED is on.

Using it with ESPHome

ESPHome's pulse_meter reads the S0 output directly. Replace the pin with the GPIO your S0 line is wired to. Enable the internal pull-up if the receiving board has no pull-up of its own.

yaml
sensor:
  - platform: pulse_meter
    name: "Water flow"
    pin:
      number: GPIOxx
      mode:
        input: true
        pullup: true
    internal_filter: 50ms   # pulses are 100 ms long and at least ~170 ms apart
    timeout: 3min           # report 0 L/min after this long without a pulse
    unit_of_measurement: "L/min"
    accuracy_decimals: 1
    filters:
      - multiply: 0.5       # pulses/min -> L/min
      - throttle_average: 60s
    total:
      name: "Water total"
      unit_of_measurement: "m³"
      device_class: water
      state_class: total_increasing
      accuracy_decimals: 4
      filters:
        - multiply: 0.0005  # 1 pulse = 0.5 L

Pass and rest halves take different times, so the rate from single pulses jitters. The throttle_average filter smooths this out; the total is unaffected. For the Energy dashboard, use the total sensor. It restarts at 0 when the ESP reboots, which total_increasing handles.

Lessons learned from rev1

On the first board revision the LC tanks barely rang. After excitation the sense node stayed almost flat instead of showing the expected multi-cycle ring-down.

Simulation ruled out the architecture. The analog front end was modelled in KiCad/ngspice:

  • A GPIO charges the 470 µH / 2.2 nF tank through a 470 Ω resistor and a Schottky diode.
  • The GPIO release to hi-Z is modelled as a switch.
  • The sense node is AC-coupled through 100 pF and biased to VDD/2 by a 330k/330k divider before it reaches the comparator.
  • Board and pin parasitics are added as small capacitors and large resistors.

LC tank simulation schematic

The simulation shows a clean ~156 kHz ring-down after the drive pulse ends at 200 µs. Blue is the drive, green the tank node and purple the biased sense node. Many cycles cross the comparator's 2.5 V threshold. The topology works, so the problem had to be physical.

Simulated ring-down, 470 µH

Root cause: copper under the inductors. Rev1 had a solid GND pour on both layers directly beneath L1 and L2. The coils' open magnetic field induces eddy currents in that copper. Those currents load the tanks and destroy their Q. Rev2 adds copper-pour keepouts under and around both inductors and the sense circuitry, and uses 470 µH coils. On rev2 the tanks ring as expected.

References

Inspiration:

Helpful references:

License

  • Hardware (schematic, PCB, footprints, housing, renders and documentation): CERN-OHL-S-2.0.
  • Firmware (firmware/) and CI: Apache-2.0.
  • firmware/mcc_generated_files/ is generated by MPLAB Code Configurator and remains under Microchip's license, which only allows its use with Microchip products. The firmware images contain this code.

Per-file details follow the REUSE specification (SPDX headers and REUSE.toml); CI checks compliance with reuse lint.

AISLER discount

This project has been prototyped at AISLER. You can instantly order as well by clicking on the badge at the top.

In case you want to build this (or any other project) at AISLER, here's a 10€ discount code: MakeInEurope-ZDCTN

Parts

46
QtyValueFootprintReferences
5470Resistor_SMD:R_0603_1608MetricR2, R6, R7, R10, R11
4330kResistor_SMD:R_0603_1608MetricR4, R5, R8, R9
3FiducialFiducial:Fiducial_1mm_Mask3mmFID1, FID2, FID3
3MountingHoleMountingHole:MountingHole_2.2mm_M2_ISO7380H1, H2, H3
20.1uFCapacitor_SMD:C_0603_1608MetricC1, C2
2100pFCapacitor_SMD:C_0603_1608MetricC4, C5
22.2nFCapacitor_SMD:C_0603_1608MetricC6, C7
2470uHInductor_Fastron_THT:L_Radial_D4.80mm_P2.50mm_Fastron_05HCPL1, L2
2Conn_01x01TestPoint:TestPoint_Keystone_5000-5004_MiniatureJ3, J4
2SS14Diode_SMD:D_SOD-123FD2, D3
110kResistor_SMD:R_0603_1608MetricR1
110uFCapacitor_SMD:C_0603_1608MetricC3
1220Resistor_SMD:R_0805_2012MetricR3
1B5819WDiode_SMD:D_SOD-123D1
1Conn_01x04Connector_JST:JST_XH_S4B-XH-A_1x04_P2.50mm_HorizontalJ1
1Conn_PIC_ICSP_ICDConnector_PinHeader_1.27mm:PinHeader_1x06_P1.27mm_VerticalJ2
1G***kibuzzard-6924F13Dkibuzzard-6924F13D
1G***kibuzzard-69E7705Ekibuzzard-69E7705E
1G***kibuzzard-69451647kibuzzard-69451647
1G***kibuzzard-69E7706Bkibuzzard-69E7706B
1G***kibuzzard-6924F10Ekibuzzard-6924F10E
1G***kibuzzard-69E77073kibuzzard-69E77073
1G***kibuzzard-6945164Fkibuzzard-6945164F
1G***kibuzzard-69E77065kibuzzard-69E77065
1G***kibuzzard-6924F128kibuzzard-6924F128
1HCPL-817-30DEPackage_SO:SSO-4_6.7x5.1mm_P2.54mm_Clearance8mmU2
1KiCad-Logo2_6mm_SilkScreenSymbol:KiCad-Logo2_6mm_SilkScreenLOGO2
1OSHW-Symbol_6.7x6mm_SilkScreenSymbol:OSHW-Symbol_6.7x6mm_SilkScreenLOGO1
1PIC18F25K80_IMLPackage_DFN_QFN:QFN-28-1EP_6x6mm_P0.65mm_EP4.25x4.25mmU1

Similar boards

  • 2 layers135.3 × 78.4 mmMseq, the printed circuit board in 3D

    Mseq

    MF-Room/mseq_pcb

    KiCad 10 hardware design for MSeq embedded, the microcontroller implementation of the MSeq MIDI sequencer.

    93 parts1CERN-OHL-S-2.0
  • 2 layers24 × 27.9 mmCanankaFEC, the printed circuit board in 3D

    CanankaFEC

    medo64/CanankaFEC

    CAN bus framework expansion card.

    28 parts2MIT
  • 2 layers55 × 45 mmCanfuel, the printed circuit board in 3D

    Canfuel

    PoJD/kicad

    Printed circuit boards. A container for all projects, successor to the older eagle repo.

    28 partsApache-2.0
  • 2 layers82 × 72 mmDomino CAN, the printed circuit board in 3D

    Domino CAN

    GBert/misc

    miscellaneous stuff / unsorted

    19 parts99
  • 4 layers121 × 96 mmClaw Machine, the printed circuit board in 3D

    Claw Machine

    emiz-jh/2526_Maker_ClawMachine

    Projet de machine à pince réalisé dans le cadre de l'Option Maker ENSEA 2025-2026.

    92 parts1
  • 4 layers62 × 45 mmServo, the printed circuit board in 3D

    Servo

    theatrus/tsumikoro

    What if you made lots of spheres roll around?

    73 parts1
  • 2 layers143 × 78 mmSnekSafe, the printed circuit board in 3D

    SnekSafe

    USA-RedDragon/SnekSafe

    Keep your snek safe by controlling temperature and lighting.

    19 parts1MIT

Questions

How big is the Water meter counter PCB?

It measures 62 × 38.1 mm and has 2 copper layers, 1.58 mm thick.

What parts does the Water meter counter use?

46 parts, built around the PIC18F25K80-I/MM, HCPL-817-30DE, 06035C104JAT2A and SS14MH. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Water meter counter KiCad files?

From the usimd/water-meter-counter repository on GitHub, at the commit this page was made from: the board is water-meter-counter.kicad_pcb and its schematic water-meter-counter.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Water meter counter design in my own project?

Its repository states no licence, so its author keeps all rights: ask usimd before reusing the design.