New Product Alert: OpenSprinkler Sensor Expander

A long-requested feature for OpenSprinkler is the ability to read analog sensors, including temperature, soil moisture, water level, light, and more. While OpenSprinkler’s built-in sensor ports can read binary (i.e., HIGH or LOW) signals—primarily from dry-contact switches like rain and flow sensors—it has lacked the ability to read analog sensors that produce continuous voltage signals. Analog sensors are critical for advanced irrigation applications, where users rely on precise environmental data to fine-tune their watering times.

Introducing the OpenSprinkler Sensor Expander—our upcoming product that provides 16 channels of analog sensor inputs, allowing your OpenSprinkler to interface with a wide variety of external sensors and automatically adjust your programmed water times based on real-world conditions. Below are two sneak peek photos of this new expander.


Main Features:

  • 16 Analog Sensor Inputs: Powered by four ADS1115 Analog-to-Digital Converters (ADCs), providing a total of 16 independent high-precision analog sensor inputs.
  • Dual Voltage Options: Selectable 5V and 3.3V to support a wide range of sensors.
  • Easy Expansion: Plugs directly into OpenSprinkler’s Zone Expander connector using the same 2×5 ribbon cable interface. It can be used standalone with the main controller or inserted at any point in an existing Zone Expander chain.
  • Hardware 1-Wire Master: Includes an on-board 1-Wire Master controller to enable future support for 1-Wire sensors, such as the DS18B20 temperature sensor (firmware support coming soon).

Below is an illustration of the Sensor Expander and how it connects to the OpenSprinkler main controller and (optionally) your Zone Expanders.


Firmware Support

We are actively working on finalizing OpenSprinkler firmware 2.2.1(5), which will be the first release to support the Sensor Expander. Below are several screenshots showing the new firmware user interface in action. We are currently accepting pre-orders, with a targeted shipping date of late-July 2026.


Edit Sensors Page:

The Sensor configuration interface lets you create a new sensor or edit an existing sensor by providing a custom name, sampling interval (e.g., every 15 minutes), physical unit, min/max clamping values, and sensor type. Currently supported sensor types include:

  • ADS1115: For sensors connected to the expander’s analog inputs. Includes three sub-types:
    • Generic Linear: Define custom linear parameters (scaling and offset) that map raw ADC voltage to sensor value.
    • Baked-in Types: Pre-configured for known sensors (e.g. SMT50 and VH400), with scaling and offset parameters taken directly from the sensor datasheets.
    • Piecewise Linear: The most flexible type, supporting non-linear mapping with up to 8 sample points.
  • Aggregate Sensors: Combine up to 8 “child” sensors and aggregate their data using operations like Average, Min, Max, Median. This is useful for example, when you need to average or denoise readings from multiple soil moisture sensors. Aggregate sensors can themselves be children of other aggregate sensors, allowing flexible hierarchies.
  • On-Board Digital Sensors: Allows you to programmatically link the controller’s internal digital sensors (e.g., rain, soil) to the new Sensor interface. Normally, on-board sensors affect watering on a per-zone basis (via each zone’s ‘Ignore Sensor’ flag). By routing them through the Sensor interface, you can use them in program-level adjustments.
  • System Internal Sensors: Monitor metrics like available Heap size and Flash size. Combined with logging, this lets you track the microcontroller’s resource usageover time.

Note: Firmware 2.2.1(5) supports up to 64 sensors total, each with configurable parameters such as logging and the option to display on the home page, as shown below.


Sensor Logs Page:

The Sensor Logs page displays logged data from all active sensors that have ‘Logging’ flag enabled. You can select different time windows to zoom into specific periods, download the logs as .csv files for external analysis, or delete the logs of individual sensor. A “Show Inactive” checkbox lets you view logs from disabled or previously deleted sensors.


Sensor Adjustments in Edit Programs Page:

The Edit Programs page now includes a new ‘Sensor Adjustment‘ section. It lets you define how the program’s water times should be modified based on the value of a selected sensor. For example, reducing watering when soil moisture is high, or increasing it when temperature is warm. You can use any sensor as input, including an Aggregate Sensor that combines readings from multiple sources.

In this interface, you can select a sensor and configure a custom Adjustment Curve using up to 8 sample points, defining how sensor readings translate into watering percentages. The adjustment curve is visualized in real-time, with the current sensor value shown as a green dotted line for reference.

Sensor Adjustment works alongside the existing Weather Adjustment feature. The program’s final water time is multiplied by both the sensor-based percentage and the weather-based ‘watering level’.


Other Firmware Features:

Beyond Sensor Expander support, firmware 2.2.1(5) brings several additional enhancements, including support for up to 4 Master Zones (previously 2), and up to 4 on-board digital sensors on hardware v3.4 (previously 2).


FAQ:

Q: What are some example use cases for the Sensor Expander?
A: The Sensor Expander is particularly useful when you want to modify watering times based on real-world sensor readings — for example, reducing watering when soil moisture is high, adjusting for temperature and evaporation, accounting for ambient light levels, or stopping irrigation when a water tank runs low.

Q: Which OpenSprinkler hardware is compatible with the Sensor Expander?
A: The OpenSprinkler v3 family (v3.0 through 3.4) is compatible. The Sensor Expander uses the same 2×5 ribbon cable connector as the v3 Zone Expanders.

Note that OpenSprinkler v2.3 and OpenSprinkler Pi (OSPi) are NOT compatible with the Sensor Expander. However, recent versions of OSPi (v1.5 and v2.0) feature two on-board ADS1115 chips, providing 8 channels of analog inputs out of the box when updated to firmware 2.2.1(5).

Q: When will the Sensor Expander be ready to ship?
A: We are taking pre-orders now! Shipping is expected to begin in late-July 2026.

Q: What types of sensors are supported?
A: Most analog sensors that operate on 3.3V or 5V logic are supported. Popular examples include the Truebner SMT50, SMT100, Vegetronix VH400, and many resistive and capacitive moisture sensors. The Generic Linear and Piecewise Linear sensor types provide flexibility to support virtually any analog sensor by configuring custom mapping parameters.

Q: What’s the size and weight of the Sensor Expander?
A: The Sensor Expander measures 80mm × 65mm × 30mm (3.15in × 2.56in × 1.18in) and weighs 75g (2.65oz).

Q: If I use the Sensor Expander, can I still use Zone Expanders?
A: Absolutely! The Sensor Expander works alongside Zone Expanders. They both utilize the same I2C communication bus, meaning multiple devices can be connected on the same chain. You can have one Sensor Expander plus multiple (up to 4) Zone Expanders, in any order along the chain.

Q: Can I daisy-chain two Sensor Expanders to get 32 analog inputs?
A: Unfortunately, no. Each main controller can only support one Sensor Expander. The ADS1115 chip allows only 4 unique I²C addresses, and our Sensor Expander already uses all four, so there is no capacity for any additional. If you require more than 16 analog inputs, you will need to add a second OpenSprinkler main controller with its own Sensor Expander.

Q: Can I connect digital sensors (e.g., rain sensor, flow sensor) to the Sensor Expander?
A: While switch-type sensors (like rain and flow) can technically be connected to the expander, we highly recommend using the main controller’s dedicated on-board digital sensor inputs instead. The Sensor Expander inputs have heavy low-pass filtering and slow sampling rates, optimized for analog measurements rather than fast digital signals.

Flow sensors should NOT be connected to the Sensor Expander. The combination of slow sampling and heavy filtering will cause missed pulses, making accurate flow measurement impossible. Connect flow sensors to the main controller’s on-board sensor inputs.

Q: Can I use custom sensors not in the pre-defined list?
A: Yes! The Generic Linear sensor type lets you configure custom linear mapping (scaling and offset) for any analog sensor. For sensors with non-linear response curves, the Piecewise Linear sensor type supports up to 8 sample points for arbitrary mapping. Your sensor’s datasheet generally provides the formula. Alternatively, an empirical approach is to measure your sensor’s output voltages at known reference values, and use the collected voltage-value pairs to define the Piecewise Linear curve.

Q: What’s the 1-Wire Master for?
A: The Sensor Expander includes an on-board 1-Wire master controller, capable of processing the 1-Wire communication protocol. But firmware support for 1-Wire sensors (such as the DS18B20 temperature sensor) is not yet implemented. We plan to add this in a future firmware update.


Ready to add intelligent sensor-based irrigation to your OpenSprinkler? Pre-order the Sensor Expander now and be among the first to receive it in late-July 2026!

