Soil moisture sensor Automatic Plant Watering System

Hello world! Today i got a new Gold coated soil moisture sensor for my website and i wanted to test it of course, this sensor is a bit better then the regular on the market and the previous ones i used, the sensor is coated with gold which make them last way longer. You can add something that opens and closes with the servo to deliver a stream of water automatic, when the soil is moist enough again the device will close again.

YOU NEED THESE LIBRARIES.

  • Wire.h
    LCD.h
    LiquidQrystal_I2C.h
    Servo.h

Schematic:
lcd-1602a plat watering system Soil moisture sensor

Just wire it up like the schematic upload the code and it should work, if your servo is acting weird try to put a 450 uF capacitor between VCC and GND of the servo, like the schematic. Make sure you connect the white side which has a – on it to GND. The long leg is +.

Parts list:
Arduino uno, I always use the RobotDyn Uno.
Soil moisture sensor Gold Coated.
Servo motor
LCD 1602 With I2C
Jumper wire set MM/FF/MF
Small breadboard or proto board to add a Capacitor between VCC and GND of the Servo. (optional)
Capacitor 450 uF (Optional)

Code:

//author:danny van den brande, arduinosensors.nl. BlueCore Tech.
//This code is created as a example on how to build a automatic watering plant system with a servo. 
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

//Most common adresses PCF8574 = 0x20, PCF8574A = 0x38,PCF8574AT = 0x3F 
//PCF8574T = 0x27   
#define I2C_ADDR          0x27   
#define BACKLIGHT_PIN      3
#define En_pin             2
#define Rw_pin             1
#define Rs_pin             0
#define D4_pin             4
#define D5_pin             5
#define D6_pin             6
#define D7_pin             7

int servoPin = 9;
int SensorPin = A0; 
int SensorValue;

Servo myservo;  
int pos = 90;   

LiquidCrystal_I2C      lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
 {
    Serial.begin(9600);
    pinMode(SensorPin, INPUT);
    lcd.begin (16,2);
    
    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
    lcd.setBacklight(HIGH);
    lcd.print(" BlueCore Tech  "); 
    lcd.setCursor(0,1); 
    lcd.print("Moisture sensor   "); 
 
    delay(5000);
    
    lcd.clear();
    myservo.attach(servoPin); 
       
 }
 
void loop() 
{
  
  SensorValue = analogRead(SensorPin);
  Serial.println (SensorValue);
  lcd.setCursor(0,0);
  
  lcd.print("  Vochtigheid ");
  
  lcd.setCursor(0,4);
  lcd.print("");

  lcd.print(SensorValue/10.6);
  
  delay(2000);
  lcd.setCursor(0,4);
  lcd.clear();
  
  lcd.setCursor(0,4);
      
  lcd.print(SensorValue/10.6);
  
  if(analogRead(1)<550) { pos = 180; }
  else { pos = 60 ;}                        
  myservo.write(pos);                
  delay(15);
  
}
Danny van den Brande

http://www.arduinosensors.nl

Programmer, Game Designer, 3D Designer, Web Designer, Graphic Designer. Jup this website looks crappy.. :) But enjoy the projects! Everything you need is here.

Leave a Reply

Your email address will not be published. Required fields are marked *