Feed on
Posts
Comments

I often get questions about sprinkler valves, so in this post I will explain the basic electric properties of sprinkler valves. If you are designing a sprinkler controller circuit, understanding these properties can be helpful. It’s a common mistake to assume sprinkler valves work with DC voltage. While most valves indeed CAN be powered by DC voltage (see below), they are designed to work with AC voltage in the range of 22VAC to 28VAC. That’s why if you look at a standard sprinkler transformer, the output is usually AC.

The electric part of a sprinkler valve is the solenoid — it’s a cylindrical-shaped thing screwed into the valve. At the center of the solenoid is a rod supported by a spring. The solenoid has two wires connected to its internal coil. Applying 24VAC on the two wires energizes the coil, and causes the rod to contract into the solenoid. This releases the internal water pressure thus opening the valve, allowing water to flow through the valve. Removing the voltage causes the rod to revert back to its original position. This allows the water pressure to build up internally hence stopping the flow. Because closing the valve relies on internal pressure build-up, it usually takes a few seconds to completely stop the water flow. This also means if your water pressure is too low you may not be able to completely stop the water flow.

IMG_0205IMG_0206

Let’s start by measuring the resistance of the sprinkler solenoid. I have two example solenoids, one made by Orbit and one made by Hunter. According to the multimeter, one measures 32.3 ohm, and the other measures 24.1 ohm. So the resistances are pretty low. If you think about it for a while, you might realize something is not quite right here: if we apply 24V on the solenoid, wouldn’t that produce a 24 V / 24.1 ohm = 1 amp current draw? That’s quite steep. In fact, my sprinkler transformer is only rated 750 mA output current, so it can’t provide enough current to drive even one solenoid?!

The catch is exactly in the fact that sprinkler solenoids are powered by AC voltage. Because the solenoid is made of a coil, it not only has coil resistance but also inductance. When operated on AC power, the inductance produces significant reactance which cannot be ignored. You can read the Wikipage to find out how reactance is calculated, but basically it has to do with the frequency of the input voltage, and the inductance of the coil. Because inductors ‘prevent’ current from changing rapidly, it behaves like a ‘resistor’ under changing current (i.e. AC). The higher the frequency, the higher the ‘resistance’ (i.e. reactance).

With an LCR meter, I measured the inductance of the two solenoids:
IMG_0207IMG_0209
One reads 63.57 mH, the other 132.45 mH. So if we power the solenoids by 24VAC, 60Hz, which is the standard output of a sprinkler transformer, we will get a reactance of:

This, plus the resistance, gives a total impedance of:

Note that the reactance counts into the imaginary part of the impedance. Using complex numbers is just a convenient way of denoting the not only the magnitude but also the phase. For example, when you apply a sinusoid voltage on the inductor, the corresponding current is also a sinusoid wave, but with a different phase. Using complex numbers, the calculation can be carried out quite easily.

Now we can calculate the operating current under 24VAC (rms). We only care about the magnitude, so the current (rms) would be:

OK, so this is getting closer to the reality. But 0.6 amp current still sounds high. What is missing? Well, remember that when the solenoid is activated, the rod will be attracted into the solenoid, and that can change the inductance significantly. So let’s re-measure the inductance with the rod pushed in:

IMG_0208IMG_0210

Indeed the inductance jumped from 63.57 mH and 132.45 mH previously to 194.4 mH and 199.6 mH respectively. OK, now if we redo the calculations, we will find out that the correct reactance is:

and current (rms) os:

The resulting current is about the same on the Hunter solenoid. So this roughly matches the electric specification of a typical sprinkler valve. It’s actually still a bit off: if we measure the actual AC current flowing through the solenoid:
IMG_0211IMG_0212

The readings are about 0.2 amp. I suspect the difference comes from the measurement of the inductance. On my LCR meter, which can measure inductance at two frequency levels: 120 Hz and 1 kHz, I find that the inductance is measured differently under the two frequencies. Because the actual operating frequency of the solenoid is 60 Hz, and my meter cannot measure 60 Hz, the inductance I am getting is probably somewhat off. That should explain the difference between the calculation and the actual current reading.

The 0.6 amp current we calculated above probably explains the inrush current: when the solenoid is just energized, there is an impulse current that’s typically higher than the holding current. This is because the rod is still out, and hence the reactance is lower, causing a higher current than when the rod is attracted in.

Operating Sprinkler Valves Under DC

From the calculations above, it’s obvious that the coil inductance is important at limiting the operating current when the valve is powered under AC. What about if we power the valve under DC? Obviously we shouldn’t use 24VDC, because that would draw too much current (0.75 to 1 amp). If you search online, you will find plenty of posts talking about powering sprinkler valves using 12VDC. This actually works well in general. Using 12VDC has advantages in that 12VDC power adapters are cheaper and much easier to find; the circuit design is simpler, and you can use the same circuit to interface with other DC devices like relays and motors. In contrast, 24VAC power circuits are more complex and you can’t use the same circuit to directly interface with DC devices.

However, you should be aware that because the sprinkler solenoid’s resistance is pretty low, the operating current under 12VDC will be relatively high, around 400 to 500 mA. This more than doubles the 200 mA operating current (rms) under 24VAC. Also, the coil will heat up more, and this potentially shortens its life. For example, under 12VDC, the Orbit valve above will dissipate 12 * 12 / 32.3 = 4.5 Watt; whereas under 24VAC, the same valve only dissipates 0.2 * 0.2 * 32.3 = 1.3 Watt (note that only the resistive portion dissipate power, inductive portion does’t).

Again, the issue is that under DC there is no reactance, so the coil’s inductance plays no effect at limiting the current. What if we reduce the voltage further to 9VDC, in order to reduce the operating current? After all, the solenoid only needs 200mA holding current to remain activated. Unfortunately that won’t work: I’ve tried powering solenoids with 9V, and I can’t get the valve to reliably energize. The problem is that 9V is not sufficient to provide the required inrush current, so the rod cannot get fully attracted in. However, if the rod is already in, 9V is sufficient to hold the solenoid activated. So if you really want to make it work with 9V, you need a circuit that can provide a high impulse voltage; then once the solenoid is activated, you can lower the voltage to reduce the current (hence power) consumption. A possible solution is to use a boot converter (very much similar to circuits for latching solenoids) to provide an impulse high voltage, but this comes at the cost of increased circuit and software complexity.

At the Maker Faire this year I got lots of questions about soil moisture sensors, which I knew little about. So I started seriously researching the subject. I found a few different soil sensors, learned about their principles, and also learned about how to make my own. In this blog post, I will talk about a cheap wireless soil moisture sensor I found on Amazon.com for about $10, and how to use an Arduino or Raspberry Pi to decode the signal from the sensor, so you can use it directly in your own garden projects.

IMG_0183

What is this?
A soil moisture sensor (or meter) measures the water content in soil. With it, you can easily tell when the soil needs more water or when it’s over-watered. The simplest soil sensor doesn’t even need battery. For example, this Rapitest Soil Meter, which I bought a few years ago, consists of simply a probe and a volt meter panel. The way it works is by using the Galvanic cell principle — essentially how a lemon battery or potato battery works. The probe is made of two electrodes of different metals. In the left picture below, the tip (dark silver color) is made of one type of metal (likely zinc), and the rest of the probe is made of another type of metal (likely copper, steel, or aluminum). When the probe is inserted into soil, it generates a small amount of voltage (typically a few hundred milli-volts to a couple of volts). The more water in the soil, the higher the generated voltage. This meter is pretty easy to use manually; but to automate the reading you need a microcontroller to read the value.

IMG_0180IMG_0182

Resistive Soil Moisture Sensor
Another type of simple soil sensor is a resistive sensor (picture on the right above). It’s made of two exposed electrodes, and uses the fact that the more water the soil contains, the lower the resistance between the two electrodes. The resistance can be measured using a simple voltage dividier and an analog pin. While it’s very simple to construct, resistive sensors are not extremely reliable, because the exposed electrodes can degrade and get oxidized over time.