How to Switch Pumps & High-Voltage Devices with OpenSprinkler (2026 Guide)

A common question we receive from users is: “How do I use OpenSprinkler to switch a water pump, a heater, a fan, or similar mains-powered devices?” Here are the top 5 ways to bridge the gap between OpenSprinkler and your high-voltage equipment, ranging from “Zero Wiring” to “Zero Software Configuration“.


1. WiFi Smart Plugs

  • Best For: Ease of use, zero wiring, and total safety.
  • Approx. Cost: ~$20

This is rapidly becoming the most popular method because it requires zero physical wiring between the controller and the pump. You can have your OpenSprinkler in the garage and control a pump in a greenhouse 50 feet away.

How does it work: WiFi power sockets like the Shelly Plug US support a well-documented HTTP API, which allows you to send commands over WiFi to switch the socket on or off. Crucially, they allow for local IP-based control without relying on a cloud server—a perfect solution for privacy-focused users.

OpenSprinkler features a station type called “HTTP Station“, which sends user-defined HTTP commands when a zone opens or closes. By leveraging the smart plug’s API, zone actions transfer directly to the power plug.

Shelly US Plug Gen 4
HTTP Station Config

How to set it up:

  1. Configure your WiFi plug to connect to your router and obtain its IP address.
  2. In OpenSprinkler, edit a zone and set its Station Type to HTTP.
  3. Enter the plug’s IP address and Port in the Server Name and Port fields.
  4. Configure the HTTP commands. Using the Shelly US plug as an example:
    • On command: rpc/Switch.Set?id=0&on=true
    • Off command: rpc/Switch.Set?id=0&on=false
  5. Test the zone to verify the plug responds. (Note: If you use a different brand, check its API documentation for the correct command path).

Pros:

  • Galvanic Isolation: Complete air-gap isolation. No risk of messing with high-voltage wires.
  • Expandability: Easy to expand to multiple plugs / pumps. You aren’t limited by the physical ports on your OpenSprinkler unit.
  • Power Monitoring: Many plugs include power consumption monitoring.

Cons:

  • Not all WiFi plugs support HTTP API or local IP-based control.
  • Relies on your WiFi router (if WiFi is down, the pump won’t turn on).
  • Requires initial WiFi configuration on the plug.

2. Wireless but No WiFi: RFToy and RF Sockets

  • Best For: Long-range control where WiFi is weak.
  • Approx. Cost: ~$40 (RFToy + Sockets)

RF Power Sockets work on the 433MHz or 315MHz bands (unlike the 2.4GHz used by WiFi) and typically come with a dedicated remote. With an RFToy, you can decode the remote’s signal and replicate it using OpenSprinkler. OpenSprinkler’s ‘RF Station’ feature is designed exactly for this. You paste the code that RFToy intercepted from the remote, allowing the zone to toggle the socket.

RF power socket with remote
OpenSprinkler RF Station Config

Pros:

  • Range: RF signals often penetrate walls and floors far better than WiFi.
  • Isolation: Complete air-gap isolation. No wiring required.
  • Cost: RF sockets are cheaper per unit than WiFi plugs, making expansion more affordable.

Cons:

  • Requires purchasing an extra device (RFToy)
  • Usually one-way communication (no feedback signal to confirm the plug actually turned on).

3. The Safe Wired Way: IoT Relay

  • Best For: Users who want a reliable wired-only connection without messing with mains voltage.
  • Approx. Cost: ~$40

If you prefer the reliability of a wired connection but are uncomfortable stripping 110V wires, the IoT Relay is great. It looks like a power strip but features a green low-voltage terminal block on the side.

How to set it up:

  1. Run two wires from OpenSprinkler (COM and a Station Port) to the green connector on the IoT Relay. It works with both AC-powered and DC-powered OpenSprinkler units.
  2. Plug your pump into the “Normally OFF” outlet.
  3. When the station activates, the outlet turns on.

Pros:

  • Zero Software Configuration: No WiFi configuration to manage.
  • Plug-and-Play: UL-listed and fully enclosed. Safe to use.
  • Reliable: It’s a hardwired connection, so it works even if your WiFi goes down.

Cons:

  • Current limit: Limited to ~12 Amps, which may not meet your pump’s specs.
  • Availability may be limited as there is only one manufacturer.
  • Expanding Cost is High if you need to switch multiple pumps.

4. The DIY Way: 24VAC Relay / Solid State Relay (SSR)

This is the classic “old school” approach. You buy a standard relay with a 24VAC Coil (for AC-powered OpenSprinkler only; or, if using a DC-powered OpenSprinkler, get a DC Solid State Relay). You wire the coil to the OpenSprinkler just like a sprinkler valve, and wire your pump through the relay’s switch contacts.

Pros:

  • Lowest Cost: The cheapest option by far.
  • Reliable: Hardwired connection works even if WiFi fails.

Cons:

  • Safety Hazard: Requires proper enclosure and handling of exposed mains voltage.
  • Wiring Required: You need to handle both low and high voltage wiring.

5. The Heavy Duty Option: Pump Start Relay

  • Best For: Large (1HP+), high power (>1500W), or 3-phase pumps
  • Approx. Cost: ~$50–$80

If you are running a massive well pump or a booster pump for a large lawn, small relays will weld shut due to the “inductive kickback” of the motor. You need a dedicated Pump Start Relay (from brands like Orbit, Hunter, or Rain Bird). These are essentially industrial-grade versions of Option 4, housed in a NEMA-rated outdoor box.

Pros:

  • Robust: Built to handle the massive in-rush current of large pumps.
  • Code Compliant: Safe for permanent outdoor installation.

Cons:

  • Most expensive option.
  • Requires professional hardwiring.
  • Expansion cost is very high.

Summary & Comparison

MethodBest ForWiring EffortSoftware ConfigIsolationCostExpansion Cost (unit)
Shelly / WiFi PlugEase of useNone (Wireless)Medium (WiFi+HTTP setup)Excellent (Air Gap)~$20Medium (~$20)
RFToy+SocketRangeNone (Wireless)Low (RF setup)Excellent (Air Gap)~$40Low (<$10)
IoT RelayWired SafetyLowNoneGood (Internal)~$40High (~$40)
24VAC Relay / SSRLow Cost DIYHigh (Mains Voltage)NoneGood (Coil)~$5Low (~$5)
Pump Start RelayHeavy DutyMediumNoneGood (Coil)> $40High (>$40)

A Complete Guide on Using Triacs to Switch 24VAC

Introduction

More than a decade ago, I published a blog post titled Understanding 24 VAC Sprinkler Valves. In that post, I took a close look at the sprinkler solenoid’s inrush vs. holding currents under 24 VAC, performed theoretical analysis and actual measurements, and explained the difference in the solenoid’s electrical behavior under AC vs. DC. While 24 VAC is a fairly old technology, it is still the standard for landscaping and irrigation projects today. These solenoid valves are cheap, robust, and widely available in home improvement stores.

24VAC Solenoid
Sprinkler Valve

In commercial sprinkler controllers, the most common way to switch these solenoids is by using triacs. Over the years, I’ve received many questions about triacs in sprinkler controller designs. So in this post, I’ll take an in-depth look at how to use a triac to switch sprinkler solenoids, interface it directly with a microcontroller (MCU) such as ESP8266, explain the two common power architectures used in real products, and discuss the choice of gate current-limiting resistors.


Triac Basics

You may already be familiar with transistors, but what is a triac? It is a 3-terminal semiconductor component, much like a BJT transistor or MOSFET, but primarily used to switch AC current rather than DC. With a standard NPN transistor, current flowing into the base-emitter junction “switches on” the transistor, allowing current to flow from the collector to the emitter. When the base current stops, the transistor switches off.

MAC97
BT136
Z0103MN

A triac’s three terminals are named Gate, Main Terminal 1 (MT1), and Main Terminal 2 (MT2). These are analogous to Base, Emitter, and Collector of a transistor. Similarly, current flowing between the Gate and MT1 can turn it on, allowing current to flow between MT2 and MT1. However, there are key differences:

  1. Bidirectional Conduction: When on, current can flow between MT2 and MT1 in either direction. This makes the Triac suitable for switching AC load. In contrast, BJTs transistors conduct current in one direction only.
  2. Bidirectional Gate Triggering: Unlike a transistor, a triac can be triggered not only by current flowing into the Gate, but also by current flowing out of the Gate. In other words, the gate current itself can be bidirectional. This leads to different operating Quadrants depending on signal polarity (see below).
  3. Latching Behavior: When the Gate current is removed, a triac remains ON as long as the current flowing between MT2 and MT1 exceeds a minimum threshold called the holding current. When used with AC, the triac naturally turns off near each zero crossing when the load current falls below this threshold. This also explains why if you try to use a triac to switch DC current, it will only turn on but won’t be able to turn off unless you unplug the power.

