Over a million developers have joined DZone.

Moisture Sensor with Intel Galileo

· IoT Zone

Access the survey results 'State of Industrial Internet Application Development' to learn about latest challenges, trends and opportunities with Industrial IoT, brought to you in partnership with GE Digital.

Recently I was playing with a moisture sensor for one of my projects so I thought to share it with you. I got that 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 deficits, 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. More water makes the soil conduct electricity more easily (less resistance), while dry soil conducts electricity poorly (more resistance. You can know whether a plant needs water or not by observing the results that the sensor outputs. Now by the end of this blog you will be able to make your own moisture sensor that can track the water need of plants of 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:
o Analog output(Yellow wire)
o GND(Black wire)
o Power(Red wire)
o DO: Digital output interface


The code is written in C++ with Visual Studio which is going to deploy on Intel Galileo running on windows.


Here I am using Gen1 board but you can definitely use any.
According to the code sensor data is received by 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 gets dry or you can do something else with your Advanced Gardening System to alert you that Plant needs water. Also I have noticed that different sensors give you different values. So might be your values of Dry, Moist and Wet soil will be different than mine but you can always play with the values and tabulate them. After few samples you can finally conclude the values for each different condition of moisture with your sensor.

Values when sensor is placed in water-


Values when sensor is in air(dry) -


The IoT Zone is brought to you in partnership with GE Digital.  Discover how IoT developers are using Predix to disrupt traditional industrial development models.


Published at DZone with permission of Pooja Baraskar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}