Skip to content

Latest commit

 

History

History
55 lines (45 loc) · 2.09 KB

README.md

File metadata and controls

55 lines (45 loc) · 2.09 KB

Soil Moisture Sensor

A simple soil moisture sensor using an Arduino UNO microcontroller.

Components Used

Code

This program is written in the C++ programming language.

👉 View Code

Used Libraries

Connections

Arduino Pin Display Pin Sensor Pin
GND GND GND
A4 SDA
A5 SCL
A0 AOUT
5V VCC
3.3V VCC

Calibration

Sensor Calibration Code

The sensor data pin is connected to pin A0.

void setup() {
  Serial.begin(9600);
}
void loop() {
  int value;
  value = analogRead(A0);
  Serial.println(value);
  delay(100);
}

Steps

First, record the highest value the sensor obtains when dry. Change the value in the code (default is 603) to the measured value:

const int dryValue = 616; -> const int dryValue = YOUR_VALUE;

Next, measure the value the sensor obtains when wettest. Measure and replace the value in the code:

const int wetValue = 292; -> const int wetValue = YOUR_VALUE;

Now, upload the code to the Arduino and everything should work!