

As you can see we are going to be connecting 3 sensors and 1 actuator:
- Rain sensor at bottom center of image
- Soil moisture sensor at bottom left of image
- Light sensor at bottom right of image
All sensors must have power and signal except in the case of the LDR where the signal is the power, because it acts as a resistor (light dependent resistor). So lets start by connecting each sensor individually.
MOISTURE SENSOR
- Connect the red and black wire of the moisture sensor to the red and black wire of the moisture sensor board respectively
RAIN SENSOR
- Connect the red and black wire of the moisture sensor to the red and black wire of the moisture sensor board respectively.
- Connect 3 wires onto the small control board. Use a red for VCC, black for Ground or negative and yellow for signal.
This is what your both sensors should look like right now:

RELAY FOR SOLENOID
What we need now is to wire the relay which takes + and – and signal. We are going to let one of the power cables pass through directly from power source to relay without interruption. We are going to interrupt the other power cable from source to relay. And the third wire, the signal, is what we will use to send a signal from the MCU in order to tell the relay to complete the interrupted power cable connection:

So for the relay right now simply connect 3 different wires to each terminal and we will identify each later.
MOISTURE SENSOR
- Connect 3 wires onto the small control board. Use a red for VCC, black for Ground or negative and yellow for signal.
- Now connect the red VCC from sensor board to red positive rail of the breadboard
- Connect the black ground from sensor board to black negative rail of the breadboard
- Connect the yellow signal cable anywhere else on the breadboard for now
RAIN SENSOR
- Connect 3 wires onto the small control board. Use a red for VCC, black for Ground or negative and yellow for signal.
- Now connect the red VCC from sensor board to red positive rail of the breadboard
- Connect the black ground from sensor board to black negative rail of the breadboard
- Connect the brown signal cable anywhere else on the breadboard for now
Your breadboard should look like this:

Notice the red and black cables from the rain sensor (top left) coming down towards the breadboard’s power rails. The brown signal cable comes down onto any other hole on the breadboard for now.
The cables coming in from the bottom right are the red and black power cables from the moisture sensor below into the same power railing in the respective positions. The grey cable is the signal cable from the moisture sensor below.
LDR
- Bring the LDR somewhere into the same side of the breadboard for connecting.
RELAY
- Connect the power cables (red and black) from the relay onto the top power railing on the breadboard. This is because you want to keep the different power sources separate. The operating voltage for the sensors is around 5v but the voltage for the relay/load could be much higher, at least 12V. [CRITICAL: THIS IS TEMPORARY]
- Connect the signal cable from the relay to another hole on that same side of the breadboard
Your setup should now look like this:

As you can see we have 3 red power VCC cables, 3 black negative GND cables and 3 yellow signal cables.
Now we need to bring in the MCU.
MCU
- Connect the red and black cables to the MCU 5V and GND pins in order to supply power ONLY to the low power side (the sensor power rails on the bottom of our breadboard)

We must also connect the GNDs. This is important so that both GNDs will be tied and therefore equal so they can be used as reference 0 or Ground.
- To do this we connect a black cable from the extra GND pin on the MCU to the black GND power rail on the high side, where the relay power source connects to. This is what the connection looks like (white arrows).

Now we must continue by connecting our last sensor which we had left behind, the LDR. This is the easiest one:
LDR
- Connect a red cable from one of the LDR legs to the red power rail on the low power side with all the other sensors.
- Instead using more wires and holes, simply connect the other leg of the LDR down to the negative power rail on the low side using a 220R resistor. The connection diagram for the LDR using the resistor is shown here

Now if you notice we only powered the LDR, we didnt connect the signal pin yet. So let’s take care of all the signals now.
ALL SIGNALS
- Connect the signal pin from the moisture sensor cable to A0
- Connect the signal pin from the rain sensor cable to A1
- Connect the signal pin from the LDR cable above to A2
- Connect the signal pin from the relay to the MCU at pin D7
Your setup should now look like this:

You can see we took the signal cables that were previously on the breadboard from rain and moisture, over to the Analog pins, A0 and A1, on the MCU. We also inserted a signal cable between the LDR GND leg and the Resistor and connected it to the A2 pin. Finally we connected the relay signal cable to the D7 pin on the MCU.
Our 3 sensors can send signals to the Analog pins on the MCU and we can program the MCU to send a signal to the relay when our conditions are met in just the right way.
SOLENOID
Now we will finally bring in the solenoid valve which has a + and a – terminal. We will connect it to the relay and breadboard and we will be done.
- Connect one of the terminals of the solenoid to the NO terminal of the relay, this is equivalent to the VCC red cable. What that means is that the VCC red terminal will be Normally Open, NO, therefore no current will flow through it.
- Connect another red cable from the Common terminal on the relay, C, to the red positive VCC power rail on the high side of the breadboard.
- Finally connect the remaining cable from the solenoid directly to the negative GND rail on the breadboard high power side
Your setup should look like this:

You can see one of the cables on the solenoid goes directly to the black negative GND rail on the breadboard high power side.
The other cable from the solenoid goes through the relay. It enters the NO terminal and exits through the C terminal and finally connects to the VCC positive rail on the high power side of the breadboard.
POWER
The only thing left to do is power the solenoid and program the MCU (Arduino).
- Connect a 12V power source to the breadboard high power side by connecting positive power source red to VCC positive red on the breadboard’s high power side rail.
- Connect the 12V negative cable to the black GND negative rail on the breadboard’s high power side as well.
- Now move the power cables from the relay over from the high power rails of the breadboard down to the low power side of the breadboard. Thats because the relay only needs 5V on its low side.

As you can see we moved the red and black power cables from the top high-power side of the breadboard down to the bottom low-power side of the breadboard.
Once again the final wiring is the one shown here:

Now upload the code and you are ready to go!
Well, dont forget to connect the hose to the solenoid valve.