Capacitive Soil Moisture Sensor
Capativie soil sensors are also made of two electrodes, but insulated (i.e. not exposed). The two electrodes, together with the soil as a dielectric material, form a capacitor. The higher the water content, the higher the capacitance. So by measuring the capacitance, we can infer the water content in soil. There are many ways to measure capacitance, for example, by using the capacitor’s reactance to form a voltage divider, similar to the resistor counterpart. Another way is to create an RC oscillator where the frequency is determined by the capacitance. By counting the oscillation frequency, we can calculate the capacitance. You can also measure the capacitance by charging the capacitor and detecting the charge time. The faster it charges, the smaller the capacitance, and vice versa. The Chirp (picture below), which is an open-source capacitive soil sensor, works by sending a square wave to the RC filter, and detecting the peak voltage. The higher the capacitance, the lower the peak voltage. Capacitive sensors are not too difficult to make, and are more reliable than resistive ones, so they are quite popular.

chirp

More Complex Soil Sensors
There are other, more complex soil sensors, such as Frequency Domain Reflectometry (FDR), Time Domain Reflectometry (TDR), and neutron sensors. These are more accurate but also will cost a fortunate to make.

Wireless Soil Moisture Sensor
Because soil sensor is usually left outdoors, it’s ideal to have it transmit signals wirelessly. In addition, because soil moisture can vary from spot to spot, it’s a probably good idea to use multiple sensors distributed at different locations to get a good average reading. Wireless would make it more convenient to set up multiple sensors.

Recently I found this 433MHz wireless soil sensor from Amazon, for only $10, very cheap. It comes with a transmitter unit and a receiver display unit. The transmitter unit has a soil probe. The receiver unit has a LCD — it displays soil moisture level (10 bars) and additionally indoor / outdoor temperature. Let me open up the transmitter to see what’s inside:

IMG_0177IMG_0178IMG_0179IMG_0181

There is a soil probe, a 433MHz transmitter, a microcontroller at the center, a thermistor, and a SGM358 op-amp. Pretty straightforward. The soil probe looks quite similar to the battery-free soil meter probe that I mentioned above. So I am pretty sure this is not a resistive or capacitive probe, but rather a Galvanic probe. Again, the way it works is by outputting a variable voltage depending on the water content in soil. By checking the PCB traces, it looks like the op-amp is configured as a voltage follower, which allows the microcontroller to reliably read the voltage generated by the Galvanic probe.

Now we understand the basic principle of the sensor, let’s take a look at the RF signal from the sensor. I’ve done quite a few similar experiments before, so I will just follow the same procedure as described in this post.

Raw Waveform. To begin, I use a RF sniffing circuit to capture a raw waveform, which looks like this:

soil_waveform

Encoding. Each transmission consists of 8 repetitions. The above shows one repetition: it starts with a sync signal (9000us low); a logic 1 is a impulse (475us) high followed by a 4000us low; a logic 0 is the same impulse high followed by a 2000us low. So the above signal translates to:

11110011 01100000 11111111 00111001 1111

The signal encodes both temperature and soil humidity values. By varying temperature and soil moisture, and observing how the signals change, it’s pretty easy to figure out that the 12 bits colored blue correspond to temperature (10 times Celcius), and the 8 bits colored red corespond to the soil moisture value. The first 12 bits are device signature, which is quite typical in this type of wireless sensors; the last four bits are unclear, but likely some sort of parity checking bits for the preceding four bytes). So the above signal translates to 25.5°C and a soil moisture value of 57.

The display unit shows soil moisture level in 10 bars — 1 to 3 bars are classifed as ‘dry’, 4 to 7 bars are classified as ‘damp’, and above 7 bars are classified as ‘wet’. How does this translate to the soil moisture value? Well empirically (from the data I observed) the dry-damp boundary is around 60, and damp-wet boundary is around 100.

Arduino Program. I next wrote an Arduino program to listen to the sensor and display the soil moisture value and temperature to the serial monitor. For this you will need a 433MHz receiver, and the program below assumes the receiver’s data pin is connected to Arduino digital pin 3. Because the encoding scheme is very similar to a wireless temperature sensor that I’ve analyzed before, I took that program and made very minimal changes and it worked instantly.

