Skip to the content
PCBKitNew board
2 layers55.6 × 43.2 mmBallValveController, the printed circuit board in 3D

Ball valve controller for irrigation, water automations and leak prevention. Supports CR05 feedback wiring. Based on ESP32c3. ESPEasy and ESPHome based firmware build instructions included

Size
55.6 × 43.2 mm
Copper layers
2
Thickness
1.6 mm
Parts
46
Nets
29
Pads
116
Tracks, vias
216, 3
Pours
2
Routed
Yes
KiCad
KiCad 8.0 (file 20240108)
Created
3 Jun 2024
Updated
4 Sep 2026

Overview

BallValveController is an open-source printed circuit board by hansrune, from the hansrune/BallValveController repository on GitHub. It is a 2-layer board of 55.6 × 43.2 mm with 46 parts on 29 nets, routed with 216 tracks and 3 vias.

It is built around the L7805 and 2N2222A. Its parts include 13 resistors, 11 connectors, 8 diodes, 4 capacitors and 2 ICs. It belongs with the home automation and IoT and audio and music boards and the ESP32 boards of this library.

Main components

2

README

README.md

Ball Valve Controller

A DYI ball valve controller for CR05 wiring based on ESP32c3. This device is mainly intended for irrigation and main water valve automation, but is also very suitable for water leak prevention. For safety, a battery helps make sure the device returns to its default state upon reset or power failure. The device can be directly controlled to the default state by external signals such as a local water leak sensor, or you can use your home automation system to cut off water supply based on more advanced conditions.

The default state can be normally open or normally closed, and is automatically detected on restart. The safety battery voltage is also monitored and available to read remotely.

This board is tested with ESPhome and ESPEasy firmware (build instructions below), and is easily used with home automation systems that support MQTT auto discovery, the native Home Assistant API, and the many controllers that ESPEasy supports

Introduction

Some of the main features and benefits

  • Supports 5-wire CR05 wiring
    • The true state of the valve can be fed back to your automation system over WiFi
    • You can detect valve malfunctioning
    • Is used by the firmware to automatically detect NO (normally open) or NC (normally closed) operation during startup
  • Supports battery backup and battery status monitoring
    • A 9V battery is sufficient to make sure the valve returns to it's default state during power failure and resets
    • The battery voltage is readable and available as a sensor
  • Water leak sensors and protection
    • There are inputs to force the valve to the default state as well as the activated state. Typically used with a Fibaro water leak detector associates with a Fibaro smart implant so that the valve can be "overruled" without any host controller / home automation being involved. Numerous Z-wave and Zigbee devices support this.
  • 1-wire support
    • This is used to attach DS18B20 temperature sensor. I use this with a nearby water heater. Two inputs with pull-ups are available, but you can also use multiple sensors on one wire
  • I2C support
    • An I2C pin header with power supply is available to use with I2C sensors
    • ... or you can use the same GPIO pins for any other purpose of your choise
  • WiFi based
    • This is almost a must have for most home automation systems
    • OTA support
    • Configuration backup, restore and bulk updates.
  • Firmware of your choise
    • ESPEasy with Domoticz over http. Device creation uses virtual sensors
    • ESPEasy with Domotics and Home Assistant via MQTT. Device creation uses a MQTT configuration text file.
    • ESPHome to Home Assistant via MQTT and auto discovery
    • ESPHome to Domoticz via MQTT and auto discovery
    • ... and as the hardware supports using both Arduino and ESP-IF development kits, almost any other firmware can be created.
  • Seed Studio XIAO ESP32C3
    • This device is shielded and comes with an external IPX antenna connector
    • FCC and CE regulations approved

Setup and mounting

A typical small electic junction box is used for an easy and affordable way for housing the PCB and battery. These boxes often also support using glands for humidity protection and strain releave.

Please note the positioning of the battery. The battery can be easily removed to provide room for a USB-C cable connection, in case an OTA update should fail. Failure to OTA is usually recovered by a power cycle, but bugs in OTA libaries need a physical connection for recovery.

The switch (see wiring below) is used to select between normally open and normally closed operation. As the ball valve will return to it's default position during reset, the valve position feedback switches are used to automatically determine if the setup is normally open or normally closed.

One of my permanent setups look like this:

... where the 1-wire sensors are attached to top and bottom of our electric water boiler.

Indicators

The 5mm LEDs are suggested to be reverse mounted for the following purposes:

  • LED D7 will indicate the state of valve activation - solid on or off
  • LED D6
    • will blink with a duty cycle 1-4 or 4-1 to indicate valve closed or open
    • a duty cycle 1:1 will indicate a reset is ongoing
    • no change indicates out of power, device death/freeze or other

Implementation and design

