Start by thinking about what you want to achieve and what bits and pieces you’ll need.
This project will use common gardening electric water valves, available in home improvement stores. While at the store, you will also need one power supply, or transformer, suitable for these water valves. How to use a MOSFET to control a motor. This might work for the water valves, except that some water valves might use alternating current (AC), and MOSFETs can control only direct current (DC). In order to control AC, you need a relay, which can control both AC and DC.
NOTE
In “Driving Bigger Loads (Motors, Lamps, and the Like)” MOSFET is a type of transistor, in which the gate pin can control whether electricity flows between the drain and source pins. In this sense, a MOSFET is a switch. A relay is also a switch. Inside the relay is a tiny mechanical switch controlled by an electromagnet: by turning on and off the electromagnet, you control whether electricity flows through the mechanical switch.
In order to know when to turn the water on and off, we’ll need a clock of some kind. You could try to do this in your program using the Arduino built-in timer, but it would be complicated, and worse, it’s not terribly accurate. As it turns out, a device that does this exists, is quite inexpensive, and is easy to use with Arduino. The RTC (Real Time Clock) is similar to the device in your computer that keeps track of the date and time even if you leave it turned off for a long time.
We’ll also need a sensor to tell us if it’s raining. We’ll use a Temperature and Humidity Sensor, as they are inexpensive and easy to use. We don’t need to know the temperature, but you get that extra feature “for free” and it might be useful.
Finally, we’ll need a way to set the on-times and off-times, i.e., the user interface. To keep this project from getting out of hand, I’ll use the serial monitor for the user interface. As you become more fluent in Arduino, you could replace this with an LCD display and pushbuttons.
Before you start programming, you need to think about how the hardware will be connected. I like to use a rough block diagram to help me see all the parts I need and to think through how they should be connected. Eventually, you’ll need to know exactly how to connect things, but in the block diagram (Figure 8-1) we just use one line to symbolize some kind of connection.
In this diagram we assumed three separate water valves, but you can see how this can be generalized to whatever your needs are.
As this is a more advanced project, I’ll introduce construction techniques. This project must work reliably for many months, perhaps even years, so you’ve got a different goal from a simple example that is only meant to show you how something works. The solderless breadboard you used earlier is great for prototyping or experimenting, but for reliability we’ll build this project by soldering components to a Proto Shield. We’ll also consider how to distribute power and make all the connections to the various external parts like the water valves. We’ll even look at how this project could be protected in some kind of enclosure.
NOTE
Shields are boards that plug into the pins of an Arduino and provide additional functionality. The Arduino Proto Shield is a particular shield that is designed to let you build your own circuit on it.
Another feature that is useful as your projects get more complex is an indication of what is going on. This is helpful for debugging, and is especially useful when parts of your system are far away, such as the water valves. We’ll add LEDs to indicate that the water valves are activated. Don’t forget the resistors for the LEDs.
Now that we have a few more details, I like to make a tentative shopping list. With complex systems, I expect that I’ll have to make changes: for example, as I work on the sketch, I might realise that I need another part. (The final, complete shopping list, with links, is at “Irrigation Project Shopping List”.)
Don’t worry if you don’t know what all these parts are. We’ll cover them in detail as we go:
- One Real Time Clock (RTC)
- One Temperature and Humidity Sensor
- One Proto Shield
- Three electric water valves
- One transformer or power supply for the water valves
- Three relays to control the water valves
- Three sockets for relays
- Three LEDs as valve activation indicators
- Three resistors for LEDs
- One power supply for Arduino (so it will work even when a computer isn’t attached)
Now that you have a tentative list, let’s look at each item and work out the details. Let’s start with the RTC.
Leave a Reply