The Four Quadrants

Because a triac controls AC power that swings positive and negative, and the Gate can be triggered by either positive or negative current, there are four distinct operating modes, or Quadrants. These are defined by the polarity of MT2 and the Gate, both measured relative to MT1.

  • Quadrant 1 (Q1): Gate Positive (+), MT2 Positive (+)
  • Quadrant 2 (Q2): Gate Negative (-), MT2 Positive (+) 
  • Quadrant 3 (Q3): Gate Negative (-), MT2 Negative (-)
  • Quadrant 4 (Q4): Gate Positive (+), MT2 Negative (-)


Why does this matter? While a triac is a bidirectional switch, it is not perfectly symmetrical on the inside. The silicon structure behaves differently in each quadrant, which means the Gate Trigger Current IGT (the current required to turn the triac on) varies by quadrant:

  • Q1, Q2, and Q3 are the most sensitive: IGT is the lowest in these quadrants.
  • Q4 is the least sensitive, often requiring 2-3x more trigger current than Q1.

Some Example Triacs:

  • MAC97 is a very low-cost, “sensitive-gate” triac commonly used in sprinkler controller circuits. Its IGT in Q1-Q3 is 3-5mA; and in Q4 is 7-10mA (some datasheets omit Q4).
  • BT136 is a higher-power triac. Its IGT in Q1-Q3 is 10mA max, and in Q4 is 25mA.

This matters greatly when driving a triac directly from a MCU’s GPIO pin. Some GPIOs may not source enough current to reliably trigger Q4. Some “High Commutation” (Snubberless) triacs do not operate in Q4 at all. This specific limitation drives the design decisions for the power architecture, as we will see next.


Circuit Design Assumptions

Before moving on, let me state a few assumptions to guide the design choices:

  1. Single Power Supply: The same 24 VAC transformer powers both the solenoid valves and the logic circuits. This assumption is fairly obvious as it’s too cumbersome to require two separate power supplies.
  2. Direct Triac Control from GPIO: As a sprinkler controller can have many zones, to minimize cost, we drive a triac directly by a MCU pin. Alternatives exist—relays, solid-state relays, opto-isolated drivers—but they are bulky, more expensive, some involving moving parts, and unnecessary in a single-supply design where true galvanic isolation does not exist anyway.
  3. Half-Wave Rectification: We use a single diode to convert 24 VAC to DC for the logic. This choice is not primarily about cost—it is essential to make a single-supply triac design work. Specifically, half-wave rectification allows the MCU ground and one side of the AC waveform to share a common reference. Full-wave rectifiers, in contrast, create a “virtual ground” that would short-circuit the triac drive path in this topology.
  4. Continuous Gate Drive: We will hold the gate signal active for the entire duration of the “ON” state, rather than pulsing it at zero-crossings like in classic triac circuits. This simplifies the circuit design. While it slightly increases power consumption, the added dissipation is negligible compared to the solenoid current.

Power Architecture for 24 VAC Sprinkler Controllers

Deriving DC from 24 VAC

The first step is converting 24 VAC into low-voltage DC (5V or 3.3V) to power the MCU and peripherals. This is done using a half-wave rectifier (single diode) and a bulk capacitor, followed by a step-down voltage regulator.

Linear Regulator. In older, non-smart controllers, the step-down regulator is often linear (e.g., a discrete zener-based regulator or a 78xx/79xx chip). This is feasible only if the MCU’s current draw is small. You see, a 24 VAC transformer, under light load, can output an unregulated voltage as high as 30 VAC RMS. This corresponds to a peak voltage of 30*1.414 = 42.4V, which is dangerously high. In fact, if you touch the two wires of the transformer, your fingers may get a tingling sensation!

For a small MCU drawing 10mA, dropping 42.4V to 3.3V dissipates about (42.4V-3.3V)*0.01A = 0.391 W. Not too bad with a decent heat sink. This is why linear regulators are common in legacy controllers.

Switching Regulator. Modern, smart controllers typically have a WiFi or Ethernet chip that can easily draw at least 100mA. This would push the power dissipation to nearly 4W – impractical for a linear regulator. For this reason, modern smart controllers all use switching regulators (e.g., LM2574 or LM2596-class chips) to efficiently step down high voltage without excessive heat. The old-school MC34063 can also be used, though its low switching frequency may cause audible noise under light load.


To directly interfacing a MCU with the triac, there are two topology choices.

Design Choice A: MT1 Tied to the Positive Rail

If you reverse-engineer a legacy non-smart controller (e.g., Orbit 28964), you will typically find:

  1. A negative voltage regulator (e.g., via a zener-based circuit or a 7905 chip).
  2. The triac’s MT1 is tied to the positive rail (MCU’s VCC).
  3. Active LOW Logic: The MCU pulls the gate LOW to turn it on. This is similar to how a PNP transistor works as a high-side switch.

Why did they do this? By tying MT1 to MCU’s VCC, the Gate is always pulled negative to MT1 when active. This forces the triac to operate in Q2 and Q3, both high-sensitivity quadrants. The MCU only needs to sink (and never source) current, which is ideal for older MCUs with weak GPIO capability, including open-drain-only outputs. In addition, GPIOs default to high or Hi-Z at power-on, keeping valves safely off. Finally, as the MCU consumes very little current, a linear regulator is acceptable.

The Downside: Setting VCC as voltage reference results in a negative GND voltage, which can be unintuitive and confusing. Extending the system with sensors and additional hardware (which often assume standard GND) is harder.


Design Choice B: MT1 Tied to GND

Modern smart controllers typically use a standard “Common Ground” topology:

  • The triac’s MT1 is tied to MCU’s GND, much like the NPN transistor’s emitter is tied to GND.
  • Active HIGH Logic: MCU pulls the Gate High to turn it on.
  • The power circuitry uses a standard positive voltage switching regulator.

Why do they do this? Positive voltage switching regulators are more common and cheaper to source than the negative voltage counterparts, especially when a high input voltage rating (>50V) is required. Also, using GND as voltage reference is easier to understand, debug, and extend. 

The Downside: With MT1 grounded, the triac operates in Q1 and Q4. While Q1 is easy to drive, Q4 is the least sensitive quadrant. This is why modern designs almost universally use sensitive-gate triacs such as MAC97 (THT) or Z0103MN (SMD), with Q4 IGT ≤ 7 mA.

When higher-power-rating triacs are needed, you have to watch out for the Q4: if the GPIO cannot provide sufficient IGT in Q4 (in fact, some snubberless triacs don’t support Q4 operation at all), the triac would simply not conduct in half of the AC cycles, resulting in unreliable valve activation and audible noise.


Gate Resistor Selection

To drive a triac directly from a MCU, a gate resistor is required to limit current. The resistor must be small enough to guarantee sufficient IGT in Q4, but large enough to avoid unnecessary power waste or exceeding the MCU GPIO’s current limit.

Assume VCC = 3.3 V, triac’s Q4 IGT = 7 mA (max), Gate forward voltage = 1.5 V (worst-case), we have: RG = (3.3 V – 1.5 V) / 7 mA = 257 Ω.
In practice, values in the 220-330 Ω range should work well.

Using Shift Registers or IO Expanders: When controlling many zones, GPIOs can quickly run out. In this case, adding a shift register (e.g., 74HC595) or I2C I/O expanders (e.g., PCA9535) is a common solution. But be careful: these devices may have much weaker current sourcing capabilitythan GPIOs. Voltage drop under load must be considered, and gate resistors may need to be reduced accordingly. If the required IGT cannot be met, an external transistor gate driver may be necessary.

One additional note: if the I/O expander outputs are pulled high at power-on, it will be necessary to add a strong gate pull-down resistor (e.g., 10 kΩ) to keep the gate LOW at power-on. Otherwise, you will notice the sprinkler solenoids momentarily pop up at power-on, which is undesirable.


Verify Gate Current Using an Oscilloscope

The calculation of gate current above assumes a static measurement, but since the triac is controlling an AC load, the forward-on voltage and gate current are both dynamic. Therefore I decided to take measurements using an oscilloscope to make sure the triac is reliably switched on.

To do so, I made a simple prototype circuit consisting of a 24 VAC to 3.3 VDC switching regulator, a MAC97 Triac, an adjustable gate resistor (100~1100 Ω), a 1 Ω shunt resistor for measuring load current, and a terminal block to hook up a 24 VAC solenoid. Below is a simplified schematic and the actual photo of it.

I hooked up a 4-channel oscilloscope to test points A, B, C, D respectively: A and B are the Gate voltages before and after the fixed 100 Ω resistor; C and D are Load voltages before and after shunt resistor RL. Therefore (VA-VB) / 100 is the gate current, and (VC-VD) / 1 is the load current.

By varying the potentiometer from low to high, I found the point at which the load current starts to miss half of the AC cycles, indicating the triac was still firing in Q1 but failing in Q4. Below are the measurement screenshots. Channels A, B, C, D are displayed in Yellow, Cyan, Purple, and Blue respectively.


When RG = 270 Ω:

All channels (RG = 270 Ω)
Channels A, B, and (A-B) displayed in violet

We can see that (A-B) varies between (1.8-0.88) = 0.92 V and (0.8-(-0.64))=1.44 V, corresponding to 9.2~14.4 mA gate current. This is well above the required trigger current, therefore the triac is fully on.

The “Negative Voltage” Anomaly. You might notice in the screenshots that the Gate voltage VB is negative in some regions, even though the MCU is continuously holding the gate signal High (thus current is flowing into the Gate). At first glance, I was greatly puzzled by this, as it seems to suggest a region of “negative resistance”.

This effect is not caused by the inductive nature of the load—repeating the experiment with a purely resistive load still shows the same negative VB​ behavior. This suggests that the phenomenon is possibly related to the triac’s internal behavior in Q4. Since MT1 serves as the “Ground” reference, when a large current surge flows out of MT1, it can momentarily make the Gate appear negative relative to MT1 (even though current continues to flow into the Gate). Interestingly, as this negative VB happens to occur in Q4 (when current flows from MT1 to MT2), it effectively increases the voltage potential VAB across the Gate resistor, thus it actually helps keep the triac triggered in Q4.

The screenshot below show the direct measurement of VCD. The peak voltage is 0.37 V, corresponding to 260 mA RMS current. This is consistent with the typical holding current of a 24 VAC solenoid.

Direct measurement of VCD (RG = 270 Ω)

When RG = 390 Ω:

All channels (RG = 390 Ω)

With a larger gate resistor, (A-B) now varies between (1.52-0.84) = 0.68 V and (0.2-(-0.92))=1.12 V, corresponding to a gate current of 6.8~11.2 mA. The triac is still solidly on.


When RG = 920 Ω:

All channels (RG = 920 Ω)

This is where things start to collapse. The gate current drops to only about 2.6~2.7 mA. While the triac is still triggering in Q1, it fails in Q4. Consequently, the load current starts to miss half of the AC cycles, clearly visible in the VCD waveform below. The solenoid also begins to make a loud buzzing noise.

Direct measurement of VCD (RG = 920 Ω)

Additional Considerations

There are some additional considerations I omitted above. These are less of a concern for sprinkler controllers, as they run on low voltage (24VAC), but can be important when using triacs to switch general AC loads that are high-voltage and/or high-current.

1. Latching vs. Holding Current Triac’s datasheets distinguish between Latching Current (minimum MT2-MT1 current required to turn the triac on) and Holding Current (required to stay on). With inductive loads like solenoids, current lags voltage. If you were using short pulses to trigger the triac, the pulse might end before the current rises high enough to latch, causing the triac to fail. In our design, however, this distinction is largely irrelevant because the Gate is held active continuously. The triac is retriggered every half-cycle, so precise latching timing is not critical.

2. Critical dV/dt and False Triggering “dV/dt” refers to how fast the voltage across the triac changes. If voltage spikes too fast, the triac can trick itself into turning on without a Gate signal. This can be a major concern when switching a high-voltage load, such as 110 V or 220 V. In our case, however, 24 VAC is a relatively low voltage, thus the risk of false triggering is low. 

3. Snubbers and MOVs / TVS Diodes Sprinkler wires run underground and outdoors, making them giant antennas for lightning and static induction.

  • MOVs or TVS Diodes: It is recommended to place an MOV or TVS diode across the 24 VAC input terminals. This acts as a surge protector, clamping high-voltage spikes before they blow up your triac or even MCU.
  • Snubber: RC snubbers are optional but can further reduce stress on the triac.

Summary

Triacs are a great choice for switching 24 VAC sprinkler solenoids: they are cheap, compact, and have no moving parts for long-term reliability. With careful attention to quadrant operation, gate current, and power architecture, a triac can be driven directly from a microcontroller without opto-isolation or external drivers.

Design Checklist

  • Use a sensitive-gate triac with low Q4 trigger current requirement
  • The MT1-to-GND design is generally preferred for WiFi-enabled designs due to switching regulator availability.
  • Choose gate resistors based on worst-case Q4 IGT, and account for under-load voltage drop if using shift registers or I/O expanders.
  • Add MOV/TVS protection and snubber per triac.

Links


Introducing DC-Powered OpenSprinkler v3.4: The First with USB-C Power

Back in July, we debuted the AC-powered OpenSprinkler v3.4, featuring a new, redesigned enclosure and several hardware improvements (read here). Building on that, today I’m thrilled to unveil the upcoming DC-powered OpenSprinkler v3.4 — the very first OpenSprinkler powered by USB-C! Check out some sneak-peek photos below:

This model shares the same sleek, low-profile enclosure as its AC counterpart. This means it features a single-layer circuit board, two extra sensor ports (SN3, SN4), and an external Ethernet connector for easy installation of the wired Ethernet module.

The key innovation, however, is the move to USB-C as the power source. This change offers several powerful advantages, rooted in our goal of modernizing the sprinkler control circuit.


Why Move Away from 24 VAC?

Traditionally, most sprinkler controllers rely on 24VAC to operate sprinkler valves. This is a dated standard with several notable drawbacks: 24VAC power adapters are heavy, bulky, expensive, and difficult to source outside North America. For international users, finding a compatible 24VAC adapter for their country is a major pain point. Furthermore, their output voltage is unregulated and they lack current limiting circuitry, posing a major risk in the event of a short circuit.


The Origin of DC-Powered OpenSprinkler

When I designed the first DC-powered OpenSprinkler, my goal was to eliminate the dependence on 24VAC and switch to DC power adapters, which are lightweight, compact, inexpensive, and globally available. DC power supplies also include built-in current limiting and protection circuitry — making them safer to use and resilient to faults.

However, to work with standard 24VAC sprinkler solenoids, a DC controller must simulate the behavior of a 24VAC solenoid using DC-only voltage. Specifically, under AC power, a solenoid coil naturally limits its current through inductive reactance:
1. Inrush Current: When the solenoid first activates, it draws a high inrush current (500–700mA) to energize the plunger.
2. Holding current: Once energized, the solenoid requires a lower, stable holding current (200–300mA) to remain open. Under AC power, this reduction happens automatically because the the plunger (now moved in) increases the coil’s inductance, which in turn raises it reactance and limits the current.

To replicate this effect under DC, OpenSprinkler uses a 7.5VDC adapter as its main power source. Since a typical sprinkler solenoid has a coil resistance of 30–40Ω, this voltage naturally produces the 200–300mA holding current required to keep the valve open. To generate the initial inrush current, however, it uses an internal voltage booster to momentarily raise the voltage to 21VDC. This dual-voltage method is essential, because the high inrush current is necessary to reliably open the valve, but if applied continuously, it can overheat the solenoid coil and significantly reduce its lifespan.


Why USB-C is a Game Changer

The DC-powered circuitry is a proven innovation that has allowed users to ditch the outdated 24VAC technology for years. The new v3.4 now takes this a step further by adopting USB-C as its main power source. This introduces three key benefits.

1. Universal Availability

USB-C is a global standard for everything from phones to laptops. This makes sourcing the power adapter incredibly easy, no matter where you are. These adapters are powerful yet lightweight, affordable, and feature built-in protection circuitry.

2. Adjustable Voltage (USB-C PD & PPS)

Modern USB-C adapters are essentially smart, adjustable power supplies. Those that support the PPS (Programmable Power Supply) standard can provide a continuous voltage range (e.g., any voltage between 5.0V and 15.0V). This is a game-changer for optimizing sprinkler valve performance.