IMG_0051soil_display_arduino

Raspberry Pi Program. By using the wiringPi library, the Arduino code can be easily adapted to Raspberry Pi. The following program uses wiringPi GPIO 2 (P1.13) for data pin.

IMG_0185IMG_0184

I haven’t done much tests about the transmission range. I’ve put the sensor at various locations on my lawn, and I’ve had no problem receiving signals inside the house. But my lawn is only a quarter acre in size, so it’s not a great test case.

One thing I really liked about using off-the-shelf sensors is that they are cheap and have ready-made waterproof casing. That combined with an Arduino or RPi can enable a lot of home automation projects at low cost.

This is a quick update that AASaver has been upgraded to version 2.1. It inherits all the capabilities of version 2.0, including built-in 5V voltage booster, flashlight LEDs, breadboard power pin headers, USB port (for charging USB devices), LiPo charger (with adjustable charging current). On top of those, version 2.1 adds a 3.3V LDO and a switch you can use to choose between 5V or 3.3V output voltage. This has been the main requested feature that was missing on version 2.0. Using an LDO (instead of changing the feedback resistors) has the advantages that the voltage booster and USB port always output 5V, while the 3.3V output is only effective on the LEDs and the breadboard pin headers. Here are some pictures:

IMG_0173IMG_0158IMG_0161

IMG_0162IMG_0159IMG_0171

For those who are curious what AASaver is: it’s a multi-purpose voltage booster for AA/AAA batteries. I came up with this idea initially when I was cleaning up a box of ‘dead’ AA batteries one day, and was surprised that many of them actually have pretty good output voltage, like 1.2 to 1.3V. Many AA batteries rejected from gadgets (e.g. remote controls and smoke alarms) still have plenty of juice, but these gadgets don’t have built-in booster circuit to bump the voltage up, so a lot of batteries are wasted this way. I was learning voltage booster at that point and had the idea of designing a multi-purpose circuit for AA batteries, so that I can harvest the remaining energy in ‘dead’ batteries for a variety of things, like lighting up LEDs, powering breadboard circuits, charging LiPo batteries etc. That’s how AASaver was invented. It’s not restricted to used or ‘dead’ batteries — if you plug in a fresh pair of batteries, you can also use it to charge your phone or other USB gadgets. It’s a really neat, useful, and inexpensive tool that everyone should have a few of these!

Below is the original video I made for AASaver. Keep in mind that the current version has a lot more features than shown in the video, including USB charging, LiPo charging. You can even modify it to become a solar charger.

With this new version, I’ve also prepared a more detailed User Manual, with assembly and usage instructions. We have just fulfilled an order from Micro Center so in the near future you may even find AASaver in the Micro Center retail stores :)

Back in April, I blogged about WAi (Worthington Assembly Inc.), a circuit assembly company located only 15 minutes away from where I live. They’ve got great reputation in the maker community, and have helped projects such as Tessel, RGB-123 LED matrices to take off. I am glad to announce that we’ve now partnered with WAi to manufacture OpenSprinkler Pi (OSPi), and the first batch of 200 boards just came out from a late-evening production yesterday. Check out these awesome videos Chris Denney took during the production:

Full-speed version

Slow-motion version

Some static pictures (taken with an outdated phone, sorry about the quality!). Picture captions: 1) tapes loaded onto pick-and-place machine; 2) first board came out of the reflow oven; 3) first board after AOI inspection; 4) me holding a stack of 25 panels.
0612141917a0612142026

06121420390612142235

Compared to manufacturing in China, using a local facility has the unbeatable advantage of quick turn-around time. The cost may be higher than made in China, but for an open-source hardware business like us, it’s critical to remain agile and be quick about making changes. I’ve been there — waiting for months for an order to ship from China, which was painful and stressful. By the time the shipment arrived, I already wanted to move on to the next version. With WAi, we may have found just the perfect solution for our need, and this is supporting local manufacturing too, win-win! :)

