0% found this document useful (0 votes)
97 views6 pages

Moisture Sensor

1. This document describes building a soil moisture sensor system using an Arduino Nano board. It uses an analog soil moisture sensor connected to analog pin 0 to read soil moisture levels. Five LEDs connected to digital pins 2-6 with resistors indicate the moisture level - green for wet, yellow for medium, and red for dry. 2. The Arduino code reads the sensor value and maps it to LED states - all green LEDs on for wet soil, progressively fewer LEDs on as soil drys. It prints the sensor values and delays 1 second between reads. 3. Resistors must be used when connecting the LEDs to the Arduino digital pins to prevent damaging the board or LEDs.

Uploaded by

Sammy Pak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views6 pages

Moisture Sensor

1. This document describes building a soil moisture sensor system using an Arduino Nano board. It uses an analog soil moisture sensor connected to analog pin 0 to read soil moisture levels. Five LEDs connected to digital pins 2-6 with resistors indicate the moisture level - green for wet, yellow for medium, and red for dry. 2. The Arduino code reads the sensor value and maps it to LED states - all green LEDs on for wet soil, progressively fewer LEDs on as soil drys. It prints the sensor values and delays 1 second between reads. 3. Resistors must be used when connecting the LEDs to the Arduino digital pins to prevent damaging the board or LEDs.

Uploaded by

Sammy Pak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

https://www.hackster.

io/renesas-team-sece/smart-agriculture-system-with-iot2efb66
http://www.instructables.com/id/Soil-Moisture-Sensor/?ALLSTEPS

1 - Breadboard (http://www.ebay.com/itm/171705651308?ssPageName=ST...
5 - LEDs
5 - 1k resistors
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

<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);
// print out the value you read:</p><p> 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

}</p>

STEP -3 LEDS

***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. **

You might also like