Final Design for Sustainability Project

The Project;

The aim of this project is to prevent the  over watering of the large agricultural fields. To achieve this we developed an Arduino system with soil moisture sensor and solenoid valve which are connected to each other. The agricultural field has sensors at regular intervals throughout the field which send the soil moisture data to the Arduino microcontroller. Through the microcontroller solenoid valve receives the soil soil moisture  data  and releases enough water to replenish the moisture in soil for a set of time. This process continues until the soil have enough water for the crop.

We strongly believe this system will help to reduce the over watering of crops and therefore save water and produce higher, healthier yield.

These improvements to water usage will lead to greater Sustainability.

Coding of the Project;

int rainPin = A0;
int solenoid = 7;
int sensorValue;
// you can adjust the threshold value
int thresholdValue = 1050;
int thresholdValue1 = 1000;
int thresholdValue2 = 850;
int thresholdValue3 = 700;
int thresholdValue4 = 550;
int thresholdValue5 = 400;

void setup() {
for(int i=2; i<=6; i++){ // sets up LEDs from pin 2 to pin 6
pinMode(rainPin, INPUT);

pinMode(7, OUTPUT);// connected to S terminal of Relay;

void loop() {
// read the input on analog pin 0:
sensorValue = analogRead(rainPin);
checkMoisture(thresholdValue, LOW, 2, 6);
checkMoisture(thresholdValue1, HIGH, 2, 2); //checks moisture(your threshold value, LED HIGH or LOW, starting LED pin, ending LED pin)
checkMoisture(thresholdValue1, LOW, 3, 6);
checkMoisture(thresholdValue2, HIGH, 2, 3);
checkMoisture(thresholdValue2, LOW , 4, 6);
checkMoisture(thresholdValue3, HIGH, 2, 4);
checkMoisture(thresholdValue3, LOW, 5, 6);
checkMoisture(thresholdValue4, HIGH, 2, 5);
checkMoisture(thresholdValue4, LOW, 6, 6);
checkMoisture(thresholdValue5, HIGH, 2, 6);

if(sensorValue < thresholdValue){
digitalWrite(7,HIGH);// turn relay ON;
else {
digitalWrite(7, LOW);// turn relay OFF;

void checkMoisture(int threshold, bool ledLevel, int startingPin, int endingPin) { //checks moisture(your threshold value, LED HIGH or LOW, starting LED pin, ending LED pin)
if(sensorValue < threshold) {
for (startingPin; startingPin<=endingPin; startingPin++){


Fritzing Chart of The Project


fritzing chart-APRIL 19


Photos of the Project;


Moisture Level Measurement



Solenoid System

Sensor-Soil Moisture


Water Tank

Video of the Project; Testing the Solenoid Valve

Testing of the solenoid Valve


Testing of the system


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s