Part of the project is the moisture sensors. The moisture sensors consist of 2 nails, one of which is connected to the power on the ardunio board, the other is connected to an analog pin on the board and a resistor.
The sensors are placed in the dirt and the resistance between them is measured.
When I first created the sensors about a month ago, they were reading values between 400 and 900, and large range that was good for calibrating the system. However when I picked the project back up this week, the sensors only read between 1 and 5. I checked the whole system over and cannot seem to fix the problem
Any ideas on why the resistance values it is reading have become so low?
Maybe the nails or the connections to the nails have rusted/corroded? Rust is not a good conductor.
Do you have a multimeter to measure the actual resistance between the nails? (You'll have to disconnect the Arduino circuitry to accurately measure resistance.)
I will definitely keep the idea of corrosion in mind when I get everything up and running. Actually I'm still in the process of testing everything out and I haven't had the nails submerged in the dirt yet at all. Its some issue that doesn't have to do with the planting side of the project.
I've tried re-soldering in case the connection was bad but that hasn't helped.
You'll always have problems with corrosion if you use iron nails, BTW,
its polarization that's the issue with DC (you turn the nails and soil into
a battery, but having different chemical reactions at each nail, so that all
readings have a big DC offset).
You either need to move to AC, or power up only for as long as it takes to take a reading
and hope that's not going to cause significant polarisation.
Alternative inert electrodes like platinum or gold can be used, v. expensive.
Its worth using copper/brass or aluminium electrodes rather than iron/steel as
the latter will simply corrode away in months/years.
And as I am fond of saying here, you have presumably been severely misled by reading "tutorials" here (and perhaps elsewhere).
Connecting a sensor between an input pin and Vcc is in general a bad idea because of the potential risk of that Vcc being shorted to ground in the wiring beyond the Arduino.
In this case, it is a much worse idea because even if you took heed of the suggestions to disable the sense current when not actually making a measurement, you would still have one electrode powered by 5V continually causing electrolysis.
At the very least, your reference electrode should be connected to ground. Your "sense" electrode can then be connected to an analog input and the resistor that biases it, connected to another pin that is set as an input (and written LOW to disable the internal pull-up) at all times other then set as an output and HIGH just while you take a measurement - which would clearly be very infrequent.
Even then, there is some potential for electrolysis with the electrode connected to your system ground. To fully isolate both electrodes, you need to have a suitable capacitor in series with each electrode, a value of perhaps 1µF or more and non-polarised (not electrolytic!). You can then leave the "switch" pin feeding the bias resistor as an output set LOW until you need to make a measurement so that the capacitors stabilise their charge, and set it HIGH for only as long as it takes to make your measurement.