Different solenoids have different coil resistances and ideal holding currents. By matching the holding current to the manufacturer’s spec, you prevent overheating (from too much current) and unreliable operation (from too little). With v3.4, you can now calculate and set the ideal input voltage for your specific valves, and the controller will negotiate with the USB-C adapter to provide it. This level of customization ensures best efficiency and reliability. For example:

  • A 30Ω coil (older Orbit valves) with 250mA holding current works best at 7.5VDC
  • A 60Ω coil (newer Orbit valves) with 200mA holding current works best at 12VDC

In previous DC models, you would have to swap the power adapter to match the voltage. With USB-C, the controller automatically negotiates the optimal voltage from a single USB-C power source.

3. Mistake-Proof Design

Previous DC models used a standard barrel jack. Despite our best effort to prevent mistakes, some users would accidentally plug in a 24VAC adapter (simply because the plug fits in), resulting in damage. USB-C completely eliminates that risk: an AC adapter plug physically cannot fit into a USB-C port.


FAQ

Q: When will it be available?
A: We are now accepting pre-orders for the DC-powered v3.4, with shipments expected by mid-November 2025.

Q: How does the controller customize the input voltage?
A: It has a built-in USB-C Power Delivery (PD) chip that negotiates the requested voltage directly with the USB-C adapter.

Q: How can I determine the ideal voltage to set for my valves?
A: Multiply your valve’s holding current by its coil resistance. Example: 250mA × 35Ω = 8.75VDC.
The holding current is typically specified in the valve’s datasheet. The coil resistance is also in the datasheet, or otherwise can be measured using a multimeter.

Q: Can I use any USB-C charger? What if mine doesn’t support PPS?
A: If the adapter supports PPS, the voltage can be set precisely. If your adapter only supports fixed voltages (5 V, 9 V, 15 V, etc.), it will select the nearest match.

Q: Does v3.4 still include an internal voltage booster?
A: Yes. The controller still needs to reliably generate an impulse voltage (21VDC) for the inrush current, which not all USB-C adapters can provide. The internal booster remains, ensuring consistent performance regardless of your charger’s capabilities.

Q: How much current can it support?
A: This is determined by your USB-C adapter’s power rating. A standard 18W adapter can provide roughly 2A at 9V, while more powerful (30W) adapters can supply even more current.

Q: Can I still use my 7.5VDC adapter with a barrel plug?
A: Yes, you can use a simple dc-female-to-USBC adapter like the one shown below. It’s a simple pass-through adapter and does NOT do any voltage conversion. However, note that the input voltage will be fixed at your adapter’s rating (e.g., 7.5V) and will not be adjustable.

Q: How can I power v3.4 using a 12VDC solar setup?
A: If your solar power source has a standard barrel plug, you can use the same dc-female-to-USBC adapter shown above.

Q: Which expander is it compatible with?
A: Fully compatible with DC Expander v3, just like previous v3 models.

Q: Will DC v3.3 still be available?
A: Yes, we will continue selling the v3.3 model while supplies last. In the meantime, we will keep offering the v3.3 circuit boards without an enclosure for repairs and DIY projects.

Q: Can I reuse my existing wired Ethernet module?
A: Yes — it uses the same W5500 Ethernet module as v3.3.

Q: I recently bought an OpenSprinkler DC v3.3. Can I exchange it?
A: Yes, if your purchase was made within the last 30 days, it qualifies for an exchange under our no-questions-asked return policy. Please see our terms and conditions for details.


Introducing AC-Powered OpenSprinkler v3.4

Exciting news! We’re gearing up to launch a new hardware revision of the AC-powered OpenSprinkler: introducing version 3.4 — a sleek, refreshed take on the ESP8266-based OpenSprinkler. While it retains the same familiar circuit as the current v3.3, version 3.4 features a completely redesigned enclosure for a refreshing new look. Check out the sneak peek photos below!


TL;DR – What’s New in OpenSprinkler v3.4:

  • Single-layer circuit – Replaces previous 2-layer design to reduce assembly time and cost
  • Revised enclosure size – Lower profile and adjusted dimensions due to circuit layout change
  • Two extra sensor ports (SN3, SN4) – Added to standardize parts and simplify sourcing
  • Switched to power barrel jack – Easier power adapter hookup, no wire stripping required
  • Added external Ethernet connector – Simplifies wired Ethernet module installation

The most significant update in version 3.4 is the shift from a two-layer circuit design—consisting of a top logic board and a bottom driver board—to a streamlined single-layer layout. Originally, the two-layer design in OpenSprinkler v3 was introduced to support interchangeable driver boards (AC-powered, DC-powered, and Latch), allowing the same logic board to interface with various solenoid types. While this approach offered flexibility, it also made assembly more complex and time-consuming. In version 3.4, we’ve consolidated the design into a single board, significantly simplifying assembly and improving overall efficiency.

As a result of the single-layer layout, the enclosure height is noticeably reduced: from 33mm (1.3in) to 25mm (1in). The length is slightly reduced, and the width is moderately increased from 56mm (2.2in) to 79mm (3.1in).

The circuit design in version 3.4 remains largely unchanged from v3.3. However, one notable enhancement is the addition of two new sensor ports: SN3 and SN4. This upgrade is driven partly by the aesthetics of the new enclosure and partly by the decision to use the same 8-pin terminal block as the zone ports. This simplifies part sourcing and reduces inventory management overhead. Initially SN3 and SN4 will be inactive, and they will be enabled in a future firmware update.

Another improvement is the change to the power input port. The current orange 2-pin terminal has been replaced with a red-colored power barrel connector. Since most 24 VAC power adapters—including the one we provide—come with a standard plug, this change allows users to plug in power directly, eliminating the need for using an adapter cable or stripping wires, which has been a common pain point for some users.

Finally, an external connector for the wired Ethernet module has been added to the right side of the enclosure, making installation much more convenient. Previously, the Ethernet connector was located on the internal circuit board, requiring users to open the enclosure, plug in the cable inside, and route it through a small opening—a process that was quite cumbersome. You see, when OpenSprinkler v3.0 was first introduced, I didn’t plan to have wired Ethernet as ESP8266 already provided built-in WiFi. But in response to strong user demand, I improvised a solution by adding an internal connector and repurposed an opening—originally intended for a now-removed RF receiver—to route the cable outside. While the workaround was functional, it was far from ideal. With version 3.4, the enclosure finally includes a dedicated external connector, making Ethernet installation simple and user-friendly.

Below are side-by-side comparisons of v3.3 and v3.4:


Other Questions You May Have:

Q: When will it be available?
A: We’ve started accepting pre-orders for OpenSprinkler v3.4, with shipments expected no later than mid-July 2025.

Q: What are the exact dimensions of the v3.4 enclosure compared to v3.3?
A: The new enclosure (v3.4) measures 125mm (L) × 79mm (W) × 25mm (H), or 4.9in × 3.1in × 1in. For comparison, the v3.3 enclosure is 140mm x 56mm x 33mm, or 5.5in x 2.2in x 1.3in.

Q: What about OpenSprinkler DC and Latch models?
A: Version 3.4 of the DC and Latch models are in development and expected to be ready by August November 2025. Until then, we’ll continue selling version 3.3 of these two models. The new models will not only feature the updated enclosure, but switch to a USB-C power adapter for better availability and ease of use.

Q: Which expander is it compatible with?
A: OpenSprinkler v3.4 is fully compatible with Expander v3, just like previous v3 controllers. If you already own Expander v3, it will continue to work seamlessly.

Q: Will version 3.3 still be available?
A: Yes, temporarily. We’ll continue selling v3.3 while supplies of its enclosure last. After that, we plan to offer v3.3 circuit boards without enclosures for repair purposes and DIY projects. We’ll also provide 3D design files for the v3.3 enclosure so users can print or order the enclosure as needed.

Q: Will version 3.4 require different firmware?
A: No. All OpenSprinkler v3 controllers use the same firmware. The system automatically detects the hardware version and make software adjustments accordingly.

Q: Can I use my existing wired Ethernet module from v3.3?
A: Yes. Version 3.4 uses the same W5500 Ethernet module as v3.3, so it remains fully compatible.

Q: I have an existing 24VAC power adapter with stripped wires. Do I need a new adapter?
A: Not necessarily. You can use a plug adapter to convert the stripped wires into a standard male barrel plug. Here are two common options: (the search terms are “power jack plug adapter” or “power pigtail barrel“).

