You can treat the [DFRobot](https://www.ampheo.com/manufacturer/dfrobot) moisture sensor like a simple analog [sensor](https://www.ampheo.com/c/sensors): 3 wires → 3 Arduino pins.
I’ll assume you have a DFRobot Gravity soil/moisture sensor (3-pin Gravity cable: brown, red, yellow). If yours looks slightly different, the logic is still the same: VCC, GND, Signal.

**1. Pinout & wiring**
**Gravity cable colors (DFRobot style)**
* Brown → GND
* Red → VCC (3.3–5 V)
* Yellow → Signal (analog output “Aout”)
**Connect to Arduino Uno (example)**
**Sensor → Arduino**
* VCC (Red) → 5V
* GND (Brown) → GND
* Signal / AOUT (Yellow) → A0
That’s it for basic analog reading.
If your board has a 3-pin “Gravity” adapter, it will usually be labeled VCC / GND / A0 – you can plug it there and then jumper A0 to any [Arduino](https://www.ampheo.com/c/development-board-arduino) analog pin you like.
**If your sensor also has D0 (digital)**
Some DFRobot modules have A0 + D0 (and a little potentiometer):
* A0 → Arduino A0 (continuous analog value)
* D0 → Arduino D2 (or any digital pin) if you want a simple “dry/wet” threshold signal
For just measuring moisture, you only need A0.
**2. Simple Arduino test code (analog read)**
Open Arduino IDE, select your board and port, then upload this:
```
const int sensorPin = A0; // Signal from DFRobot moisture sensor
int sensorValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(sensorPin); // 0–1023 on Uno/Nano
Serial.print("Raw value: ");
Serial.print(sensorValue);
// Optional: map to a 0–100% scale (you should calibrate these numbers!)
int moisturePercent = map(sensorValue, 1023, 300, 0, 100);
// 1023 ~ air (dry), 300 ~ in water or very wet soil (example, adjust!)
if (moisturePercent < 0) moisturePercent = 0;
if (moisturePercent > 100) moisturePercent = 100;
Serial.print(" | Moisture: ");
Serial.print(moisturePercent);
Serial.println("%");
delay(500);
}
```
**How to use:**
1. Upload the sketch.
2. Open Tools → Serial Monitor (set 9600 baud).
3. Watch the “Raw value” and “Moisture %” as you:
* Leave the sensor in air → value should be higher (drier).
* Put the “probe” area into moist soil → value should drop (wetter).
Adjust the map() input values (1023 and 300) after testing dry vs wet in your soil to get better % calibration.
**3. Quick tips**
* Power: Most DFRobot moisture sensors accept 3.3–5 V; with an [Arduino Uno](https://www.ampheo.com/product/a000046-25542493), 5V is fine. If you use a 3.3 V-only board, connect to 3.3 V instead.
* Corrosion:
* The capacitive DFRobot sensor (big PCB, plastic-coated, no exposed copper) is much better long-term in soil.
* Old-school two-prong resistive sensors corrode quickly – don’t leave them powered 24/7; power them only when reading (via a digital pin or [transistor](https://www.onzuu.com/category/transistors)).
* Common ground: If you use extra modules (display, pump driver, etc.), always share GND with the [Arduino](https://www.ampheoelec.de/c/development-board-arduino).