I got automatic watering working almost a month ago. Then I broke it:
- Turns out there was a problem with the water valves in the house. These had to be fixed.
- As I got more familiar with RF69 traffic / library, I realized RF69 messaging is best done to completion within (a tight) loop(). I had spread out the RF69 messages into functions in which I would loop through expecting a specific message. The challenge with this is the Controller sent/received messages in an unpredictable way because the Controller is dealing with both MQTT traffic and commands as well as RF69 traffic.
The goal of this post is to document the implementation of the first beta of the Watering Puck.
Thanks To Those That Went Before
- Ray’s DIY Electronics Hobby Projects – An exceptional open sourced open sprinkler hardware and software project. In particular, Ray provides thoughtful blog posts on stuff like how to use a 24VAC irrigation directed power source to also power a microcontroller. THANK YOU.
- Afrotechmod’s Youtube video: Diode Tutorial & How to build an AC to DC power supply on using diodes to build a full wave rectifier – I am VERY grateful for the videos Afrotechmod has created to explain electronics. I find them understandable and practical. THANK YOU.
I decided it made the most sense to use off-the-shelf solenoids from Orbit and a 24VAC power supply. 24VAC is the standard used in irrigation systems.
Orbit Valve Box Base (YouTube video description
I am using these three relays. The cost was ($13 for 4)/4 + $8 shipping (I ordered 4) = $11.25 (high shipping cost).
Always looking for a good explanation on how relays work. I found dial2fast’s How Does a Relay Work Youtube video to be very clear. The DC current flows through copper coils inside the relay. This generates a magnetic field which moves the switch to the other side. NO (Normally Open) moves the arm from the open circuit to closing the circuit and letting the 24VAC flow through the valve.
This image from 12VoltPlanet works for me:
Since I am not smarter than a 5th grader, I thoroughly enjoyed these videos on how electricity can be used to create a magnetic field as is done within this relay. In UniServeScienceVIDEO’s Magnetic Field Demonstrations Youtube video, there are three demonstrations that are fun to watch. Jeff Regester’s Magnetic Field of a Coil of Wire Youtube video demonstrates a compass spinning when electricity goes through the coil. I like both. UniServe’s is great in that it shows the motion of the magnetic field. Jeff;s is awesome because it shows the standard physics class example.
Powering the Feather using the 24VAC
I want to run the Feather off the same 24VAC Power supply being used by the valves. I’ll do this by adding a way to smooth out the AC waves into a flat DC line as well as a way to down shift the power from 24VDC to 5 VDC and connect the Feather through the USB port.
My first attempt used this setup:
- Rectifier circuit to convert AC to DC. I’m thrilled to see the need for the rectifier circuit…of course, I couldn’t leave home without it if I’m ever taking AC to DC…I spent time understanding peak detection/rectifier circuits when I designed and built the Ladybug Shield. Based on this experience, and the great advice in Dave’s excellent EEVBlog #490 Peak Detector Circuit. I am going to use the very simple diode + capacitor peak detection circuit Dave talks about at the beginning of his video. I am not doing any precision measuring as was the case with the EC circuit of the Ladybug Shield. Rather, I just want to get the signal ready as input to the DC-DC Buck Converter. While the diode will eat up about .7V, I don’t need to adjust anything because I’m not interested in the actual DC value. Sure this method of rectification leaks current and drifts over time. However, for this scenario that is ok.
- diode (I have several)
- a 100µF / 50V capacitor (see OpenSprinkler’s post).
- DC-DC Buck Converter – The VDC output after using the rectifier circuit measured 40V.
I decided to use the schematic I found on RAYSHOBBY.NET:
Since I easily forget how different components – such as diodes – do their magic, I thought Sparkfun’s diode tutorial was helpful.
Parts I have:
- D1 – Diode
- C2 – 220µF/6.3V Capacitor
- RT – 30K Resistor
- RB – 10K Resistor
- CT – 100pF Capacitor
- RSC – 2 1 Ω Resistors
This time I’m going back to the first attempt – that is using the DC-DC Buck Converter. However, the rectifier design I’ll use will be the more effective full wave rectifier. Afrotechmods did an excellent YouTube video on this type of rectifier.
The above image shows the difference between using a half-wave and full-wave rectifier. The full-wave rectifier uses both the positive and negative parts of the AC to recharge the capacitor. Much better. I’ll use that technique.
What size of capacitor should I use? Afrotechmods shows a design with a 1µF capacitor when there is no load:
I = .035A
t = 1/60 Hz = .0167s (NOTE: See DOH! below…)
for the ripple I’ll use 1V.
C = .035 * .0167 / 1 = .0005845 = 585 µF. I need a capacitor that is at least 585µF that can handle around 50V. I found this 680µF/50V capacitor at my local electronics shop. The voltage ripple I should see V = .035*.0167/.00068 = about .86V. Even better!
So crafty me…I built one:
um… I screwed up for the time period. Full wave is at 120 Hz, not 60 Hz. So:
t = 1/120 = .0083
C = .035 * .0083 / 1 = .0002905 = 291 µF.
DOH-DEE-DOO..I’m leaving the 680µF capacitor. Overkiil, but from what I can tell should mean even less ripple.
The firmware code, WateringPuck2017_v3.ino, is located at this GitHub location.
I needed to make sure I used available logic pins…Looking at the Feather m0’s logic pins
I’m going to NOT use:
- any pin between A0 and TX1
- pin 13 since it is used by the LED
- the SCL and SDA pin