Introduction: It's Watering Time!
Function:
What this project is able to do is that when put into soil the soil moisture sensor is able to detect the amount of water in the soil and display the amount on the LCD screen. Then depending on the amount of water a corresponding light color LED will light up based on the appropriate amount of water. When the amount of water gets too low the light will flash red and the piezo buzzer will make a chirp noise allerting you to water the plant.
Step 1: Requirements
To be able to complete this project you need to be able to do the following things:
1. Wire a circuit according to a Fritzing diagram
2. Soldering header pins and wires
3. Access to a laser cutter and knowledge on how to use it (Optional-To cut out enclosure)
Required Software:
1. Arduino (Required to push code)
2. Adobe Illustrater (Required for enclosure)
3. Fritzing software (Optional- For further detail on the circuit)
Step 2: Gathering the Materials
Materials Required:
- 1 arduino nano
- 1 small breadboard
- 1 LCD Screen
- 1 potentiometer
- 1 piezo buzzer/speaker
- 1 soil moisture sensor
- 1 Red LED
- 1 Yellow LED
- 1 Green LED
- 3 330ohm resistors
- 1 9v battery and 9v snap battery connecter
- 12+ female to male jumper wires(To extend the LCD Screen instead of soldering)
- 30+ jumper wires (Amount required may vary)
- Loose jumper wire (Used to solder to LED and Piezo buzzer)
Tools Required:
- Soldering iron and roll of solder
- Wire clippers
- Laser Cutter (Optional)
Step 3: Assembling the Circuit
The picture above is a Fritzing diagram of the whole completed project. Also download the fritzing file if you have already downloaded the fritzzing software. For further detail on the wiring of each component proceed to the next steps.
Attachments
Step 4: Soldering the Arduino Nano
When you purchase the arduino nano you will recieve the arduino nano and seperate header pins. To solder the pins easily put them in the arduino nano loosely, making sure the longer sides of the header pins is facing down towards the breadboard, then push them down into the breadboard. The breadbord will keep the pins steady and accurate making the soldering easy.
Step 5: Wiring the LCD Screen and Potentiometer
Refer to the Fritzing Diagram above and wire the LCD screen as seen. In this project the LCD will not be on a bread board so there's two things you can do. One you can solder loose wires to each LCD pin or you can use a female to male jumper wire to connect the LCD. I chose the second option because it's quicker and easier.
LCD Pins:
1 to GND
2 to 5V
3 to the center pin on the potentiometer
4 to Arduino digital pin 12
5 to GND
6 to Arduino digital pin 11
7 (no connection)
8 (no connection)
9 (no connection)
10 (no connection)
11 to Arduino digital pin 5
12 to Arduino digital pin 4
13 to Arduino digital pin 3
14 to Arduino digital pin 2
15 to 5V
16 to GND
Step 6: Wiring the LEDS
The Leds in this project will not be on the breadboard so to extend each pin solder loose wire to each end. Each of the three leds have their negative ends connected to a 330 ohm resistor which is then connected to ground. The positive ends of each led are connected to a digital pin. The red LED is connected to D8, the yellow LED is connected to D7, and the green LED is connected to D10. Refer to the fritzing diagram to wire correctly.
*Refering to one of the images above, the green LED is shown with black tape on it, the tape represents where you will have to solder the led to the piece of wire. Also there's two diffrent ways to solder the LEDs, first you can solder just loose wire to each end then connect the negative end to a resistor on the breadboard, or solder the resistor to the negative end of the LED.
Step 7: Wiring the Piezo Buzzer/speaker
Wire the piezo buzzer according to the fritzing diagram above. The Piezo speaker in this project will not be on the breadboard so to extend each pin solder loose wire to each end. The negative end of the buzzer will be connected to ground and the positive end will be connected to digital pin 9 (D9).
* Black tape is used because i was unable to solder, but soldering is recommended.
Step 8: Wiring the Soil Moisture Sensor
Refer to the fritzing diagram above and wire the soil moisture sensor accourdingly. The sensor has three pins that need to be soldered with loose wire. After soldering the three wires to the sensor connect the VCC wire to power, the GND wire to ground, and the SIG wire to Analog pin 0 (A0).
Step 9: The Power Source
To power the project use a 9v battery with a snap 9v battery connecter. The red wire from the battery connecter will go to the VN pin on the arduino uno and the black wire will connect to ground.
Step 10: Coding
If you are unable to download the code file then copy and paste the code below into a new Arduino file and upload it to your build.
CODE:
/*
1 to GND 2 to 5V 3 to the center pin on the potentiometer 4 to Arduino digital pin 12 5 to GND 6 to Arduino digital pin 11 7 (no connection) 8 (no connection) 9 (no connection) 10 (no connection) 11 to Arduino digital pin 5 12 to Arduino digital pin 4 13 to Arduino digital pin 3 14 to Arduino digital pin 2 15 to 5V 16 to GND
Once everything is connected, load this sketch into the Arduino, and adjust the potentiometer until the display is clear.
Library
The LCD has a chip built into it that controls all the individual dots that make up the display, and obeys commands sent to it by the the Arduino. The chip knows the dot patterns that make up all the text characters, saving you a lot of work. To communicate with this chip, we'll use the LiquidCrystal library, which is one of the standard libraries that comes with the Arduino. This library does most of the hard work of interfacing to the LCD; all you need to pick a location on the display and send your data! Tips
The LCD comes with a protective film over the display that you can peel off (but be careful of the display surface as it scratches easily). The LCD has a backlight that will light up when you turn on your Arduino. If the backlight doesn't turn on, check your connections.
As we said above, the potentiometer adjusts the contrast of the display. If you can't see anything when you run the sketch, turn the potentiometer's knob until the text is clear. This sketch was written by SparkFun Electronics, with lots of help from the Arduino community. This code is completely free for any use. Visit http://learn.sparkfun.com/products/2 for SIK information. Visit http://www.arduino.cc to learn about the Arduino.
Version 1.0 2/2013 MDG */
#include
LiquidCrystal lcd(12,11,5,4,3,2);
// Here we are setting up some water thersholds that we will // use later. Note that you will need to change these to match // your soil type and environment.
int thresholdUp = 400;//400 int thresholdDown = 250;//250
// We are setting up the pin A0 on the redboard to be our sensor // pin input:
int sensorPin = A0;
const int buzzerPin = 9; char notes[] = "cdfda ag cdfdg gf "; // a space represents a rest
int beats[] = {1,1,1,1,1,1,4,4,2,1,1,1,1,1,1,4,4,2}; int tempo = 150;
void setup() { pinMode(buzzerPin, OUTPUT); // Piezzo Buzzer const int songLength = 18;
pinMode(8, OUTPUT); //red LED pinMode(7, OUTPUT);//yellow LED pinMode(10, OUTPUT);// green LED lcd.begin(16, 2); int sensorValue; int sensorValue1; sensorValue = analogRead(sensorPin); sensorValue1 = sensorValue; lcd.write("Water Level:"); } void loop() { int sensorValue; sensorValue = analogRead(sensorPin); // Sets sensor value to Analog read. lcd.print(sensorValue); delay(1000); lcd.clear(); lcd.write("Water Level:"); delay(1000); lcd.setCursor(12,0); if(sensorValue<200) // If water level is below 200, red LED will blink and Buzzer willl chirp. { digitalWrite(8, HIGH); digitalWrite(7, LOW); digitalWrite(10, LOW); highChirp(5, 2); delay(100); lowChirp(5, 2); delay(100); tweet(2, 2); delay(random(100)); }
if((sensorValue>200) && (sensorValue<800)) // If water level is between 200 and 800, yellow LED will blink. { digitalWrite(8, LOW); digitalWrite(7, HIGH); digitalWrite(10,LOW); }
if(sensorValue>800) // If water level is above 800, green LED will blink. { digitalWrite(8, LOW); digitalWrite(7, LOW); digitalWrite(10,HIGH); } } void highChirp(int intensity, int chirpsNumber) { int i; int x;
for (int veces = 0; veces <= chirpsNumber; veces++) {
for (i = 100; i > 0; i--) { for (x = 0; x < intensity; x++) { digitalWrite (buzzerPin, HIGH); delayMicroseconds (i); digitalWrite (buzzerPin, LOW); delayMicroseconds (i); } } } }
void lowChirp(int intensity, int chirpsNumber) { int i; int x;
for (int veces = 0; veces <= chirpsNumber; veces++) {
for (i = 0; i < 200; i++) { digitalWrite (buzzerPin, HIGH); delayMicroseconds(i); digitalWrite(buzzerPin, LOW); delayMicroseconds(i); }
for (i = 90; i > 80; i--) { for ( x = 0; x < 5; x++) { digitalWrite (buzzerPin, HIGH); delayMicroseconds (i); digitalWrite (buzzerPin, LOW); delayMicroseconds (i); } } } }
void tweet(int intensity, int chirpsNumber) {
int i; int x;
//normal chirpsNumber 3, normal intensity 5
for (int veces = 0; veces < chirpsNumber; veces++) {
for (int i = 80; i > 0; i--) { for (int x = 0; x < intensity; x++) { digitalWrite (buzzerPin, HIGH); delayMicroseconds (i); digitalWrite (buzzerPin, LOW); delayMicroseconds (i); } } }
delay(1000);
}
Step 11: Making the Enclosure
For a enclosure you can make whatever kind of containment unit but i chose to laser cut out the unit. The file given to you is ready to be used. but before starting the cut make sure to delete the red squares and the words that label each side of the box, they're just there to help put it together when finished. Also make sure that the cut lines are set to 0.1. The material you use should'nt matter I used wood but acrylic is recommended.