Water Flow Controller W/ HTTP Controls Using Adafruit Feather Huzzah

by 406jem in Circuits > Arduino

305 Views, 4 Favorites, 0 Comments

Water Flow Controller W/ HTTP Controls Using Adafruit Feather Huzzah

20250321_095714.jpg
20250321_095804.jpg
20250520_124626.jpg

K.I.S.S.

This is just some instruction for a little water controller flow controller I built from a Huzzah to monitor the moisture content in my flowerbed and water accordingly. The code is pretty basic and the physical build is fairly minimal using the Adafruit Huzzah and a HD-38 Soil Moisture Sensor module to keep track of things and make decision and to make things happen I made use of a relay, 12 volt battery and a motorized ball valve. I wanted to power the thing from one source so I just used the 12v battery and a 5v stepdown converter. I also put the built circuit into a decent waterproof enclosure 'cause water...

Below is a set of instructions containing code for the Arduino ide, instructions to flash the build, a component list and the build itself.

Other Considerations...

No solar solution as I am just powering my build through the usb connection, but imo.. adding a battery, super simple; adding a solar charger, little more complicated but doable.


Note the antenna and Lora radio hat that is clearly in the picture and part of my build.. This is literally just a Lora 'feather' or hat for the Huzzah (and other Adafruit spec boards), nothing special going on with it and I intend to use it in the future to propagate the data to a larger lora data network. To be clear... I'm not using it and have completely omitted it from the component list and instructions.

Supplies

enclosure.jpg
huzzah.jpg
hd38soilsensor.jpg
20250520_124725.jpg
battery pack and charger.jpg
  1. Enclosure
  2. qBoxMini DIY IOT Enclosure
  3. Microprocessor
  4. Adafruit Feather Huzzah with ESP8266
  5. Monitoring
  6. HD-38 Soil Moisture Sensor
  7. Flow Control
  8. Single Channel 12V Relay Switch
  9. U.S. Solid Motorized Ball Valve
  10. Power
  11. KBT 12V 2400mAh Rechargeable Li-ion Battery
  12. Mini 5V Buck Converter Board (Amazon) (Adafruit)
  13. Incidentals
  14. circuit board wire
  15. soldering iron and solder
  16. computer w/ usb port
  17. usb to usb c-type cable
  18. Arduino IDE
  19. a multimeter of some other tool for effectively testing DC voltages

Adding Components to the Base Board

wiring diagram for huzzah sprinkler controller.png

Assuming you have all the needed components gathered the first thing to do is solder the extra components and wiring on the base board...

Prep your work area to do a little soldering and grab your enclosure kit (or base board if you are not using the enclosure kit) and remove all the components that can be removed, clean the board.

Solder on the 5V Buck.. we are going to use this to convert the 12V DC supplied from the battery to a constant 5V feed to power the Huzzah.

When soldering the +5V USB pin for the Huzzah notice the inclusion of pigtails (wires only soldered on one end) for use later to power the Relay Switch.

Next solder on the wiring according to the diagram supplied, It is best to solder all the wiring to the back (underside) of the base board.

Quick list of connections to make...

  1. P1+ to Vin on 5V Buck
  2. P1- to GND on 5V Buck
  3. GND from 5V Buck to GND(-) on HD-38
  4. GND on 5V Buck to GND on Arduino Huzzah
  5. GND on Arduino Huzzah to GND on Voltage Divider
  6. +5V on 5V Buck to Arduino Huzzah USB pin
  7. +5V on 5V Buck to +5V(+) on HD-38
  8. A0 on HD-38 to input of Voltage Divider
  9. Center Node (Divided Voltage) of Voltage Divider to ADC
  10. Pigtails
  11. Solder a wire onto the SCL pin of the Huzzah (to connect to and control the Relay Switch)
  12. Solder a wire onto the +12V pin of P1 (to connect to the DC+ of the Relay Switch)
  13. Solder a wire onto the -12V (GND) pin of P1 (to connect to the DC- of the Relay Switch)

That should be all the connections, we can now proceed with some steps to ensure the correct operational values.. Basically we should test things and verify a few values before we start plugging stuff in.

Before putting the base board back into the enclosure housing proceed to the next steps.

Testing Critical Voltage Values