The easiest way to view the controller is probably this block level wiring diagram:

This is just a typical setup for the various external components. The schematic diagram is available here. The KiCad EDA project is in the same folder

If you use more than one 1-wire sensor, it is easier in ESPHome to use both inputs (RX+TX in diagram) with automatic sensor address detection.

GPIO pin usage

PINCapabiltyFunction
GPIO2Active low outActivate battery read
GPIO3/A1Analog inBattery read input
GPIO4Active low inValve open
GPIO5Active low inValve closed
GPIO6I2CSDA
GPIO7I2CSCL
GPIO9Active low outInternal status LED
GPIO10Active high outValve activate to non-default state
GPIO20RX / 1-wireSerial or 1-wire sensor
GPIO21TX / 1-wireSerial or 1-wire sensor

Interfacing leak detectors

J10 is used to interface leak detectors:

PINNameFunction
1ActivatePull high to force non-default state
2DeactivateBattery read input
3VccSupply voltage, 3.3V, 5V or 12V strap
4GNDGround
Connecting a Fibaro Implant

A Fibaro implant may be associated with Fibaro leak detector(s). This type of device to device can work even without the Z-Wave hub being operational

  • VCC - strap JP1 to the 12V supply as illustrated here, or just feed the Implant directly from the 12V power supply
  • Deactivate - connect to one side of Out1 - the other side to GND
  • GND for implant power and Out1
Connecting an Arduino water leak sensor

Typical Arduino water leak detectors are open collector outputs. Connect as follows:

  • VCC - strap/solder JP1 to the 3.3V side for sensor power
  • Deactivate - connect to sensor output. This will force the valve to default state when activated
  • GND - sensor power ground

Hardware - getting started

This project uses my KiCad-lib-ESP32 repository as a git submodule. To check this out, use the following:

bash
git clone --recurse-submodules https://github.com/hansrune/BallValveController.git 

Materials used

This project uses the Seed Studio XIAO ESP32C3 RISC-V module. This tiny device has proven to be more reliable than most ESP8266 modules used in earlier versions. This module also comes with an IPX connector for connecting an external antenna, and is delivered with a simple external antenna for good range. This device is also EMI shielded and certified.

A ball valve like these HSH-FLO valves uses metal gears, and also have a manual override possibility. Despite the moderate cost, I have found them very reliable. Manufacturer claims 100k operations. I typically use a 2 or some times 3-port version, size 3/4" DN20, DC12/24V and with CR05-01 wiring, including a manual overrride whell option.

Any available 12V DC power supply delivering 1A or more should do.

There are many options and possible pinouts for DC-DC converters for the 12V to 5V conversion. A linear regulator (L7805) will need a heatsink, so a DC-DC converter is recommended.

The MOSFETs need a low Vgs trigger voltage, i.e. well under 3V on full load. I have used Si2301/A1SHB for the P-channel, and Si2302/N025P for the N-channel, and 2N2222/1P - all SOT-23 packages.

Resistors are 0805 size. Screw terminals are 3.5mm, which is a tight fit when ferrules are being used.

For more information, use this KiCad BOM

Hardware assembly

Soldering a prototype by hand is possible if you have a steady hand and a small solder iron tip. A microscope is recommended to inspect the solder joints properly.

Recommend to do the SMD parts first, then other components. I prefer to mount the 5mm LEDs on the back side.

Hardware tests

You should test at least the following before adding the ESP32 module:

  • Attach a battery and check that the valve can be operated both NO and NC
  • Add power and check that 5V conversion is OK
  • Apply 5V to the ESP32c3 pin 11 to check that the relay is operated
  • Apply 0V to pin 1 of the ESP32c3 and check that pin 2 receives a 200ms readout of the battery voltage (divided by the 68k + 20k resistors)

Firmwares

ESPHome

ESPHome firmware can be set up from this ESPHome configuration repository using the test_ball_valve as a template

Follow the README for instructions on what you will likely want to change.

By default, MQTT auto discovery is being used. This should work out of the box with Home Assistant, Domoticz and other that support Home Assistant MQTT Auto Discovery

In Home Assistant, the device has these controls:

... and information / diagnostics panel:

ESPEasy

ESPEasy can be used with a number of different controllers / home automation systms. A custom firmware build description is available here

ESPEasy requires many settings. For configuration settings and rule files, you can upload the files from this page as a starting point. Please make sure to change name, unit number, controller IP addresses, NTP, syslog host and latitude/longitude. This configuration uses both a MQTT controller and a Domoticz controller. Change to what you need.

Bugs and tweaks

For Fibaro Smart Implants

A Fibaro Smart implant needs a 9-30V power supply. To accomodate that, you can supply 12V by running a wire on the back of the PCB as follows:

