
The SparkFun Soil Moisture Sensor is a great tool for monitoring the moisture levels in soil, and it's surprisingly easy to set up. The sensor works by measuring the electrical conductivity of the soil, which changes depending on the moisture levels.
The sensor is designed to be used with a microcontroller, such as the Arduino, to read the moisture levels and provide a digital output. This is achieved through the use of a simple analog-to-digital converter.
To get started with the SparkFun Soil Moisture Sensor, you'll need to connect it to your microcontroller and write some code to read the sensor's output. The sensor has three pins: VCC, GND, and OUT, which need to be connected to the corresponding pins on your microcontroller.
For your interest: Artificial Grass
Getting Started
To get started with your SparkFun Soil Moisture Sensor, you'll need to power it. You can do this using Qwiic, which is a great option.
If you're not using Qwiic, make sure to power the sensor with between 3.3V - 5V, as this will give you the best results.
One common issue with soil moisture sensors is their short lifespan when exposed to a moist environment. To combat this, the sensor's PCB has been coated in Gold Finishing (Electroless Nickel Immersion Gold).
You can also extend the lifespan of your sensor by only powering it when you take a reading. This is easy to do using a digital pin set to HIGH on your microcontroller.
Hardware Setup
To get started with the SparkFun Soil Moisture Sensor, you'll need to set it up with your microcontroller. The sensor has three pins to connect: VCC, GND, and SIG.
These pins are pretty straightforward, but it's worth noting that you should supply power to VCC and GND, and not power the sensor constantly to prevent corrosion of the probes.
You'll also need to connect the SIG pin to the ADC pin on your microcontroller, as this is where the analog signal will be sent. This will allow you to read the values from the sensor.
Required Materials

To set up your project, you'll need a few materials. The Soil Moisture Sensor is the main component, but you may not need everything listed, depending on what you already have and the sensor you prefer.
You'll need a soil moisture sensor, and a digital pin to power it. The sensor should be connected to an analog pin, specifically A0.
You may also need a power source, such as a breadboard or a microcontroller.
Setting Up
To get started with setting up your Soil Moisture Sensor, you'll need to connect it to a microcontroller. This is where the sensor's three pins come into play: VCC, GND, and SIG.
The VCC and GND pins need to be supplied with power, but be aware that powering the sensor constantly can lead to corrosion of the probes.
You'll also need to connect the SIG pin to the ADC pin on your microcontroller. The value read on SIG will vary depending on the voltage with which you power the sensor.
Theory and Operation
The SparkFun soil moisture sensor is a clever device that uses two probes to measure soil moisture levels.
These probes act as a variable resistor, with better conductivity resulting in lower resistance and higher SIG out readings.
The sensor's readings will vary depending on the voltage used for Vcc and the resolution of your ADC pins.
Theory of Operation
The probes act as a variable resistor, with better conductivity resulting in lower resistance and a higher SIG out reading.
The amount of water in the soil directly affects the conductivity, making it a crucial factor in determining the resistance.
More water in the soil means better conductivity, which in turn results in lower resistance and a higher SIG out reading.
Your analog readings will vary depending on the voltage you use for Vcc, so it's essential to consider this when interpreting your data.
The resolution of your ADC pins also plays a significant role in determining the accuracy of your readings, so choose wisely.
Read Value

To read the value from the sensor, you'll need to call the readMoistureValue() method on the sensor object. This method returns a value between 0 (100% wet) and 1023 (0% wet, or "dry").
The sensor measures the resistance between its two probes, and the returned value is based on the capabilities of the Analog to Digital converter (ADC) on the sensor's microcontroller. The ADC is 10 bits, with a maximum value of 2^10 = 1024.
To get a percentage value, call the readMoisturePercentage() method. This will give you a value between 0 and 100, representing the moisture level of the soil.
The readMoistureRation() method returns a value between 0 and 1.0, representing the moisture ratio of the soil. This value can be useful for more precise calculations.
Code and Examples
The SparkFun soil moisture sensor is a great tool for monitoring the moisture levels in your plants or soil.
You can find several examples of how to use this sensor with the library provided. For instance, you can use the Basic Readings example to set up and read the soil moisture from the sensor.

The examples also include a Readings and LED example that flashes the sensor LED when reading the moisture value.
You can also use the LED Flash Based on Moisture Percentage example to vary the sensor LED flash rate based on the moisture percent sensed. The flash rate increases the drier the sensed value.
To upload the code to the Arduino, you'll need to use the code provided in the Step 3: Code section. This code tells the sensor how to differentiate between wet and dry soil based on a certain value.
Here are the examples provided with the library:
- Basic Readings - Setup and read the soil moisture from the sensor
- Readings and LED - Flash the sensor LED when reading the moisture value
- LED Flash Based on Moisture Percentage - Vary the sensor LED flash rate based on the moisture percent sensed
Project and Functionality
The SparkFun Qwiic Soil Moisture Sensor is a great tool for monitoring moisture levels in your garden or indoor plants. This sensor provides a simple interface for reading the current resistance (moisture) value from the sensor.
You can also control the on-board LED, turning it on and off as needed. This can be a useful feature for visualizing moisture levels or indicating sensor activity.
The sensor can be configured to use a different I2C address if you need to use multiple sensors together or avoid conflicts. This makes it easy to set up and use multiple sensors in your project.
For more insights, see: Soil Moisture Sensor with Arduino Project Conclusion
Functionality
The functionality of the SparkFun Qwiic Soil Moisture Sensor is quite impressive. You can read the current resistance value from the sensor, which gives you an idea of the moisture level in the soil.
This library provides a simple interface that enables you to read the current resistance value, turn the on-board LED on and off, and change the I2C address of the sensor if needed.
The sensor's on-board LED can be controlled using the library's methods, allowing you to turn it on or off at will. I've found this feature to be particularly useful for testing and debugging purposes.
Here are the specific functionalities provided by the library:
- Read the current resistance value from the sensor
- Turn the on-board LED on and off
- Change the I2C address of the sensor
For SPI bus, you can control the on-board LED, which is a useful feature for creating custom lighting effects or simply testing the sensor's functionality.
Project
We're going to make a portable soil moisture sensor that prints the current moisture value to an LCD screen.

This project uses the circuit from a previous example, and we just need to add a Serial Enabled LCD Screen and portable power.
The soil moisture sensor is connected to the LCD screen at 5V, GND, and digital pin 2 (D2) for serial communication.
You can find more information about the code in the comments, where it explains the different values for the upper and lower thresholds.
The code has a middle zone that could be either wet or dry, depending on whether the soil is drying out or getting wet.
You'll need to adjust the code variables to fit your specific setup, soil type, and desired moisture level.
Using calibration techniques, you can test the reading and play around with the values until you find some that fit your needs.
Setup and Configuration
To set up the SparkFun Soil Moisture Sensor, you'll need to connect it to an Arduino or other microcontroller board.
The sensor comes with a voltage regulator that allows it to operate at 3.3V or 5V, so you can use it with a variety of boards.
First, connect the sensor's VCC pin to the Arduino's 5V pin, and the GND pin to the Arduino's GND pin.
The sensor's OUT pin should be connected to an analog input on the Arduino.
You can use the SparkFun Soil Moisture Sensor library to make it easier to read the sensor's data.
The library provides a simple function to get the soil moisture level, which is represented as a value between 0 and 1023.
Broaden your view: Moisture Soil Sensor Arduino
Featured Images: pexels.com