Two months ago, I wrote a blog post about the preview of OpenSprinkler Bee, which is an open-source arduino-based controller for battery-operated sprinkler valves. While that’s still in the development stage, today I am glad to announce that an Arduino shield version of OpenSprinkler Bee is completed and immediately available for purchase at the Rayshobby Shop.

IMG_0073IMG_0075

So what is this Arduino shield version, and how is this different from other OpenSprinkler prodcuts that we carry? Well, an Arduino shield is a circuit board that you plug into an existing Arduino — it does not have a microcontroller chip itself, but contains additional circuitry that extends the basic functionality of an Arduino. So to use the shield, you will need to provide an existing Arduino board.

How is the OpenSprinkler Bee (OSBee) different from the other OpenSprinkler products? The main difference is that OSBee is designed to work with battery-operated sprinkler valves. These valves internally use a latching solenoid, which only draws power when you open or close the valve, and does not draw power if it remains in the same state. So it’s very efficient and suitable for battery-operated controllers. The other OpenSprinkler products, such as OpenSprinkler 2.1s, DIY 2.1u, OSPi 1.4, OSBo 1.0, are all designed for 24V AC sprinkler valves, which operate on 24V AC and require a power adapter / transformer.

While OSBee shield itself does not have built-in wireless modules, you can stack it with other Arduino shields, such as RF, WiFi, Ethernet shields, to provide web connectivity. The OSBee Arduino library has one example of using the Arduino Ethernet shield with OSBee shield to create a web interface for sprinkler control.

Is there any easy way to tell latching solenoid valves from 24V AC valves? Yes. Latching solenoid valves usually come with a special plug, and the two wires are usually colored differently because the solenoid has polarity. 24V AC valves usually come with just two wires colored in the same way (because AC voltage has no polarity). Here are some examples of latching solenoid valves. Note the special plugs and/or different wire colors.

IMG_0072IMG_0078

For valves that come with stripped wires, simply attach them to the screw terminal blocks on OSBee shield. For valves with special plugs, you can cut and strip two pieces of wire (20 to 24 AWG): insert one end of the wire to the plug, and the other end to the screw terminal block.

IMG_0080IMG_0077

How to open or close the latching solenoid valve? Electrically, latching solenoid valves have quite low coil resistance (a few ohms). To open the valve, you apply a momentary positive voltage on the coil. The specific voltage depends on the valve specification, but it typically varies between 9V to 22V. To close the valve, just reverse the voltage polarity. The important thing to keep in mind is that the voltage is applied as a pulse — usually 25 to 100 milliseconds. Because the coil resistance is so low, the instantaneous current is very high, up to a few amps. So you can’t apply the voltage continuously (or it will smoke the coil or the power supply!) In addition, it’s better to first build up the voltage into a capacitor, and then dump the charge to the valve from the capaictor.

How to generate such a high voltage from Arduino’s 5V or 3.3V pin? It’s by using a neat circuitry called ‘boost converter‘. The Wikipedia has plenty of information about how it works, but the basic principle is to use a MOSFET switch, an inductor, a diode, and a PWM signal to build up the charge into a capacitor. This way you can generate a high voltage from a low-voltage source such as AA batteries.

How to apply a voltage in both polarities? This is by using another neat circuitry called ‘H-Bridge‘. The H-Bridge is made of four MOSFET switches. By closing the pair of switches in each diagonal direction, you can apply voltage in either positive or negative polarity. Because you also need a state where no voltage is applied on the solenoid, that’s three states in total and hence two microcontroller pins are required to produce three states. Wait, why not directly use two microcontroller pins to apply the voltage? Well, microcontroller pins can neither handle high voltage nor provide high current, so you need MOSFETs to help switch high voltage and high current using only logic signals from the microcontroller.

With all the technical concepts explained, here is the diagram of the various components on the OSBee Sheild:
osbee_shield_diagram

The shield can switch 4 independent valves / zones. The boosting voltage is software adjustable — anywhere from 9V to 24V. An Arduino library with three demo programs are provided in the OSBee Github repository. For details, please refer to:

OSBee Shield v1.0 is now available for purchase at the Rayshobby Shop. Thanks!

Older Posts »