Q: I just bought an OpenSprinkler AC v3.3 recently. Can I exchange it for v3.4?
A: Yes, as long as your purchase was made within 30 days, which qualifies under our no-questions-asked return and refund policy (see our terms and conditions). Please note that in terms of functionality and circuit design, v3.3 and v3.4 are nearly identical, aside from the two additional sensor ports on v3.4.


Using OpenSprinkler DC with Power-over-Ethernet (PoE)

Occasionally, we encounter application cases where users want to utilize Power-over-Ethernet (PoE), which allows a single Ethernet cable to deliver both network connectivity and electrical power. This setup eliminates the need for a separate power line, making it especially useful in remote or hard-to-reach locations where running additional cables is difficult. To enable PoE, a PoE switch injects voltage—typically 48VDC—into the Ethernet cable, which then carries both data and power. At the receiving end, a PoE-compatible power circuit is needed to step the voltage down to a usable level, such as 12VDC. OpenSprinkler does not natively support PoE, as its Ethernet module and power circuitry do not comply with PoE standards. However, you can use an off-the-shelf PoE splitter to separate the power and data: the splitter outputs 12VDC and a standard Ethernet signal (without the 48VDC). Since OpenSprinkler DC operates on 12VDC, this makes it compatible with a PoE switch when used with a suitable splitter.

The image below shows a typical PoE splitter. One end features an Ethernet receptacle where the PoE cable is connected. The other end splits the signal into two outputs: a 12VDC power plug and a standard Ethernet connector. The 12VDC plug connects to the power barrel of the OpenSprinkler DC, while the Ethernet connector plugs into the wired Ethernet module.

The diagram below illustrates the complete setup. With this configuration, a single Ethernet cable can deliver both power (for the controller and solenoids) and data connectivity. We’ve successfully tested this setup using a TP-Link 4-port PoE switch, a PoE splitter rated for 12VDC at 2A, and an OpenSprinkler DC with a wired Ethernet module—it worked flawlessly. Please note that this setup is only compatible with DC-powered OpenSprinkler models (including OpenSprinkler Latch), as they can operate directly on 12VDC. It is not suitable for OpenSprinkler AC, as there is no straightforward way to convert 12VDC to the required 24VAC.

Why WireSprout only works with AC-powered OpenSprinkler

Recently through a customer I learned about a product called WireSprout, and it only works with the AC-powered OpenSprinkler but not the DC-powered version. Out of curiosity, I looked into why this is happening. So what is WireSprout? Simply speaking, it allows individually controlling 2 zones using a single zone wire. This is useful in situations where some of your zone wires are broken and it’s too much hassle to repair the broken wires. Let’s say you have 2 zones, but only 1 good zone wire. Using WireSprout, you to control both zones using the single good zone wire. This works on any sprinkler controller (well, as you will see later, as long as it’s an AC sprinkler controller). A single WireSprout pack contains a pair of two ‘sprouts’. Each sprout is a tiny little circuit wrapped in heat shrink tubing, and has 3 wires: 1 blue and 2 green wires. Below is the diagram that shows how to connect it to a sprinkler controller:

To be fair it’s not adding more zones — to control 2 zones you still need to take 2 zone ports on the sprinkler controller. Also it requires the Common (COM) wire to be a good (i.e. non-broken) wire. But what it helps with is to reduce the number of zone wires. Note that it can only go with a pair of 2 zones. For example, if you want to control 4 zones, you need another good zone wire and another pack of sprouts. It unfortunately cannot allow you to control 4 zones with a single good zone wire.

Each sprout is very small, so likely it only contains a few electronic components. Also, it’s very general — it can work with any AC sprinkler controller, so the circuit doesn’t rely on the knowledge of any specific controller. It also works only for 2 zones at a time. Finally according to the customer, it doesn’t work with DC-powered OpenSprinkler, only works with AC-powered version. So it must rely on the property of AC to work. I googled similar products, and after a bit of research, it became clear to me that the circuit is indeed extremely simple. Each sprout is essentially two diodes in series, where the two ends are the green wires, and the center (between the two diodes) is the blue wire. Below is what I believe each sprout contains internally:

So how does it work all together? Here is the diagram:

Because the output voltage is AC, it has positive and negative cycles. As you can see, on the positive cycle of the COM wire, if Zone 2 port is on, the two diodes circled green will turn on. So the current flows from COM to Solenoid 1 through the Common wire, then through the zone wire to Zone 2 port. The other two diodes are reverse biased therefore solenoid 2 cannot turn on even if Zone 1 port is on. Conversely, on the negative cycle of the COM wire, the situations with all diodes are flipped, so only Solenoid 2 can turn on (assuming Zone port 1 is on). In this particular arrangement, Zone port 1 controls Solenoid 2, and Zone port 2 controls Solenoid 1. If you want them to correspond to each other (i.e. 1 -> 1 and 2 -> 2), just horizontally flip one of the sprouts.

In short, the WireSprout works by leveraging the fact that AC waves have positive and negative cycles. By using diodes, it can cleverly block half of the AC waves, therefore Solenoid 1 can only turn on during the positive cycles, and Solenoid 2 can only turn on during the negative cycles, or vice versa. Thus these two zones can be individually controlled.

Now it’s obvious why the DC-powered OpenSprinkler can’t work with WireSprout: DC-powered OpenSprinkler outputs DC-only voltage, there are no positive or negative cycles — there is only positive voltage. Therefore WireSprout can’t leverage the negative cycles to disable one of the solenoids therefore it cannot achieve individual control of 2 solenoids using a single zone wire.

There is possibly a downside of this method: each solenoid only get half of the AC waves as opposed to the full wave normally. Would this cause any reliability issues? I am not sure, but it seems there hasn’t been any reported issue so far.

Finally, we can also explain why WireSprout always works in pairs of 2 and not more than that: if you want to control, say 4 solenoids with a single zone wire, that would require counting the parity of the AC waves, which would be much more complex and may require an active circuit.

Announcing OpenSprinkler Firmware 2.2.0(1)

Today we’ve officially released OpenSprinkler firmware 2.2.0(1). As you may have noticed on this forum post, this firmware is a major revision from the previous firmware 2.1.9. Most of the new features are thanks to Valeriy Soltan’s excellent work almost 2 years ago (I know, time flies during the pandemic), including support for sequential groups, setting a date range for each program, support for pausing and resuming stations, shifting zones forward, more flexible master on/off adjustment times etc. In addition, we’ve added a device name parameter, which is included in all IFTTT notifications; and a new weather adjustment method called ‘Monthly’ adjustment is added to set a manual watering percentage per month. For OpenSprinkler 3.x only — one major step forward is the support of OpenThings Cloud (OTC) token, which allows remote access via the OTC cloud server. This eliminates the need for settings up port forwarding, which has been a pain for manual users. OTC has been enabled for our OpenGarage product for a while, and it seems to be working pretty well, so this is a good time to enable OTC for OpenSprinkler as well. A major benefit of OTC is that the same web interface / UI is available both locally and remotely, and OTC server serves as a real-time ‘relay’ between the firmware and user, it doesn’t actually store any date on the cloud server. Another step forward for OpenSprinkler 3.x is upgrading ESP8266 core to version 3.0.2 (the latest ESP8266 core for Arduino). In important benefit of this is that the WiFi and wired Ethernet are unified, through the lwip library available in this core version. As a result, wired Ethernet and WiFi use exactly the same interface functions, so all WiFi features (including OTA update) are also supported by wired Ethernet. Moreover, this allows OTC to be supported by both WiFi and wired Ethernet as well.

We’ve release a test version of firmware 2.2.0 a month ago and since then have been working on fixing bugs both in the firmware and the UI. At this point, the firmware is ready to be released to the public, and we are really excited. The full list of new features can be found in the Github release notes. As usual, firmware update instructions can be found on our support website at support.opensprinkler.com Since this firmware is very new, bugs and issues are probably inevitable. If you encounter any problem, please be patient and file a support ticket at support.opensprinkler.com We will try to handle them as quickly as we can.

Learning Electronics — I/O expander options

It’s hard to believe that two years have gone by since my last post. Lots of things happened during these two years: on the good side, we have our first baby born during a year of pandemic, and he is bringing joy to the family every day. On the bad side, there is a pandemic, which brought so many challenges, from supply chain issues to shipping delays and to the difficulty of finding available employees to hire. The pandemic has also taken a huge roll on my mental health, significantly limiting my productivity and creativity.

