Instructables

Garduino: Gardening + Arduino

Featured

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
diy_bloke5 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 :-)
LeskoIam1 year 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!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!