Now that we have a base board we want to actually test the work. First thing to do is to actually test the 5v Buck.

  1. Visually inspect the work against the pinout diagram for the actual 5V Buck component (the only component that should be connected at this point) you used and if that looks correct move on to actually powering the circuit by connecting the battery to P1.
  2. attach the top plug to the power plug (P1 in the diagram), connect the negative lead from the battery to the ground (P1-) and the positive lead from the battery pack to the positive (P1+);
  3. use the multimeter to verify
  4. 12v on the Vin pin on the Buck
  5. 5v at the Huzzah USB pin
  6. 5v at the HD-38 +5V pin
  7. test the voltage divider as well by simply supplying 5v and checking the output is ~1V.. feel free to test other values, but we just need to ensure this stays UNDER 1V so we don't burn up the Huzzah. ADC is the only analog pin on this board and it expects <= 1V.
  8. IF those voltages are correct and after disconnecting the battery. Now it is safe to plug in the HD-38 and we can verify a few more voltages.
  9. Disconnect the battery and again, visually inspect the pin connections, this time for the HD-38 component.. If they look correct attach the HD-38. At this point we have ONLY the 5V Buck and the HD-38 connected. Reconnect the 12V battery to P1 (you should just be plugging and unplugging the top plug on the P1 component to disconnect/reconnect the power at this point).
  10. use the multimeter to verify
  11. ~0V at A0 pin
  12. ~0V at ADC pin
  13. now connect the moisture probe to the HD-38 (if not already connected) and submerge the probe in water.
  14. use the multimeter to verify (the correct adjustment of voltage thru the Voltage Divider)
  15. ~5V at A0 pin
  16. ~1V at ADC pin
  17. IF those voltages are correct we are ready to do the same process again, this time attaching the Huzzah (now that we know we are not going to burn anything up with too much voltage).
  18. Disconnect the Battery, remove the probe from the water, inspect the connections made to the Huzzah header pins and if they look OK plug the Huzzah into the headers, connect the battery.
  19. We should at this point see the Huzzah power up.. no smoke.. we are not going to be able to do any further testing until we actually program the Huzzah. Once we flash the code onto the device we can proceed to testing one additional pin output and start connecting the rest of the components and mounting things in the enclosure.
  20. Disconnect the battery.

Flash the Huzzah

The code is here. Feel free to make any adjustments or enhancements you like. If you are unfamiliar with the Arduino IDE you'll need to download it and look into how to prepare your environment to connect to and flash the Arduino Huzzah. Here is some instruction to get started.

BEFORE you flash the Huzzah you need to make one critical edit to the code so the wifi connects and the webserver operates as intended.

  1. lines 21-23.. change these values to reflect your wifi credentials and well.. whatever you want to name the device (hostname only matters if your gonna do extra work on your network for name resolution).

Once flashed you can use the serial monitoring console in the Arduino IDE to see output from the program.

When you are done checking out the serial monitor and watching the thing boot up see some debugging output (pay attention to the ip reported by the Huzzah in the serial monitor.. write it down), etc.. Disconnect the usb cable from the Huzzah.

We are gonna do one more test.. if ya want to.. if not it's gonna be fine, the relay will either work or not.

  1. Connect the battery to J1 and wait about 20 seconds to ensure the device has started up correctly.
  2. With the sensor probe OUT OF THE WATER Verify ~0V on the SCL
  3. With the sensor probe SUBMERGED IN WATER Verify ~5V on SCL (really any positive voltage over 3.0 volts will be fine.. this pin is what will tell the Relay to open/close ultimately controlling the power to open/close the Ball Valve.
  4. Once you see that the signal line is actually working disconnect the battery.

Attaching the Rest of the Components

relay to ball valve.png

So If you have not already we should start actually mounting things into the enclosure starting with the baseboard and all the components currently attached to it. You can power it up again using the battery to test things if you like once mounted.. just make sure the power is NOT connected as you proceed to attach the rest of the components (really the only thing left to 'attach' is the Relay).

  1. Attach all the pigtails to the Relay switch accordingly..
  2. +12V piggy to HD-38 DC+ pin
  3. -12V (GND) piggy to HD-38 DC- pin
  4. SCL piggy to HD-38 IN pin
  5. So at this point.. the relay is GOING TO SEND POWER to the output pins when the battery is connected. The only difference is WHAT PIN. NO stands for normally open, NC stands for normally closed. I'm not going to get into it too much.. just know that the power toggles between the two pins and the thing that controls which output pin gets +12V is the signal from the SCL pin.
  6. What I'm saying is you can power up the circuit (connect the battery) and depending on if the probe is in the water or not.. you will see one of those pins get +12V.. you can test this or just hook up your relay according to the manufacturer specs.. If you are using the same ball valve I am this is;
  7. yellow is ground.. (connect this to the -12V on J1)
  8. blue connect to NO
  9. red connect to NC
  10. one more wire... run a wire from the DC+ (+12V) to the COM pin, these are both pins on the Relay so you can just run a wire in between the screw connectors. This is the voltage supply that is sent to NC and NO and ultimately powers the motor in the Ball Valve.
  11. Cool Beans.. you should be able to plug the battery in and watch the ball valve open/close depending on if the sensor probe is wet or dry.
  12. pro tip.. DO NOT get your fingers or anything else in the way to that ball valve, very bad things will happen if you do.

Finalize Encloser and Deploy to the Wild

20250321_182932.jpg

Getting everything into the enclosure should not be too challenging, I did end up leaving the Relay switch loose in my build, but it tucks nicely into the empty space next to the Huzzah.

What you do from here is kinda up to you... I built a little box to house the battery and easily connect the charger (I always have mine plugged in) and put it in the front flowerbed where I have an irrigation system I feed from water controlled by the ball valve.

Couple things to note.. I did not discuss the webpage much.. but the reason I used a Huzzah and put up with weird voltage dividers and other 'challenging' aspects where there are simply better platforms IS the Huzzah webserver.

Remember that ip I told you to write down earlier? this is how you connect to and control the Huzzah. I'm not going to get into it a ton, but I built some basic controls to set critical values for the system by going to certain urls. Basically use your internet browser on any device connected to the same network as the Huzzah and type in that ip address and check it out. Once you have seen the webpage.. go look at the code and feel free to build out any other types of controls you would like or make any alterations you decide are an advantage.

basically this code could be improved a lot, but I'm not trying to be too fancy and it is a good starter for people so feel free to take control.