Guess what...we have already done the grunt work to detect moisture! It's just another application of the LDR circuit and code, only we replace the LDR with probes.
For this exercise, you can create a set of probes using two pieces of wire (with the ends stripped), and attach them in place of the LDR, as shown in Figure 9.8. This is the same circuit we built in the previous section and showed in Figure 9.7, only this time, we have replaced the LDR with two wires. Let's make this slight change now:
Figure 9.8 – Moisture detection circuit
Here are the steps to follow, which match the numbered black circles in Figure 9.8:
- Remove the LDR from the breadboard.
- Place a wire (with both ends stripped) into a breadboard row that previously connected to one of the LDR's legs (in the illustration, this new wire connects back to 3.3 volts on your Raspberry Pi).
- Place another wire (with both ends stripped) into a breadboard row that previously...