Feed on
Posts
Comments

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

Tags: , , ,

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.

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!

Today I am very excited to introduce OpenSprinkler Bee (OSBee) 2.0: it’s an open-source, WiFi-enabled, universal sprinkler controller. It is suitable for garden and lawn watering, plant and flower irrigation, hydroponics, and other types of watering project. This is the first OpenSprinkler product built upon the popular ESP8266 WiFi chip. It’s designed primarily for latching solenoid valves, but can also switch non-latching solenoid valves (such as standard 24VAC valves), low-voltage fish tank pumps (which can be used to feed water to flower pots and indoor plants), and other types of low-voltage DC valves and pumps. All of them can be powered from a single USB port. This is made possible by using a unique circuit design that leverages a boost regulator and a new solenoid driver circuit. Hence I call it a Universal sprinkler controller. Among the software features, it introduces the concept of Program Tasks, which provides maximal flexibility in programming the zones. In contrast to the first version of OSBee, which was in the form of an Arduino shield and relies on an additional Arduino, OSBee 2.0 is a standalone controller with built-in WiFi, OLED display, laser cut acrylic enclosure, and can switch up to 3 zones independently.

Here is not-so-short video introduction to OSBee 2.0:

Here are two photos of the OSBee 2.0 circuit board:

osbeewifi_1osbeewifi_2

Screenshots of the web interface and Blynk app:
osbee_screenshots

In summary, in terms of Hardware Design, it has the following features:

  • A single ESP8266 chip serves as the microcontroller and handles WiFi connectivity.
  • On-board 128×64 OLED display, real-time clock with backup battery, USB-serial chip. Can switch up to 3 zones independently.
  • Boost converter and a new H-bridge design that allows the same controller to switch both lathing and non-latching solenoid valves, all powered from a single 5V USB port.
  • An easy-to-assemble laser cut acrylic enclosure.

In terms of Software Features:

  • It has a built-in web interface that allows you to easily change settings, perform manual control, and create automatic sprinkler programs. It also provides logging and program preview features.
  • It introduces Program Tasks to allow maximal flexibility in programming zones. For example, you can define arbitrary ordering of zones, have multiple zones run at the same time, and insert delays between tasks. Zone water time is programmed at precision of seconds.
  • It allows remote control through the Blynk app and Blynk cloud server.
  • Firmware update can be performed either wirelessly using the web interface (OTA), or through the on-board USB port with a USB cable.

It improves upon the current OpenSprinkler 2.3 by adding built-in WiFi capability, and using a unified solenoid driver that can handle both latching and non-latching solenoid valves. On the other hand, it can only switch up to 3 zones, and the number cannot be expanded. It’s also missing a few advanced features at the moment, such as weather-based water time, virtual stations (e.g. HTTP and RF stations), and support for sensors. Some of these features are purely software, and can be easily added in the future.

OpenSprinkler Bee 2.0 is now available for purchase at our online store:

The package includes a fully assembled OSBee 2.0 circuit board, laser cut acrylic enclosure, instructions, USB cable, and optionally an USB adapter.


Resources and Technical Details

OSBee 2.0 is an open-source project. Its hardware schematic, firmware source code, user manual, and API document are all available at the OpenSprinkler Github repository (look for the prefix OSBee in the repository).

Below I will briefly go over the technical details of the boost converter and the solenoid driver, as I think it’s an interesting design that’s potentially applicable elsewhere. The boost converter is borrowed directly from the OpenSprinkler DC circuit. It’s a simple MC34063-based boost regulator that bumps the input 5V up to 24V DC, and stores the charge into a 2200uF capacitor.

osbee_circuit_1

The Booster is controlled by two MOSFET-based high-side switches. The first one controls the input power: the microcontroller uses it to feed the input 5V to the booster, which quickly raises the voltage to 24V. After a couple of seconds, high-side switch 1 is turned off and the microcontroller prepares the states of the half H-bridges (COM, Z1, Z2, Z3). Let me first explain how the states are set for Latching solenoids. The solenoids for the three zone are connected between COM-Z1, COM-Z2, and COM-Z3 respectively. Normally all four half bridges are in ‘High’ state, so the net voltage across every solenoid is 0. To activate a solenoid (say Z1), the corresponding half-bridge will be pulled down to ground (i.e. ‘Low’ state). The microcontroller then turns on high-side switch 2 momentarily to dump the charge from the 2200uF capacitor to the solenoid. This turns on the valve. To deactivate the solenoid, the microcontroller pulls all half-bridges to Low, except the zone that is to be deactivated which remains in High state. It then turns on high-side switch 2 momentarily, again dumping the capacitor charge to the solenoid, but now in reverse polarity, thus closing the valve. This is basically how it operates latching solenoids.

So how does the same circuit work for Non-Latching Solenoids, such as 24VAC valve commonly used in residential sprinkler system? It turns out that just like latching solenoids, non-latching ones also require a pretty high impulse current (called inrush current) to get activated. The difference, however, is that to keep it on, it needs to draw current continuously from the power source. When the power cuts off, the solenoid is deactivated. This is called the holding current and is considerably lower than the inrush current. So to operate non-latching solenoids, all I need is an additional diode that provides a path from the input 5V to the solenoids to provide the holding current. This diode could be software switched by the microcontroller, but because ESP8266 has very few number of GPIO pins, (and I want to avoid having to use an IO expander), I opted to enable this diode path using a solder jumper. To operate non-latching valves, this jumper needs to be soldered on.

osbee_circuit_2

On the Software side, the firmware uses an option to allow the user to choose the valve type (unfortunately the controller can’t automatically detect the valve type yet). For non-latching valves, the half-bridge states are actually easier to manage than the latching case: now COM is always in ‘High’ state, and Z1, Z2 or Z3 are kept ‘Low’ for as long as needed to keep the valves on. That’s it.

You may be wondering how does this even work for valves rated at 24VAC? How can we drive them using DC, and just 5V? The short answer is that this is due to the way such solenoids behave under AC. Specifically, when you first connect the solenoid to 24VAC, it immediately draws a high inrush current, which reliably energizes the solenoid and opens the valve. Once energized, the solenoid presents a large inductance and high reactance to AC, thus limiting the effective current flowing through it. This results in lower holding current, which is enough to keep it on and saves the coil’s lifespan. We can exploit this behavior and achieve the same effect using a DC-based circuit: the booster produces a high voltage initially to provide the inrush current needed to energize the solenoid, and then lowers the voltage to the input level to provide the holding current. Exactly how much holding current is needed is not clearly defined, but for all 24VAC solenoids I’ve tested, once energized, they can remain on at just 5V input voltage.

Now we are left with the last part of the technical details: the Half H-Bridge Design. From the circuit diagram above, it seems we can easily implement the half bridges using relays. While this is totally true, relays are bulky, expensive, slow to switch, and difficult to replace. For these reasons, modern electronics prefer to use semi-conductors as much as possible in place of relays. So I decided to use a MOSFET-based H-Bridge design, and it’s a more interesting design than just throwing relays everywhere.

Typically when you want to switch between GND and a voltage considerably higher than the microcontroller’s output, you can use a half H-bridge design as show in the left image below. It uses a low-power N-MOSFET to drive the high-power P-MOS on the bridge, making it possible to use a GPIO pin to switch a high voltage. However, this generally requires 2 GPIO pins (i.e. A and B) per half bridge. Because ESP8266 has a small number of GPIO pins, the challenge is how to use just 1 GPIO pin per half bridge.

osbee_hbridge_1osbee_hbridge_2

So I came up with a slightly modified half bridge design, as shown in the right image above. It leverages two low-power N-MOSFETs to drive the high-power P-MOS and N-MOS on the bridge. This allows using just 1 GPIO pin (A) to switch the bridge. When A is Low, both input N-MOSFETs turn off, and the gates of the P-MOS and N-MOS are both pulled high, so the P-MOS turns off and N-MOS conducts, pulling the OUTPUT to Low. When A is High, the reverse happens, and the OUTPUT is also High.

Using two input N-MOSFETs also makes it easy to prevent shoot-through problem, which is often an issue with H-bridge. Shoot-through happens when the control signal A transitions from Low to High (or conversely from High to Low), and at some point the P-MOS and N-MOS may both be in conducting state, causing a shorting. To avoid this, I chose to use two different types of input N-MOSFETs: one with lower gate threshold voltage (such as BSS138) and one with higher gate threshold voltage (such as 2N7002). This way, as the control signal A swings between Low and High, the two input N-MOSFETs will turn on and off at different times, ensuring that the P-MOS and N-MOS will not both conduct at the same time. As for the choices of the P-MOS and N-MOS, I opted to use the common AO3401 and AO3400, which provide ample room for continuous current as well as impulse current.

Sorry about going through these nitty-gritty details, but I think these are interesting design notes worth documenting and sharing. Feel free to chime in with your comments and suggestions. Thanks!

A quick note that our Black Friday / Cyber Monday sales are on now: all OpenSprinkler products are shown in discounted prices right now, and the deal only lasts till Monday Nov 28. This is the only time of the year that we offer discounted pricing, so if you are interested in buying OpenSprinkler, grasp this chance and don’t let it slip away!

If you are wondering whether you need to apply any coupon code. The answer is NO: the price you see is the discounted price. In the past when we used to have coupons, many customers forgot to apply the coupon in the end. To save you the trouble of having to enter coupon code, we directly discount the price, so you will definitely not miss it.

Older Posts »