01.10.2019

Soil Moisture Sensor Arduino

Soil Moisture Sensor Arduino 7,7/10 468 votes
  1. Soil Moisture Sensor Arduino Code

Guide for Soil Moisture Sensor YL-69 or HL-69 with Arduino The soil moisture sensor or the hygrometer is usually used to detect the humidity of the soil. So, it is perfect to build an automatic watering system or to monitor the soil moisture of your plants.

You need to supply power to VCC and GND. We recommend not powering the sensor constantly to prevent corrosion of the probes (more on this in a bit). SIG provides an anlog signal out that can be attached to the ADC pin on any microcontroller. The value read on SIG will vary depending on the voltage with which you power the sensor. Theory of OperationThe two probes are acting as a variable resistor – more water in the soil means better conductivity and results in a lower resistance and a higher SIG out. Your analog readings will vary depending on what voltage you use for Vcc as well as the resolution of your ADC pins. Powering the Soil Moisture SensorWe recommend powering the Soil Moisture Sensor with between 3.3V - 5V.

Please note that the analog value returned will vary depending on what voltage is provided for the sensor.One commonly known issue with soil moisture senors is their short lifespan when exposed to a moist environment. To combat this, we've had the PCB coated in Gold Finishing.Another way to extend the lifespan of your sensor is to only power it when you take a reading.

Using a digital pin set to HIGH on an Arduino, for example, is an easy way to accomplish this. If you wish to power the sensor with more than a digital pin on your microcontroller can provide, you could always use a. AssemblyIf you bought the Soil Moisture Sensor that already has the 3-pin screw terminal attached, you may skip this section.As for connecting the senor to your circuit, we've given you a few different options.

You can solder on a if you need to easily switch sensors on your project. This pairs nicely with our connector. Of course, you can always solder some straight to the sensor. WeatherproofingIf you intend to use this sensor outdoors, we recommend adding a little protection to the PCB to extend its lifespan. You could always use good ol' fashioned hot glue.

SoilCapacitive

However, hot glue does not hold up well in the sun and is only recommended for projects that will not be exposed to high temperatures. For projects that need to be able to withstand all the elements, you could use a to cover the SMD parts on the PCB as well as your solder connections. Calibration System CalibrationTo get any sort of useful data out of your Soil Moisture Sensor, it is advised that you calibrate it to whatever soil you plan to monitor. Different types of soil can affect the sensor, and you may get different readings from one composition tot he next. Before you start storing moisture data or triggering events based on that value, you should see what values you are actually getting from your sensor. Using the sketch above, note what values your sensor outputs when the sensor is completely dry vs when the sensor is completely submerged in a shallow cup of water. Depending on what microcontoller you're using, the operating voltage of that microcontoller, and the resolution of its analog-to-digital converter, you're results will vary.For example, using the same circuit above, if I detach the VCC pin from D7 and attach it directly to the 5V supply on the RedBoard, you'll see the close to the following values in the serial monitor when the senor is dry (0) and when it is completely saturated with moisture (880).

Thus, it is difficult to write an example sketch that works for all platforms. It really depends on the operating voltage and ADC resolution of the board you're using. Soil CalibrationOnce you have an idea what values your sensor is outputting in completely dry and completely wet situations, it's time to calibrate your sensor for the specific soil you want to monitor. Do the same test above, only this time test your soil when it is as dry as possible, then measure it when the soil is completely saturated with moisture.

Getting these values and comparing them to the ones from the previous calibration will give you the best insight into what values mean for your specific plant and soil. This test may take some trial and error and patience. Be careful not to over-water (or under-water) your plants during these tests.Once you have a good handle on the values you can expect, you can to adjust your code accordingly. Resources and Going Further Additional ProjectsTo connect your plant monitor to the Internet of Things, from our SparkFun Inventor's Kit for Photon. In it, we show how to connect the soil moisture sensor to an Internet connected device such as the or the.You can also learn how to use the soil moisture sesnor with the Blynk app in the. Get plant watering notifications right on your phone or other mobile device!Check out this great Instructables project from that uses the SparkFun Soil Moisture Sensor:.Check out these other great SparkFun tutorials for more soil moisture sensing fun!

Soil Moisture Sensor Arduino

Soil Moisture Sensor Arduino Code

In 2003, CU student Nate Seidle fried a power supply in his dorm room and, in lieu of a way to order easy replacements, decided to start his own company. Since then, SparkFun has been committed to sustainably helping our world achieve electronics literacy from our headquarters in Boulder, Colorado.No matter your vision, SparkFun's products and resources are designed to make the world of electronics more accessible. In addition to over 2,000 open source components and widgets, SparkFun offers curriculum, training and online tutorials designed to help demystify the wonderful world of embedded electronics. We're here to help you start something. SparkFun Electronics.