This post is my attempt to resume regular blogging, a habit that I’ve always enjoyed in the past but was lost during the two terrible years. I am hoping this will motivate me to continue learning and sharing new knowledge about electronics, and continue to provide new passion in my life.


In this post, I will briefly summarize I/O expander choices I’ve considered when designing the OpenSprinkler circuits, and the pros and cons of each choice. I/O expanders are often necessary when the microcontroller’s I/O pins are insufficient for the application. For example, a sprinkler controller may need a large number of output pins in order to drive many zones independently. This is the reason that from the very first version of OpenSprinkler, I’ve decided to use an output expander, to allows the number of zones to be scalable and not limited by the available I/O pins on the microcontroller itself.

74HC595 Shift Register

The most common choice for increasing output pins is to use a 74HC595 shift register, or more precisely: serial-in, parallel-out shift register. 74HC595 is cheap, widely available, and quite simple to connect to a microcontroller like Arduino. Each chip adds 8 output pins, and you can daisy chain them to almost any number, limited only by the potential signal degradation/distortion when cascading too many of them. At the minimum, a microcontroller only needs to use 3 pins to interface with any number of daisy chained shift registers. These pins are named LATCH, CLOCK, and DATA, which are essentially CS, CLOCK, and MOSI pins in SPI terms. You can begin the data transfer by setting LATCH pin low, then at the rising edge of each CLOCK cycle, the HIGH or LOW signal presented on the DATA pin is transferred to the first storage register, while the data already transferred in previous clock cycles are shifted down to the next storage registers respectively, hence the name ‘shift register’. After 8 clock cycles, 8 bits of data are shifted in. Finally set the LATCH pin high, upon which the values in the storage registers are transferred and presented on the output buffers. You can bit bang the pin values, use Arduino’s built-in shiftOut function, or if CLOCK and DATA pins happen to be connected to the microcontroller’s SPI CLK and MOSI pins, you can use SPI functions for even faster operation.

One advantage of 74HC595 is that it has a separate set of storage registers vs. output latches (aka output buffers). During data transfer, this allows the output values remain stable and not affected by the data that’s being shifted in. The output values only update upon the rising edge of the LATCH pin. This compares favorably to other shift registers like 74HC164 that are even cheaper but don’t have output latches (thus the output values may flicker during data transfer and such the flickering would be problematic for output devices like sprinkler solenoids).

Pros:

  • Very cheap (a couple of cents in bulk pricing) and widely available.
  • Can be daisy chained to enable a large number of output pins
  • Relatively small number of microcontroller pins required to interface with it.

While the list of pros makes it sound like this is the perfect choice for almost any application, there are also a number of cons which are somewhat subtle but important for sprinkler controllers.

Cons:

  • 74HC595 is output only, it does not support input pins (for that there are dedicated parallel-in, serial out shift registers, basically the opposite of 74HC595).
  • Maximum output current is small — according to the datasheet, each output pin can only source or sink up to 4~7mA, depending on the supply voltage. If the output device is a transistor or MOSFET, this is more than sufficient. But on AC-powered OpenSprinkler, the output device is a traic, such as MAC97 or Z0103MN, which require relatively large gate current, and 4~7mA is only barely enough.
  • Upon powering up, the output states are not deterministic — this means if LEDs are connected as output devices, they may have a brief moment of flickering upon powering up; similarly if the output devices are solenoid drivers like traics, some solenoids may be momentarily activated until the microcontroller clears out the output buffer. This problem can be alleviated by using an additional pin — the output enable pin — to disable the output latches upon powering up, but the downside is this requires another microcontroller pin.
  • The communication between microcontroller and shift register is one-way, so it’s difficult for the microcontroller to detect or enumerate how many shift registers are connected. On OpenSprinkler, I had to use an analog pin in conjunction with a parallel resistor per shift register to be able to detect/enumerate the number of shift registers. This is a downside, particularly if the microcontroller is short of analog pins.

I2C I/O Expanders (such as PCF8574/8575/PCA9555/9535)

Due to the advantages of 74HC595, I used it on the legacy versions of OpenSprinkler (1.x and 2.x) for many years, until I had to move on to switch the microcontroller to ESP8266, in order to support built-in WiFi. Suddenly the cons of 74HC595 became a show stopper, partly because ESP8266 has a much smaller number of GPIO pins, so I could not afford to spare many GPIO pins to interface with 74HC595; and partly because ESP8266 has only one analog pin, which has to be used for solenoid current sensing, thus cannot be used to detect/enumerate the number of expanders.

This is where I discovered there are a large family of I2C I/O expanders. In fact NXP has a document that nicely summarizes the various choices. Most of them differ by the number of I/O pins available, output type, maximum output current, the availability of pull-up resistors on each pin. The output type is quite interesting: some of them use push-pull (i.e. Totem-poll) which means they can both source and sink a large amount of current (i.e. strong current sources and sinks); some of them (e.g. Quasi-output) can sink a large amount of current but only source a small amount of current (i.e. strong sinks but weak sources); some of them (e.g. open-drain) can only sink current but not source current at all.

Most of the pros and cons below are exactly the counterparts of the cons and pros of 74HC595 respectively.

Pros:

  • Each pin can be configured as either input or output, so with a single I/O expander chip, some of the pins can be configured as outputs to drive triacs or MOSFETs; while others can be configured as inputs to read sensor values or button statues.
  • All of them interface with the microcontroller through I2C, therefore they require only the SDA and SCL pins from the microcontroller, and the same two pins can be shared with other I2C devices such as real-time clock, OLED display etc. This is particularly suitable for ESP8266, on which the number of GPIO pins are very limited.
  • Using I2C almost means the communication is bidirectional — the microcontroller can detect and enumerate the number of I/O expanders connected to it.
  • Another advantage of I2C is that each I/O expander has a unique I2C address, so by carefully allocating the address of each expander, the microcontroller can detect which type of OpenSprinkler (AC-powered, DC-powered, or Latch) by reading the I2C address.
  • The I/O pins on these expanders can source or sink a large amount of current (up to 25mA), which is more than sufficient to drive triacs. Well, not all of them though: when designing OpenSprinkler 3.0, I was only aware of PCF8574 and PCF8575, which are weak current sources, so they have to be combined with PNP transistors or P-ch MOSFETs to source a large number of current. By the time I started designing OpenSprinkler 3.1 and 3.2, I became aware of PCA9555 and PCA9535 — they are strong current sources so there is no longer need for additional transistors or MOSFETs.
  • Upon powering up, the output states are deterministic — in fact, the outputs are always high upon powering up, with weak pull-up resistors. This makes it possible to overcome the flickering issue at powering up.

Cons:

  • They are relatively expansive (a dollar or so in bulk pricing). While this may not seem much, it does stand out quite significantly when compared to the pricing of 74HC595. Also, the chip shortage caused by the pandemic has made them even more expensive and frequently out of stock. In contrast, it hasn’t affected the pricing or availability of 74HC595 much.
  • Because each expander must have a unique I2C address, and each chip (e.g. PCA9555) only has 3 bits of address pins, this means you can only connect up to 8 expanders chips. This is also a disadvantage compared to 74HC595 where you can daisy chain virtually unlimited number of expanders. Despite this limitation, I decided this is a worthwhile compromise to make for OpenSprinkler as the total number of zones per controller is usually not that much.

Among all the I2C expander chips, PCF8574/8575/PCA9555/9535 are relatively more common and available. The differences between them are:

  • PCF8574 has 8 I/O pins, and PCF8575 has 16. Both of them are of Quasi-output type, so they can sink but not source a large amount of current. They were used for OpenSprinkler 3.0 controller and zone expanders.
  • PCA9555 and PCA9535 both have 16 I/O pins, and both use Totem-poll output, so they can both sink and source a large amount of current. They are used in the current OpenSprinkler 3.2 controller and zone expanders. The only difference between the two is that PCA9555 has built-in pull-up resistor while PCA9535 does not. Thus for any pin configured as input, PCA9535 requires an external pull-up resistor.

CH423s I2C I/O expander

Recently I discovered a very low-cost I2C I/O expander CH423s. It’s made by a Chinese company QinHeng which is famous for making the low-cost USB-serial chip CH340. CH423s has a bulk pricing of about 20 cents, and it has 16 output only pins with 8 additional input/output pins. So it’s a quite capable and versatile chip. However, after reading its datasheet and understanding the sample programs, I found it has a big downside, that is it takes over too many I2C addresses. This is a quite strange design of the chip — unlike PCA9555/PCA9535 (each of which only takes over one I2C address, and you can configure the input/output of each pin by settings configuration registers), CH423s uses multiple I2C addresses to eliminate the need of configuration registers. While it is relatively easy to program, the large span of I2C address space makes it infeasible when the same I2C bus has to be shared with other devices like real-time clock and OLED display, which may conflict with its address space. Also, there are not configuration bits for the I2C address, so it’s not possible to use it on zone expanders. Nonetheless, this is an interesting choice to consider for some applications, if the I2C address space is not a problem.


