Assembling the Circuit

Finally, we’re done with the sketch and we’ve tested all the components! Are we ready to start soldering? Not quite: we’ve tested the various components separately, but not together. You might think that this step is unnecessary, but integration testing is vital. This step discovers unexpected interactions between components, whether hardware or software. For instance, two components might require the same feature on Arduino that is available on only one pin, or two libraries might conflict with each other, or the sketch logic might need to be reorganised. It’s better to do this on the solderless breadboard in case wiring changes need to be made.

To get our full automatic garden-irrigation system, we need to combine three schematics: Figure 8-11, Figure 8-13, and the schematic for the RTC. Although our final system will have three valves, it will be quite a lot of work (and quite a squeeze for the solderless breadboard), for not much gain in information. If it works for one water valve, it should work for all three, so let’s do just one valve for now.

WARNING

Be very careful making assumptions, as they may be wrong and could come back to haunt you later. Never assume that if things work OK by themselves that they will work well together. Any engineer will tell you that integration testing is vital and very often finds problems that were not seen earlier.

Notice that I made an assumption: that testing with only one valve would be sufficient. This is exactly the sort of assumption I’m warning you against. For instance, more valves and more relays consume more power. Can the Arduino digital outputs provide power to all three relays if they are all on at the same time? Can the water valve power supply provide power to all three water valves if they are all on at the same time?

I’ve allowed myself to make these assumptions because I’ve done the rough calculations in my head, and because my years of experience tell me this is very low risk. However, as a beginner, you should avoid making such assumptions and test everything before you start soldering or assembling a project inside a case.

I’ve seen too many students have to take beautifully constructed projects apart because something didn’t work the way they expected it to. (Even worse, it always seems to be the part that’s hardest to get to.)

Figure 8-15 shows the schematic and Figure 8-16 the pictorial circuit diagram for the entire system for one valve. Again, I’ve indicated the polarity of the water valve power supply and of the water valve, but this is relevant only if you have a DC system. If you have an AC system (which seems to be more common), these have no polarity.

15 GSWA3E automatic garden irrigation system one valve schem
16 GSWA3E automatic garden irrigation system one valve bb
NOTE

Before building a complex circuit, print out the schematic. As you build your circuit, use a coloured pen or highlighter to mark each connection you make. This will make it easy to see what you’ve done and what you’ve not yet done.

This is also useful when verifying a circuit, marking each connection as you verify it.

Build this on your breadboard and upload the complete system sketch from Example 8-4. It’s OK that the sketch assumes three valves and we have only one: you can set times and allow the other two to activate, but nothing will happen.

Now test it: Press P to display the current settings and verify that they are all zero. Note the current time. Press S and set an ON time that is a minute or so away, and then set an OFF time for a minute after that. Your relay should click and the LED should come on. Your water valve may or may not do anything, depending on whether it works without any water pressure (mine makes a very reassuring click even without water).

Problems? Double-check your wiring. Pay particular attention to the diodes, the MOSFETs, and the relay. Remember that each pin of the MOSFET has a particular function, and you must use the correct pin. Remember that the diode is polarized. The black band indicates the cathode. Remember that the relay has a black strip indicating pins 8 and 9. If your water valve power supply and water valves use direct current (DC), make sure the positive and negative ends are connected where they are supposed to be.

This step also helps remind you of the importance of getting the MOSFETs, diodes, and relays wired up the right way. Once you solder these components, it won’t be so easy to change. So once you get things working, make sure you understand why. Make notes of any mistakes you made and how you fixed them. You might even want to take some pictures of your breadboard for reference. It’s always a good idea to document your work.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *