Instructables

Step 7: Test and Calibrate Your Sensors

I loaded this code onto my Arduino to read sensors connected to analog pins 0, 1, and 2 and output values to screen:

int moistureSensor = 0;
int lightSensor = 1;
int tempSensor = 2;
int moisture_val;
int light_val;
int temp_val;

void setup() {
Serial.begin(9600); //open serial port

}

void loop() {
moisture_val = analogRead(moistureSensor); // read the value from the moisture-sensing probes
Serial.print("moisture sensor reads ");
Serial.println( moisture_val );
delay(500);
light_val = analogRead(lightSensor); // read the value from the photosensor
Serial.print("light sensor reads ");
Serial.println( light_val );
delay(500);
temp_val = analogRead(tempSensor);
Serial.print("temp sensor reads ");
Serial.println( temp_val );
delay(1000);

}

Here are some values I maintained from my sensors:
moisture (nails fully into soil at opposite ends of milk jug:
nails touching each other: 985
nails in air, not touching: 0
soil that seems too wet: 889
soil that's totally dried out: 0
soil that's starting to seem too dry: 707
soil that seems about right: 826

light:
indirect sun: 949
ambient indoor light at night: 658
ambient indoor light at night, hand casting shadow over sensor: 343
~2 feet from grow light, at night: 832
~2 feet from grow light, at night, hand casting shadow over sensor: 797

temperature (used temperature lead on multimeter to calibrate):
61 degrees Fahrenheit = 901
90F = 949
51F = 877
32F = 796

On soil moisture, it's kind of guesswork unless you get a fancy probe to compare its values to what your Garduino is outputting. Or, you could add a fixed amount of water to a known quantity of soil to figure out how resistance value varies with changes in water added... if you do, you'll want to mount the nails some fixed distance from each other (with some nonconductive material, obviously). Let me know if you do this!
 
Remove these adsRemove these ads by Signing Up

This is an awesome tutorial. When I first created my moisture sensors they were reading values in the 600-700 range, which seemed okay to me. I picked the system back up about a month later when I moved somewhere where I actually have sun, and now they will only read values between 1-50. I tried replacing the nails and double checked the circuit but I can't seem to find a fix. Any ideas what the problem might be?

diy_bloke10 months ago
great. as regarding the reading of yr moisture sensors, what i have done in a similar case is to measure the resistance of the earth via my spikes in my plant bed when it was moist enough and calculated a voltage from that which told me the reading I was going to get from the arduino. used that as an irrigate or not threshold in my program. Worked well.
Keep in mind that two spikes in the earth, also give off a small voltage that can innfluence yr settings :-)
LeskoIam2 years ago
Hey!
I was wandering if someone already tried to calibrate moisture sensors like you proposed? Yes, and did someone use similar system for hydroponics?
I'm just starting to build my own system and but I will probably switch to hydroponics. Really cool idea and implementation!