You are on page 1of 24

let's make Explore (/tag/type­id/) Publish (/about/create.

jsp)
Login (/account/login) | Sign Up (/account/gopro?sourcea=header&sourceaUrl=%2Fid%2FSoil­Moisture­Sensor%2F)

Featured: share what you make


 (/id/intel/) Intel IoT (/id/intel/)
(/)
 (/tag/type­id/category­workshop/channel­laser­cutting/) Laser Cutting (/tag/type­id/category­workshop/channel­laser­cutting/)

 (/tag/type­id/category­home/channel­life­hacks/) Life Hacks (/tag/type­id/category­home/channel­life­hacks/)  (/id/Fusion/) Fusion 360 (/id/Fusion/)

Arduino Soil Moisture Sensor  by innovativetom (/member/innovativetom/)
 Download (/id/Soil­Moisture­Sensor/?download=pdf) h (/id/Soil­Moisture­Sensor/) 6 Steps .
  Collection   I Made it!  Favorite   Share  

About This Instructable

License:
8 114,860views
 167favorites

innovativetom
(/member/innovativetom/)
Innovative Tom
(http://innovativetom.com)

(/member/innovativetom/)
Follow 27

Bio: 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 ...
(/file/FMCIX3KHWNUKOBA/) More » (/member/innovativetom/)

More by innovativetom:

***Edit***
Please use resistors when connecting the LEDs to your Arduino!
 (/id/2x4­and­
***Edit***
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
Plywood­Work­Bench/)
easy build and I would class it as a beginner project.

 (/id/Soil­Moisture­
Ad
Modbus CAN/J1939 Logger
Cellular Modem Option Modbus RTU, TCP, and
more! Sensor/)  (/id/LM35­
www.poseidonsys.com

Temperature­Sensor/)

Tags: arduino (/tag/type­id/keyword­arduino/)

sensor (/tag/type­id/keyword­sensor/)

soil moisture sensor (/tag/type­id/keyword­soil%20moisture%20sensor/)

plant sensor (/tag/type­id/keyword­plant%20sensor/)

plants (/tag/type­id/keyword­plants/)

Step 1: Things you will need poting (/tag/type­id/keyword­poting/)

planting (/tag/type­id/keyword­planting/)

indoor (/tag/type­id/keyword­indoor/)

beginner (/tag/type­id/keyword­beginner/)

arduino project (/tag/type­id/keyword­arduino%20project/)

breadboard (/tag/type­id/keyword­breadboard/)

Related

Leaf Light: An Indoor Garden
Monitor (/id/Leaf­Light­An­
Indoor­Garden­Monitor/)
by knsievert
(/id/Leaf­ (/member/knsievert/)
Moisture Sensor with Intel
Galileo (/id/Moisture­Sensor­
with­Intel­Galileo/)
by Pooja_Baraskar
(/id/Moisture­ (/member/Pooja_Baraskar/)
DIY Moisture Sensor With
Intel Galileo (/id/DIY­
Moisture­Sensor­With­Intel­
Galileo/)
(/id/DIY­ by charlesm29
Guardian of the Garden
(/id/Guardian­of­the­Garden­
(/file/FCL4GS3HWNUKSZK/)
1/)
by Explaining Today
(/id/Guardian­ (/member/Explaining+Today/)
Soil Moisture Meter Detection
1 ­ Breadboard (http://www.ebay.com/itm/171705651308?ssPageName=ST... module for Arduino
Gardening (/id/Soil­Moisture­
5 ­ LEDs
Meter­Detection­Module­for­
5 ­ 1k resistors (/id/Soil­ Arduino­G/)

1 ­ Soil Moisture sensor kit (http://www.ebay.com/itm/171705525756?
ssPageName=ST...
1 ­ Arduino Nano (http://www.ebay.com/itm/171728876932?ssPageName=ST...
~8 ­ Assortment of jumpers.

Step 2: Arduino
9

(/file/F70Y7UQHWNUKOBD/)

(/file/FGSCYXOHWNUKOC0/)

The Code:
<p>/* </p><p>Innovativetom.com 
Flower Pot Soil Mosture Sensor</p><p>A0 ‐ Soil Mosture Sensor 
D2:D6 ‐ LEDS 1,2,3,4,5</p><p>LED1 ‐ Green 
LED2 ‐ Green 
LED3 ‐ Green 
LED4 ‐ YELLOW 
LED5 ‐ RED</p><p>Connect the Soil Mosture Sensor to anolog input pin 0,  
and your 5 led to digital out 2‐6</p><p>*/ 
int led1 = 2; 
int led2 = 3; 
int led3 = 4; 
int led4 = 5; 
int led5 = 6;</p><p>int mostureSensor = 0;</p><p>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); 
}</p><p>// the loop routine runs over and over again forever: 
void loop() { 
  // read the input on analog pin 0: 
  int sensorValue = analogRead(mostureSensor); 

Step 3: LEDs

(/file/F7Y177MHWNUKPAP/)

(/file/FONFIHVHWNUKOC2/) (/file/FIP87URHWNUKOC3/)
(/file/FCRET4NHWNUKOC6/) (/file/FESLK01HWNUKODD/)

***Edit*** 
Please use resistors when connecting the LEDs to your Arduino!
***Edit***
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.
**Here you must put a 1k resistor between anode (+) and the positive rail.
Connect the anode or (+) lead from the LED to the + positive rail of the
beadboard. **

Step 4: Wiring

(/file/FRGJ3QDHWNUKOEH/)
(/file/F1SPC01HWNUKOEI/) (/file/FZV57C6HWNUKOEJ/) (/file/FSFE87BHWNUKOEK/)

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.

Step 5: The Moisture Sensor

(/file/FH8Z5I9HWNUKOEL/)

(/file/FO5JVORHWNUKOEM/) (/file/FDXBUTTHWNUKOEO/)
(/file/FCCYI9RHWNUKOET/) (/file/FPDFAZRHWNUKOEW/)

The moisture has very well defined pin out.
Connect the ground to the ground rail, power to the power rail.
Connect the "AC" Labeled pin on the moisture sensor to analog input 0 pin on
the Arduino.
*note, the moisture sensor I have has two outs one labeled "AC" and one
labeled "DC". The "AC", is a serial signal 0­5 volts that 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 desired point.

Step 6: Your Done.

(/file/FGNEYU9HWNUKOF0/)
(/file/FIUTB70HWNUKSWR/)

(/file/F3FBL25HWNUKOF3/)

Connect up the Arduino and load the code;
Code On Github (https://github.com/Innovativetom/Mosture­Sensor­LEDs)
Innovative Tom (http://innovativetom.com)
Buy the Kit:
eBay Link (http://www.ebay.com/usr/innovative_tom)

Ad
Modbus CAN/J1939 Logger
Cellular Modem Option Modbus RTU, TCP, and
more!
www.poseidonsys.com

We have a be nice comment policy. 
 Please be positive and constructive. w  I Made it!    Add Images   Post Comment

2 days ago Reply
emirbyildiz (/member/emirbyildiz) made it! 

Nice project. I will add a dc water pump motor, 6x18650 battery and a 12V solar
panel to make it permanent. Thank you!

(http://cdn.instructables.com/FPC/3PYG/IOPZE03O/FPC3PYGIOPZE03O.LARGE.jpg)

mojoj1 (/member/mojoj1)
5 days ago Reply

hello, what is the function of those LED? why is there too
many? and if the plant is lack of water, what signal will the
arduino gives and what if there is too much water or the
water is enough already? please help me, im new in this
arduino.

An account (/member/An account) a month ago Reply

I'm using a moisture sensor for a project. Thanks for the
awesome tutorial!

d_jack (/member/d_jack) 2 months ago Reply

Hi all, great setup you have here. Firstly I am new to a lot
of this and have forgotten a lot of what I used to know so
hopeing someone can help with a problem I have. I have
built a watering system using this ....
http://www.ebay.com/itm/391289602060?
_trksid=p2055119.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT
I have kept it basic just using this board to switch solenoids
directly. I have also used one of these boards as a
floatless switch to turn on a drain pump in a sump in case
of flooding however as soon as the level drops past the
probe it starts a nasty echo pulsing the pump on and off till
the level drops clear enough not to retrigger the sensor.
What I want to do as add an electrolytic to the output
transister on the board that switches the relay to give me
2­5 seconds of run on to let the water clear the probe.
Could someone please suggest a simple way to do this
and component values? Thankyou in advance! Dave

hunsnowboarder (/member/hunsnowboarder) 2 months ago Reply

Nice instructable. Maybe switch case would be more
practical instead of if/elseif.

2 months ago Reply
flpsoares (/member/flpsoares) made it! 

Very helpful, thanks!

(http://cdn.instructables.com/FI1/UFA0/IM9G9D4G/FI1UFA0IM9G9D4G.LARGE.jpg)

3 months ago Reply
ngreen17 (/member/ngreen17) made it! 

slightly modified but still i made it

(http://cdn.instructables.com/FP3/CR2J/ILE2NWC8/FP3CR2JILE2NWC8.LARGE.jpg)
swapnilm16 (/member/swapnilm16) 3 months ago Reply

can u help me to create code for turning dc water pump on
and off using soil moisture sensor and arduino nano

X Circuito io (/member/Circuito io)  .  swapnilm16 (/member/swapnilm16) Reply


8
3 months ago
hey, check out circuito.io and our latest instructable:
http://www.instructables.com/id/Thirsty­Flamingo/

SteveB15 (/member/SteveB15) a year ago Reply

Nice job but it does need a few simple refinements to make it
practical...
Add 1K resistors to the LEDs and correct the code so that the
red LED will light.
The probe only needs to be on while a reading is taken, so
poll the probe for one second every half hour by driving it
from a digital pin. In my example code I used D7. This greatly
improves power consumption and extends the life of the
probe by several orders of magnitude since damage by
electrolysis will be insignificant. If you want to check after
watering, just press reset for a new reading.
Here's my modified code with probe polling:
/*
Innovativetom.com 
stevebrace.co.uk
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 probe = 7;
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);
pinMode(probe, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// Power­up the probe and pause for the driver
digitalWrite(probe, HIGH);
delay(1000);
// 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, HIGH);
}
else if (sensorValue >= 615 && sensorValue < 820)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
}
else if (sensorValue >= 410 && sensorValue < 615)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
}
else if (sensorValue >= 250 && sensorValue < 410)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
}
else if (sensorValue >= 0 && sensorValue < 250)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
}
// Power­down the probe
digitalWrite(probe, LOW);
delay(1800000); // wait half an hour
}

AdeV (/member/AdeV)  .  SteveB15 (/member/SteveB15) 3 months ago Reply

You could save a bunch of code by using a switch() statement with "fall­
through" to set your LEDs... I haven't tested this code, so it might need
debugging, but here's what I'd do:
// Reset all LEDs 
digitalWrite(led1, LOW); 
digitalWrite(led2, LOW); 
digitalWrite(led3, LOW); 
digitalWrite(led4, LOW); 
digitalWrite(led5, LOW);
switch(sensorValue) { 
case >= 820: 
digitalWrite(led5, HIGH); 
// normally we'd put "break;" here to exit the select 
case >= 615:
digitalWrite(led4, HIGH); 
case >= 410: 
digitalWrite(led3, HIGH); 
case >= 250: 
digitalWrite(led2, HIGH); 
case >= 0: 
digitalWrite(led1, HIGH); 
}
By excluding the break; after each case statement, the code "falls
through" and runs all the other cases as well. But it only runs from the first
case that matches, so if the sensor value was 255 for example, the first
matching case is "case >= 250", so LED2 comes on. The code falls
through from there & also turns led1 on. Since all LEDs were turned off at
the start, leds3, 4 and 5 remain off.
HTH!

DaveS101 (/member/DaveS101)  .  SteveB15 (/member/SteveB15) Reply

hey steve instead of using delay would it not be better to use 5 months ago
a blink without delay method as not to tie up the processor if it
is in the middle of a delay you lose all other functions till the
delay is over, way better to time it with millis(); function then
you can respond to interrupts like button pushes or sensor
inputs it is always best to not use delay
setup
long previousMillis = 0;
long interval = 900000; // 15 minutes
main loop
{
unsignedlong currentMillis = millis();
if(currentMillis ­ previousMillis > interval)
{
previousMillis = currentMillis;
}
else
{
get value from sensor once every 15 minutes
}
}

DaveS101 (/member/DaveS101)  .  DaveS101 (/member/DaveS101) Reply

5 months ago
//working program you can use more millis(); timers for the
sensor delays i //just //did not have time to work it up yet i can
post it later but the odds of //hitting the delay during a button
push are 1 in 500 with 2ms delay i consider //this acceptable i
have not noticed any trouble from it
//By Dave Soderbloom 
//Quick sketch for water sensor reading without delay to tie up
processor for other tasks like interrupts  
//pins I used on msp432 

int led1 = 2; 

int led2 = 3; 

int led3 = 4; 

int led4 = 5; 

int led5 = 6; 

int probe = 8; 

int moistureSensor = A7; 

int sensorValue = 0; 

long previousMillis = 0; 

long interval = 10000; // 15 minutes900000 

void setup() 

Serial.begin(9600); 

// setting the led pins to outputs 

pinMode(led1, OUTPUT); 

pinMode(led2, OUTPUT); 

pinMode(led3, OUTPUT); 

pinMode(led4, OUTPUT); 

pinMode(led5, OUTPUT); 

pinMode(probe, OUTPUT); 

//get and display startup reading before main loop to the serial
monitor 
digitalWrite(probe, HIGH); 
delay(1000); 
int sensorValue = analogRead(moistureSensor); 
Serial.println(sensorValue); 
digitalWrite(probe, LOW); 

void loop() 

unsigned long currentMillis = millis(); 

int sensorValue = analogRead(moistureSensor); 

if(currentMillis ­ previousMillis > interval) 

previousMillis = currentMillis; 

digitalWrite(probe, HIGH); 
delay(2); //super small delay may need to be higher
depending on your arduino or launchpad board you are using
some take 200 miliseconds to get accurate analog reading 

int sensorValue = analogRead(moistureSensor); 

// print out the value you read: 
Serial.println(sensorValue); 

//may have to adjust ranges depending on a few factors  
if (sensorValue >= 820) 

digitalWrite(led1, HIGH); 

digitalWrite(led2, HIGH); 

digitalWrite(led3, HIGH); 

digitalWrite(led4, HIGH); 

digitalWrite(led5, HIGH); 

else if (sensorValue >= 615 && sensorValue < 820) 

digitalWrite(led1, HIGH); 

digitalWrite(led2, HIGH); 

digitalWrite(led3, HIGH); 

digitalWrite(led4, HIGH); 

digitalWrite(led5, LOW); 

else if (sensorValue >= 410 && sensorValue < 615) 

digitalWrite(led1, HIGH); 

digitalWrite(led2, HIGH); 

digitalWrite(led3, HIGH); 

digitalWrite(led4, LOW); 

digitalWrite(led5, LOW); 

else if (sensorValue >= 250 && sensorValue < 410) 

digitalWrite(led1, HIGH); 

digitalWrite(led2, HIGH); 

digitalWrite(led3, LOW); 

digitalWrite(led4, LOW); 

digitalWrite(led5, LOW); 

else if (sensorValue >= 0 && sensorValue < 250) 

digitalWrite(led1, HIGH); 

digitalWrite(led2, LOW); 

digitalWrite(led3, LOW); 

digitalWrite(led4, LOW); 

digitalWrite(led5, LOW); 

// Power­down the probe 

digitalWrite(probe, LOW); 

}

SteveB15 (/member/SteveB15)  .  DaveS101 (/member/DaveS101) Reply

5 months ago
Thanks for taking the time to make, not only constructive
criticism, but also posting your solution. This is exactly the
kind of input we like!

ABHINAV REDDY (/member/ABHINAV REDDY)  .  SteveB15 (/member/SteveB15)

Can u give me the code if I want to place relay instead a year ago Reply

of led.plz. // ........ Is that the part of coding 

SteveB15 (/member/SteveB15)  .  ABHINAV REDDY (/member/ABHINAV REDDY)

Abhinav, just use the code as is but drive the relay from a year ago Reply

your desired digital pin through a transistor. Don't forget
to place a reverse bias diode across the relay coil to
protect against back EMF.

ABHINAV REDDY (/member/ABHINAV REDDY)  .  SteveB15 (/member/SteveB15)

Thanks  a year ago Reply

//power the probe etc 
Is that the part of code,which transistor should I use

JasonEdinburgh (/member/JasonEdinburgh)  .  ABHINAV REDDY
(/member/ABHINAV REDDY) a year ago Reply

if you use a relay module like this then it has the
transistor and diode already
http://img.dxcdn.com/productimages/sku_319093_1.jp...
(http://img.dxcdn.com/productimages/sku_319093_1.jpg)
I found with mine that it was a LOW signal that caused
the relay to engage. (not a high signal as I expected). It
also needed just under 5v to work. Read the datasheet
info on whichever module you use.

joyang (/member/joyang) 3 months ago Reply

Hi! Nice work. How did you select the sensor value
ranges? And what is the unit of measurement? Are the
output values voltages or some capacitance values?

grega.znoj.9 (/member/grega.znoj.9) 3 months ago Reply

You can save few lines using bitWrite instead digitalWrite :)

FrankB61 (/member/FrankB61) 4 months ago Reply

Hai can any one help me for. I need to swit 3 sensors whit
3 solenoids. i am messuring diverend spots in a
greenhouse and i need to messure diverend spots.
when a spot is dry it must water whit a pump ( trou relay)
when wet it has to stop.
I will need to ajust the sensor for opening ( diverend plant
need diverend moister)
hard ware no problem program big problem.
This program is verry nice but how can i transform it to my
needs??
pleaaasssseeee help...

Jsminetan (/member/Jsminetan) 4 months ago Reply

Hi everybody, i am new here and would like to start a diy
watering plant project. Its solely for my hobby!  
My plan goes like this: because i am using a normal
moisture sensor (the squarish one), i will put that moisture
sensor into the soil and try to detect whether water is
present. If theres water present, the motor pump would not
start. If there isnt, the motor pump would start to pump
water out of the tank. I have been fidgeting with codes, but
i cant seem to get the motor to work.. can anybody help
me..?

AnujM2 (/member/AnujM2) 10 months ago Reply

can we use uno board instead

yousif_rc (/member/yousif_rc)  .  AnujM2 (/member/AnujM2) Reply

5 months ago
Yes u can

a year ago Reply
the_resident (/member/the_resident) made it! 

Hey guys,
Here are a lot of pics if someone (noob like me) want to see the connections :)
I must thank Tom for the initial post and to Steve for the second version,  
In the photos I used the second version but the first one works just fine,  

I'm working now on a version where I can use an ATTINY85 chip to get rid of
the Arduino so my mom plant can be more happier and I can keep my Arduino,
hehe 
I want to use a I2C display as well, if any of you guys can help me with a piece
of code to make my life easier it'll be much appreciated!
Thanks!

(http://cdn.instructables.com/F8A/44KM/I9CLYXGM/F8A44KMI9CLYXGM.LARGE.jpg)

(http://cdn.instructables.com/FJG/293H/I9CLYXGN/FJG293HI9CLYXGN.LARGE.jpg)

(http://cdn.instructables.com/FJN/R8XM/I9CLYXI4/FJNR8XMI9CLYXI4.LARGE.jpg)

(http://cdn.instructables.com/FMI/Q1SI/I9CLYXJM/FMIQ1SII9CLYXJM.LARGE.jpg)

(http://cdn.instructables.com/FM7/MBE1/I9CLYXJO/FM7MBE1I9CLYXJO.LARGE.jpg)

(http://cdn.instructables.com/F7Z/7VME/I9CLYXL8/F7Z7VMEI9CLYXL8.LARGE.jpg)

(http://cdn.instructables.com/FG8/07SF/I9CLYXL9/FG807SFI9CLYXL9.LARGE.jpg)
(http://cdn.instructables.com/FBK/R86N/I9CLYXLA/FBKR86NI9CLYXLA.LARGE.jpg)

(http://cdn.instructables.com/FBA/8UQU/I9CLYXLD/FBA8UQUI9CLYXLD.LARGE.jpg)

(http://cdn.instructables.com/F0Z/FI31/I9CLYXMW/F0ZFI31I9CLYXMW.LARGE.jpg)

(http://cdn.instructables.com/FO5/TYG2/I9CLYXN1/FO5TYG2I9CLYXN1.LARGE.jpg)

(http://cdn.instructables.com/FFE/PZW0/I9CLYXOL/FFEPZW0I9CLYXOL.LARGE.jpg)

(http://cdn.instructables.com/FXB/8MMA/I9CLYXOW/FXB8MMAI9CLYXOW.LARGE.jpg)

(http://cdn.instructables.com/FNA/7TR3/I9CLYXP5/FNA7TR3I9CLYXP5.LARGE.jpg)

(http://cdn.instructables.com/FMY/BCAF/I9CLYXS0/FMYBCAFI9CLYXS0.LARGE.jpg)
jatinakhatri (/member/jatinakhatri)  .  the_resident (/member/the_resident) Reply

5 months ago
i tried the same , but all the led glowing same time ,no need
of the sensor
no change when i put in water or out of the water.
any suggetion?

the_resident (/member/the_resident)  .  jatinakhatri (/member/jatinakhatri) Reply

5 months ago
hey there, well, if you made all the connections correct it
should work, I am thinking that maybe you messed something
in rush, if you look at the pics you should see cleary how to
hook everything up, you can do a test with just one LED and
see if it works, put the sensor in the water and the led shoul
turn off, I strongly suggest to check your connections and pin
assignments in the source code, if you're still outa' luck send
me a private message and I'll do my best to help ya

TimothyL13 (/member/TimothyL13) 7 months ago Reply

HELP... I'm Noob at this thing. The LED won't turn on. I
followed the step and not sure how the resistor work as the
image is shown. Also should I be using the Code On
Github or the one by SteveB15?
Pls, reply asap, Thanks
Many regards
Tim

(http://cdn.instructables.com/FP2/L5BR/IG5EGPW1/FP2L5BRIG5EGPW1.LARGE.jpg)

(http://cdn.instructables.com/F3E/11IN/IG5EGPW3/F3E11INIG5EGPW3.LARGE.jpg)

(http://cdn.instructables.com/FDS/Y0U2/IG5EGPW4/FDSY0U2IG5EGPW4.LARGE.jpg)

(http://cdn.instructables.com/F05/HCT2/IG5EGPW6/F05HCT2IG5EGPW6.LARGE.jpg)

DLM87 (/member/DLM87)  .  TimothyL13 (/member/TimothyL13) Reply

6 months ago
A couple of things that could fix your board. The LEDs that have the small
electrode inside them connected to earth/negative, will have to be taken
out of the breadboard and reversed. The LED's wouldn't have been
damaged though, so they should still work just fine. Also, hook a resistor
between the each LED and it's matching Arduino jumper wire ­ anything
from 330 Ohms to 10,000 Ohms should work. Putting these in will prevent
overloading the Arduino, LEDs and your USB port on your computer :)

PremR3 (/member/PremR3) 6 months ago Reply

hi, i need to show my output in the serial monitor of my pc ,
instead of led. is this can be done?if it is,please update the
blog for both circuit and code this modification or you can
post as comment. waiting for reply.........

AnkitJ14 (/member/AnkitJ14) 7 months ago Reply

very nice instructable, thank you, you made my day!!
regards­ Ankit. :)

GabrielB21 (/member/GabrielB21) 9 months ago Reply

very nice tutorial !! 
This sensor comes with a fourth digital pin, did someone
already use it? How does it work? 
sorry by the bad inglish :(

8 innovativetom (/member/innovativetom) (author)  .  GabrielB21
(/member/GabrielB21) 9 months ago Reply

You can use it, I found that it was less reliable than
using the analog signal. It is also a simple on and off,
you wont be able to have a bar graph.

JonathanT12 (/member/JonathanT12) 11 months ago Reply

Thanks for the instructable. I've got a bunch of these but
not wired any up yet.
Surely those else if statements don't need the &&'s. You
will only make it to the else if when the value is explicitly
not >= then the second value anyway, if it was the
preivous statement would have been run.
With this many levels of if then wouldn't a switch...case be
better? (it doesn't make a huge difference, I guess, it just
seems the switch is easier to maintain).
Example of what the if / else if could be (with LED lighting
removed, for brevity.
if (sensorValue >= 820)
{
// code
}
else if (sensorValue >= 615)
{
// code
}
else if (sensorValue >= 410)
{
// code
}
else if (sensorValue >= 250)
{
// code
}
else if (sensorValue >= 0)
{
// code
}

SteveB15 (/member/SteveB15) a year ago Reply

Here's a sketch for the ATTiny85 running an 8MHz
bootloader:
­­­
int led1 = 0;
int led2 = 1;
int led3 = 2;
int probe = 3; // Power for the probe
int moistureSensor = A2;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(probe, OUTPUT);
pinMode(moistureSensor, INPUT);
}
void loop()
{
// Power­up the probe and pause for the driver
digitalWrite(probe, HIGH);
delay(2000);
// read the input on analog pin 2:
int sensorValue = analogRead(moistureSensor);
if (sensorValue >= 410 && sensorValue <= 1024)
{
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);
}
else if (sensorValue >= 360 && sensorValue < 410)
{
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
}
else if (sensorValue >= 0 && sensorValue < 360)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
}
// Power­down the probe to prevent electrolysis
digitalWrite(probe, LOW);
// wait half an hour before next read
delay(108000000);
}

SteveB15 (/member/SteveB15)  .  SteveB15 (/member/SteveB15) Reply

a year ago
Oops! Bug in the above code... Last line should be:
delay(1800000);

X nqtronix (/member/nqtronix) 2 years ago 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.

8 innovativetom (/member/innovativetom) (author)  .  nqtronix (/member/nqtronix)
a year ago Reply
For sure I only had it running for a few minutes.

X aramaic (/member/aramaic) made it! 
a year ago Reply

I used a standard Arduino, I made few changes on the breadboard 
connections and I changed the code a little bit in the beginning to make  
all 5 LED's to turns ON when the sensor goes more than 900. Thank you for
this project !!!! It just worked great.

(http://cdn.instructables.com/FXA/B5PZ/I5BSADQ2/FXAB5PZI5BSADQ2.LARGE.jpg)

X aramaic (/member/aramaic)  .  aramaic (/member/aramaic) a year ago Reply

One more thing the moisture sensor from the picture get rusty very quick.
Suggest you to use this one which had more solid metal cover on the fork.
It is the same price, but last months more.

8 innovativetom (/member/innovativetom) (author)  .  aramaic (/member/aramaic)
a year ago Reply
Sweet thanks! I have seen this problem I also heard
cover it in some kind of plastic has work. The name is
slipping my memory right now.

8 innovativetom (/member/innovativetom) (author)  .  aramaic (/member/aramaic)
a year ago Reply
NICE!! just watch those leds, if your going to run it for
any length of time they will burn out.

dick55 (/member/dick55) a year ago Reply


Step 5 says "The AC, is a serial signal" when it is clearly a 0 ­ 5V analog output.
This threw me when I first read it. However I soon realized that this is just a
nomenclature problem; the author definitely is inputting it to a Nano analog port.

8 innovativetom (/member/innovativetom) (author)  .  dick55 (/member/dick55)

True, I was not trying to imply that the signal was AC. a year ago Reply

But that the label of the pin on the moisture sensor said
"AC". I changed the wording around so it made more
sense.

8 innovativetom (/member/innovativetom) (author) 2 years ago Reply

You are both correct. Later today I'll update it with resistors.
@nqtronix I never ran it for more then a minute it two.
@photoace12 I totaly plan on it!

X shinyshinyshiny (/member/shinyshinyshiny)  .  innovativetom
(/member/innovativetom) a year ago Reply

can we have a parts list please?

courtneypk (/member/courtneypk) 2 years ago Reply

Could you add a materials list to this Instructable? For
instance, I'm not sure what the source for the moisture
sensor part might be. Otherwise, it's very clear.
Thanks,
Paul

nkem.ehiemere (/member/nkem.ehiemere) 2 years ago Reply

How did you determine the values and ranges for soil
moister? Do you have any links to your sources I could use?

8 innovativetom (/member/innovativetom) (author)  .  nkem.ehiemere
(/member/nkem.ehiemere) 2 years ago Reply

I just put the sensor in water copied down the analog
number, then divided it by 5. it not very percise but it
seemed to work well for me.

8 photoace12 (/member/photoace12) 2 years ago Reply

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

I More Comments

FEATURED CHANNELS
Home Repair Knitting
(/tag/type­ Survival Breakfast Minecraft (/tag/type­ USB Comics
id/category­ (/tag/type­
Newsletter (/tag/type­ (/tag/type­ id/category­ (/tag/type­ (/tag/type­
workshop/channel­ id/category­ id/category­ id/category­ craft/channel­ id/category­ id/category­ Winter Drinks
Join 2 million + to receive instant
home­ outside/channel­ food/channel­ play/channel­ knitting­and­ technology/channel­
costumes/channel­ (/id/Holiday­ Weddings
DIY inspiration in your inbox.
improvement/) survival/) breakfast/) minecraft/) crocheting/) usb/) comics/) Drinks/) (/howto/weddings/)

enter email I'm in!

Mobile
Download our apps!

Android » (https://play.google.com/store/apps/details?id=com.adsk.instructables)
iOS » (https://itunes.apple.com/app/instructables/id586765571)
Windows » (http://apps.microsoft.com/windows/en­us/app/7afc8194­c771­441a­9590­54250d6a8300)
About Us Find Us
Who We Are (/about/) Facebook (http://www.facebook.com/instructables)
Advertise (/advertise/) Youtube (http://www.youtube.com/user/instructablestv)
Contact (/about/contact.jsp) Twitter (http://www.twitter.com/instructables)
Jobs (/community/Positions­available­at­Instructables/)
Pinterest (http://www.pinterest.com/instructables)
Help (/id/how­to­write­a­great­instructable/)
Google+ (https://plus.google.com/+instructables)
Tumblr (http://instructables.tumblr.com)
Resources
For Teachers (/teachers/)
Artists in Residence (/air)
Gift Pro Account (/account/give?sourcea=footer)
Forums (/community/)
Answers (/tag/type­question/?sort=RECENT)
Sitemap (/sitemap/)

Terms of Service (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |
Privacy Statement (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |
Legal Notices & Trademarks (http://usa.autodesk.com/legal­notices­trademarks/) | Mobile Site (http://m.instructables.com)
 (http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
© 2016 Autodesk, Inc.

You might also like