Introduction: Using Pulsed Solenoids With Wemos D1 Mini and H-Bridge for Irrigation
For this instructable I wanted to create a solution so I can remotely turn on a sprinkler system or to auto water my seedlings.
I'm going to use a wemos D1 to control pulsed solenoids. These solenoids use much less power because when they have received the pulse they stay in that state until they receive another pulse. Therefore they are also ideal to use with batteries.
You can change the state of the solenoid by using -3.6 to -6.5 volts and 3.6 to 6.5 volts. Because I want to use the same power supply as the one of my wemos I will use +5V and -5V. These voltages you can change by an H-Bridge. The H-Bridge I'm using can control 2 solenoids. Pay attention that the power supply delivers more then 4.5V otherwise the H-bridge won't work.
Step 1: Needed Parts
Step 2: Install the Needed Library's
If we are going to use the wemos D1 mini we first need to install some library's.
- Go to file preferences
- In the Additional Board Manager URLs field paste the following link: https://arduino.esp8266.com/stable/package_esp8266com_index.json
- Press OK
- Go to tools, board menu, boards manager and install esp8266
Step 3: Soldering
There isn't much to solder here. You only need to solder the header pins onto the wemos board
I didn't try this but if you solder female headers to D1 to D4 and then solder wires on the +5v and ground it is possible that you can attach the wemos onto the H-Bridge. This however isn't tested by me because my pinheaders were already soldered.
Step 4: Wiring
In the image above you see the wiring of this project. The wiring of the solenoid doesn't really matter. It only matters how you write your code. If the + and - of your solenoid are reversed you also have to pull another pin high or low on the esp module.
The GND should always be connected to the G pin of the wemos otherwise the outputs won't switch. Also don't use D1 and D2 otherwise the serial output won't work anymore because these are pins meant for serial communication.
You also need a level converter between the output pins of the wemos and the input pins of the H-bridge because the wemos pins output 3.3v and the h-bridge needs a signal of 5v in order to output the needed voltage to switch the solenoids.
Step 5: Coding
- Connect the usb cable (if 5V isn't connected to the wemos board)
- Download the code
- Open file
- Go to tools
- Select the wemos D1 R1 board
- Select the com port where the wemos is connected under tools, port
- Change your-ssid with your home SSID
- Change your-password with your wifi password
- Click the upload button
Step 6: Testing
In the previous step we uploaded the code.
Everything should work now. In order to test this we need to know the IP-address and we need to connect a garden hose.
Your IP-address you can see via the serial monitor or on your wireless router
- Go to tools, serial monitor
- There you see your ip-address (see first image)
Now it's time to test everything outside.
- Screw on the 2 garden hose connectors
- Attach the solenoid onto a faucet on one side and onto the garden hose on the other side.
- Go to the link http://yourip/sol1/1 and to http://yourip/sol1/0 to turn it of.
- If you wan't to control the second solenoid http://yourip/sol2/1 and http://yourip/sol2/0
Step 7: Conclusion
This is the base for making an automatic irrigation system, you can by example add sprinklers to the system or drip irrigation hoses. This solution can also be run from a solar panel. Depending on how popular this instructable is I will make a solar powered version later.