Moisture Sensor with Intel Galileo
How to use a moisture sensor component for your IoT projects.
Join the DZone community and get the full member experience.Join For Free
recently i was playing with a moisture sensor for one of my projects so i thought to share it with you. i got it from ebay for less than $4. basically a soil moisture sensor measures the water content in soil. with it, you can easily tell when the soil needs more water or when it’s over-watered. when the soil moisture is deficient the sensor output value will decrease. this sensor uses the two probes to pass current through the soil and then it reads that resistance to get the moisture level. wet soil causes the soil to conduct electricity better (less resistance), whereas dry soil conducts electricity poorly (more resistance). you can determine whether or not a plant needs water by observing the results that the sensor outputs. now by the end of this article you will be able to make your own moisture sensor that can track the water needs of the plants in you garden.
this is how a soil moisture sensor looks:
- moisture sensor module (arduino compatible)
- intel galileo board
- jumper wires
- power supply: 3.3v or 5v
- pin definition:
- analog output (yellow wire)
- gnd (black wire)
- power (red wire)
- do: digital output interface
the code is written in c++ with visual studio that will deploy on intel galileo running on windows.
here i am using a gen1 board but you can definitely use any.
depending on the code, the sensor data is received by the a0 pin. however any analog i/o pin can do the task. my sensor was showing values above 300 when the soil is moist and above 500 when it is completely dry but when i place it in water the values drops to 100. here i have attached an led to alert us when the soil becomes dry or you can do something else with your advanced gardening system to alert you that the plant needs water. also i have noticed that different sensors give different values. so perhaps the values for dry, moist and wet soil will be different from mine but you can always play with the values and tabulate them. after a few samples you can finally determine the values for each condition of moisture with your sensor.
the following shows the values when the sensor is placed in water:
the following shows the values when the sensor is in air (dry):
Published at DZone with permission of Pooja Baraskar, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.