1-Wire I/O expanders (DS2413/DS2408)

Wouldn’t it be nice if the microcontroller only needs one-pin to communicate with I/O expanders? It turns out such an option does exist! Take a look at the 1-Wire I/O expander chips: DS2413 supports two I/O pins, and DS2408 supports 8 I/O pins. They interface with a microcontroller through a single data wire, hence the name 1-wire. Probably the most well-known 1-wire device is the DS18B20 temperature sensor. While this may not seem a lot of I/O pins, each chip actually has a globally unique address, so you can connect virtually unlimited number of these chips, all sharing a single data line! These chips were brought to my attention by Patrick Morse — he proposed this as a solution to implement Hunter’s EZ Decode system. In fact, before his email, I’ve from time to time received requests to develop a 2-wire decoder system — similar to I2C, 2-wire decoders use a clock line and data line to transfer signals between the microcontroller and the solenoid driver. This is an attractive solution for applications where it’s a hassle to install a large number of long copper wires between the sprinkler controller and each solenoid. 2-wire decoders solve the problem by connecting all solenoid serially using only 2 data lines. Each decoder would have a unique address just like in the case of I2C. The microcontroller sends commands to discover the unique address of each decoder connected on the bus, and consequently can switch each solenoid valve independently. The 1-wire decoder would be a further simplification by reducing one data wire. The commercially available 2-wire decoders generally use proprietary communication protocols that are not open-sourced. The existence of DS2413 and DS2408 means we can easily implement a 1-wire decoder using well-documented 1-wire protocol. That’s great!

Pros:

  • Using one single data line, suitable for implementing 1-wire decoders that can significantly save the amount of copper wires required in a sprinkler system.
  • Each chip has a globally unique 1-wire address, making it possible to connect a large number of chips all sharing the same data line. By detecting the 1-wire address, the microcontroller can detect and enumerate each chip.

Cons:

  • Relatively expensive: DS2413 has a bulk pricing of close to 2 dollars, and it only supports 2 I/O pins. Also they are less commonly used so more prone to chip shortage issues.

While it’s possible to interface with these devices by directly using a microcontroller pin (through the open-source 1-wire library), it may be better to use a 1-wire master chip, which interface with the microcontroller through I2C and it can talk to 1-wire devices using a more robust data line. The 1-wire master chip is particularly useful for ESP8266, which doesn’t have many GPIOs, so it may be necessary to delegate the communication task to a separate chip.


To conclude, this posts summarizes some of the I/O expander options I’ve considered when designing OpenSprinkler circuits, and the pros and cons of each. In the case of OpenSprinkler 3.x, the design decisions were largely driven by the limited number of pins on ESP8266. With other microcontrollers that are not short of GPIO pins, 74HC595 may still be the most attractive choice due to its many advantages and the significantly lower cost.

How to Switch Gardena 1251 Latching Valve using OpenSprinkler Bee (OSBee)

Update: the technique described in this article is possibly no longer necessary for the current version of OSBee, as it now supports setting a different opening vs. closing voltage.


Recently when helping a customer, I came across an interesting case of how to control Gardena 1251 latching solenoid valve using OpenSprinkler Bee. This valve is mostly sold in the European market and isn’t very popular in the US market. On spec, it’s operated using a single 9V battery, and to use this valve you need to buy a Gardena 1250 controller unit. The whole assembly including the valve and controller unit are quite pricy (close to 100 bucks), so it’s not a very cost-effective solution compared to other brands. Nonetheless, it’s an interesting case that helped me understand how these latching solenoids work.


Measure the Control Voltages

The initial request to look into this valve was due to the fact that OSBee can’t seem to operate this valve correctly: it can open the valve but never manages to close the valve. This was reported by a German customer, and it caught my curiosity. To figure out the issue, the first thing I did was to check how the control unit (1250) is sending out control voltages to the valve. It’s pretty common that when operating latching solenoid valves, the control circuit sends an impulse voltage to open the valve, and another impulse voltage in the reverse polarity to close the valve. On most solenoid valves I’ve seen, the two impulse voltage (of opposite polarity) are roughly the same, and that’s also how the OSBee circuit works.

Upon connecting the control unit to an oscilloscope, I noticed something strange: no matter how I press the on/off button, it’s only sending a very short (a few milliseconds) pulse, which cannot possibly operate the valve. Then it became clear to me that the controller is in fact actively sensing the existence of the valve, and would not send control voltages if the valve is not detected. I measured the resistance of the solenoid valve, which is about 35 ohm. So I connected a 33 ohm resistor to the controller as a dummy load, and there you go, now we can observe the control voltages and pulse lengths.

It’s pretty easy to notice the asymmetry here: while opening the valve requires a pulse of 250 ms and -7.84 voltage (this is roughly the battery voltage since my 9V battery isn’t fully charged), closing the valve only requires a very short pulse of 62 ms and very low voltage — 2.5V. This is quite strange to me: how come closing the valve only requires such a short pulse and such low voltage?


How Does This Latching Valve Work?

In order to figure out what’s going on here, I un-tightened a bunch of screws and opened up the valve.

At the bottom of the valve is a pressure chamber with a spring. This is very similar to other valves I’ve seen.

The top section contains, supposedly, a coil and magnet inside, and a small cone-shaped metal piece that can be attracted to the magnet or released. It’s quite easy to observe that when opening the valve, the metal piece gets attracted (left picture above), this supposedly releases the pressure in the bottom chamber, thus allowing the water to flow through the valve. Conversely, when closing the valve, the metal piece is released and dropped to block the hole at the bottom, this supposedly allows water pressure to build up in the bottom chamber, thus stopping the water flow.

The key in making this latching is that an impulse voltage can permanently magnetize the core, thus permanently attracting the metal piece. This makes it possible for the valve to remain in the ‘open’ status without contiguously drawing current from the power source (which is unlike non-latching valves like 24VAC valves).

Observing this mechanism, it became clear to me that ‘closing’ the valve basically requires de-magnetizing the core, and that requires just a short pulse of low voltage in the opposite polarity. If you apply the same voltage and strength as before, it will start magnetizing the core the other way, thus the magnetic pole changes direction but the metal piece will still be permanently attracted!

Anyways, this is very interesting to me because previously I had no idea how latching solenoid valves work internally. Now at least I know understand this particular valve works, and this understanding will help me figure out how to get OpenSprinkler Bee to control this valve.


Use OSBee to Control the Gardena 1251 Valve

There are several issues that make OSBee incompatible with the Gardena 1251 valve, but it turns out they can all be solved without too much difficulties. The first is that OSBee by default boost the input voltage (which is 5V from USB) up to 22VDC, which is significantly higher than 9V required by the valve. This is reasonably easy to solve — by fine tuning the boosting time, I can find the sweet spot where the boosted voltage is just around 9V. This boosting time turns out to be around 80 to 100ms.

Second, OSBee by default uses 100ms pulse in both directions (i.e. both opening and closing the valve). This is very easy to change to 250ms and 62ms respectively to match the Gardena controller.

The last issue deserves more thinking, that is, opening the valve requires 9V, but closing the valve requires only 2.5V. Because the input voltage is from USB and it’s 5V, there is no obvious way to step that down to 2.5V since the boost converter can only bump up the voltage and never reduce the voltage. How do we create this asymmetric voltage in opposite polarities? Turns out that you can do so by making use of a diode connected in parallel with a 100 ohm resistor. Why? The diode is a one-way gate: when positively biased, it turns on almost fully (except the 0.7V voltage drop across it, which can be ignored here); but when reversely biased, it turns off, thus current has to flow through the resistor (connected in parallel to the diode), and that resistor will divide the voltage, ensuring that only about 2.5V falls on the valve.

I’ve attached here a diagram showing the connection. The diode can be almost any general-purpose rectifier, like 1N4148, 1N4001 and so on. I’ve also included two photos showing the actual components connected to OSBee and the valve. With this modification, OSBee can now both open and close the Gardena 1251 valve successfully. Mission accomplished!