... or just connect to the 12V input terminal

License

This project is licensed under the GNU General Public License v3.0 for the software, CERN-OHL-W for the hardware, and CC BY-SA for the documentation and ideas.

Parts

46
QtyValueFootprintReferences
5Conn_01x01_MaleConnector_PinHeader_2.54mm:PinHeader_1x01_P2.54mm_VerticalJ5, J6, J7, J8, J9
410kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR3, R4, R7, R8
44.7kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR5, R6, R9, R10
310uFCapacitor_Tantalum_SMD:CP_EIA-3216-18_Kemet-A_Pad1.58x1.35mm_HandSolderC2, C3, C4
31N4007Diode_SMD:D_SMB_HandsolderingD1, D4, D8
31N4148Diode_SMD:D_MiniMELFD2, D3, D5
3MountingHole_PadMountingHole:MountingHole_3.2mm_M3_ISO14580_PadH1, H3, H4
3Screw_Terminal_01x04TerminalBlock_Phoenix:TerminalBlock_Phoenix_PT-1,5-4-3.5-H_1x04_P3.50mm_HorizontalJ2, J4, J10
2LEDLED_THT:LED_D3.0mm_ClearD6, D7
2SolderJumper_3_OpenJumper:SolderJumper-3_P1.3mm_Open_Pad1.0x1.5mm_NumberLabelsJP1, JP2
11kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR12
1270Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR11
12N2222APackage_TO_SOT_SMD:SOT-23_HandsolderingQ2
133kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR1
168kResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR2
1910Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR13
1C_SmallCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC1
1G5V-2Relay_THT:Relay_DPDT_Omron_G5V-2K1
1L7805Package_TO_SOT_THT:TO-220-3_VerticalU1
1Q_PMOS_GDSPackage_TO_SOT_SMD:SOT-23_HandsolderingQ1
1Screw_Terminal_01x02TerminalBlock_Phoenix:TerminalBlock_Phoenix_PT-1,5-2-3.5-H_1x02_P3.50mm_HorizontalJ11
1Screw_Terminal_01x03TerminalBlock_Phoenix:TerminalBlock_Phoenix_PT-1,5-3-3.5-H_1x03_P3.50mm_HorizontalJ1
1Screw_Terminal_01x04Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ3
1SeedStudio XIAO ESP32 C3 v1LOCAL1:XIAO_ESP32C3_THTU2

Questions

How big is the BallValveController PCB?

It measures 55.6 × 43.2 mm and has 2 copper layers, 1.6 mm thick.

What parts does the BallValveController use?

46 parts, built around the L7805 and 2N2222A. 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 BallValveController KiCad files?

From the hansrune/BallValveController repository on GitHub, at the commit this page was made from: the board is KiCad/BallValveController.kicad_pcb and its schematic KiCad/BallValveController.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the BallValveController design in my own project?

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

Similar boards

  • 2 layers156.5 × 67.5 mmNixieScanDisplay, the printed circuit board in 3D

    NixieScanDisplay

    profdc9/NixieClock

    A Nixie clock that uses IN-14 tubes and very generic components that can be easily sourced.

    106 parts10
  • 2 layers100 × 100 mmBoomslang, the printed circuit board in 3D

    Boomslang

    profdc9/Boomslang

    A microcontroller-based model rocket launcher igniter.

    113 parts1MIT
  • 2 layers85.1 × 63.5 mmRelayBoardX3, the printed circuit board in 3D

    RelayBoardX3

    hansrune/RelayBoardX3

    3x relay board used for garage door control and ventilator motors

    54 parts
  • 2 layers125.2 × 86.4 mmEmbedded System Project, the printed circuit board in 3D

    Embedded System Project

    jastikai/Embedded-System-Project

    Repository for Embedded System Project course of University of Oulu, Spring 2024.

    57 parts
  • 2 layers112.8 × 83.1 mmInverter, the printed circuit board in 3D

    Inverter

    sovanaram/Power-Electronics

    Create and experiment power conversions

    53 parts
  • 2 layers165 × 133 mmFuerza, the printed circuit board in 3D

    Fuerza

    yislle/PCBs-By-ME

    Proyectos electrónicos

    131 parts
  • 2 layers101.5 × 83 mmSd2snes, the printed circuit board in 3D

    Sd2snes

    mrehkopf/sd2snes

    SD card based multi-purpose cartridge for the SNES

    154 parts722GPL-2.0
  • 2 layers279.4 × 203.2 mmZ180GDC, the printed circuit board in 3D

    Z180GDC

    lynchaj/rhyophyre

    Single Board Computer featuring Zilog Z180 processor and NEC µPD7220 Graphics Display Controller

    249 parts12