Soil Moisture Sensor

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Food Living Outside Play Technology Workshop

Arduino Soil Moisture Sensor


by innovativetom on June 22, 2014

Table of Contents

Arduino Soil Moisture Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Arduino Soil Moisture Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: LEDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 3: Wiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 4: The Moisture Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 5: Your Done. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

http://www.instructables.com/id/Soil-Moisture-Sensor/
Author:innovativetom Innovative Tom
As a young lad Tom spent most of his days at the heels of his father, working in their shop, also known as the basement. His dad was an extraordinary
cabinet maker and while working on their 1850’s home, one room at a time Tom got used to building things. Although woodworking did not interest him,
electricity, however, did. Around the age of five his dad had set him up with a motor, an old light switch, and a nine volt battery. He was hooked. As he got
older his fascination with the way things worked led him to take apart just about everything. Including his parent’s new five disc CD changer. He was almost
as good as putting them back together.

Intro: Arduino Soil Moisture Sensor


In this instructable I will show you how to connect the an Arduino Nano and a moisture sensor. The information will then be displayed with 5 LEDs. This is very easy build
and I would class it as a beginner project.

Step 1: Arduino
The Code:

/*

Innovativetom.com Flower Pot Soil Mosture Sensor

A0 - Soil Mosture Sensor D2:D6 - LEDS 1,2,3,4,5

LED1 - Green LED2 - Green LED3 - Green LED4 - YELLOW LED5 - RED

Connect the Soil Mosture Sensor to anolog input pin 0, and your 5 led to digital out 2-6

*/ int led1 = 2; int led2 = 3; int led3 = 4; int led4 = 5; int led5 = 6;

int mostureSensor = 0;

void setup() { // Serial Begin so we can see the data from the mosture sensor in our serial input window. Serial.begin(9600); // setting the led pins to outputs
pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(led5, OUTPUT); }

// the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(mostureSensor); // print out the
value you read:

Serial.println(sensorValue); if (sensorValue >= 820) { digitalWrite(led1, HIGH); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, HIGH);
digitalWrite(led5, LOW); } else if (sensorValue >= 615 & sensorValue < 820) { digitalWrite(led1, HIGH); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH);
digitalWrite(led4, LOW); digitalWrite(led5, LOW); } else if (sensorValue >= 410 & sensorValue < 615) { digitalWrite(led1, HIGH); digitalWrite(led2, HIGH);
digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); } else if (sensorValue >= 250 & sensorValue < 410) { digitalWrite(led1, HIGH);
digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); } else if (sensorValue >= 0 & sensorValue < 250) { digitalWrite(led1,
LOW); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); } delay(1000); // delay 1 second between reads }

http://www.instructables.com/id/Soil-Moisture-Sensor/
Step 2: LEDs
Connecting the LEDs;

Digital Pin 2 Green.

Digital Pin 3 Green.

Digital Pin 4 Green.

Digital Pin 5 Yellow.

Digital Pin 6 Red.

Connect the cathode or (-) lead from the LED to the Arduino.

Connect the anode or (+) lead from the LED to the + positive rail of the beadboard.

http://www.instructables.com/id/Soil-Moisture-Sensor/
Step 3: Wiring
In this step we connect the power and ground rails.

From the arduino ground pin connect a short jumper to the blue rail on the breadboard.

From the arduino 5v Pin we connect a short jumper to the red rail on the breadboard.

Bond both rails together.

http://www.instructables.com/id/Soil-Moisture-Sensor/
Step 4: The Moisture Sensor
The moisture has very well defined pin out.

Connect the ground to the ground rail, power to the power rail.

Connect the "AC" pin to analog 0 on the arduino.

*note, the moisture sensor I have has and "AC" and "DC" outputs. The AC, is a serial signal the when fully dry it outputs 5 volts, when fully wet, 0 volts. The DC, is
configured with the trim pot and is brought high when the moisture level reaches a certain point.

http://www.instructables.com/id/Soil-Moisture-Sensor/
http://www.instructables.com/id/Soil-Moisture-Sensor/
Step 5: Your Done.
Connect up the Arduino and load the code;

Code On Github

Innovative Tom

Buy the Kit:

eBay Link

http://www.instructables.com/id/Soil-Moisture-Sensor/
Related Instructables

Hear your plant Hear your


make music! - plants play
Garduino: Arduino
More Humane Gardening + Ethernet controlled plant music! (WIFI Calm & Relaxed
Moisture sensor version by watering system version) by Interaction :
Arduino by
by dr.mcc mattomatto and custom AC mattomatto Plant Plus by
liseman
Receptacles sopon_iamas12
outlets by nataku

Advertisements

Comments
2 comments Add Comment

nqtronix says: Jun 23, 2014. 1:32 AM REPLY


You definitly want to add resistors in series to the LEDs. Otherwise they may drain to much current and damage themselfs or the arduino/atmega.

photoace12 says: Jun 23, 2014. 1:09 AM REPLY


You could add onto this by turning it into a self-watering plant!

http://www.instructables.com/id/Soil-Moisture-Sensor/

You might also like