KS0549 Keyestudio DIY Electronic Watering Kit

From Keyestudio Wiki
Jump to navigation Jump to search



Description

As for some plants lovers, they are keen on spending time in caring for their plants. Yet if they are busy in your work or entertainments, plants may wither by virtue of lacking water. To avoid this, we launched an automatic watering device with four humidity sensors and a water pump. It can water four plants pots. An equipped display screen can show the humidity value of soil.


Parameters

  • Working voltage: 5V
  • External power supply: DC 6-15V (recommended 9V)
  • DC output capability per I/O: 10 mA
  • 3.3V port output: 150 mA max
  • Size: 68*51*11mm3
  • Weight: 22.5g


Wiring Diagram

Project

Control relay modules and water pumps

4.1 Control relay modules and water pumps

Parameters:

  • Working voltage 2.5V~6V
  • The inner diameter of a water pipe is 6mm 
  • When voltage is 5V, the height of the water pipe from the pump cannot be higher than 105cm


Description

The relay is an electric switch, and the water pump is a power device. We can pump water by the relay switch.

Test Code

#define IN1 3
#define IN2 5
#define IN3 6
#define IN4 9

void setup() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

void loop() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, HIGH);
  delay(3000);
  digitalWrite(IN4, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN1, LOW);
  delay(1000);
}



Soil Humidity Sensor

The soil humidity sensor is used for detecting soil humidity value, which can determine if your plants are desperate for water.

Read values detected by soil sensors

Description

Read values of the 4 soil humidity sensors and print them out in serial monitor of Arduino IDE.


Test Code

#define soilPin1 A0
#define soilPin2 A1
#define soilPin3 A2
#define soilPin4 A3

void setup() {
  Serial.begin(9600);
  pinMode(soilPin1, INPUT);
  pinMode(soilPin2, INPUT);
  pinMode(soilPin3, INPUT);
  pinMode(soilPin4, INPUT);
}

void loop() {
  int val1 = analogRead(soilPin1);
  int val2 = analogRead(soilPin2);
  int val3 = analogRead(soilPin3);
  int val4 = analogRead(soilPin4);
  Serial.print("SoilSensor 1 =  ");
  Serial.print(val1);
  Serial.print("  ");
  Serial.print("SoilSensor 2 =  ");
  Serial.print(val2);
  Serial.print("  ");
  Serial.print("SoilSensor 3 =  ");
  Serial.print(val3);
  Serial.print("  ");
  Serial.print("SoilSensor 4 =  ");
  Serial.println(val4);
}

Test Result

Upload the test code and open the serial monitor of Arduino IDE, you can see that the values detected by the four soil humidity sensors are printed out. Touch the detection area of the sensor when your hands are wet, values on the monitor become smaller, which means that the more humid the soil, the smaller the measured value.

Automatic watering device

Description

We have learned how to control the water pump and read the value of the soil humidity sensor, you can control the relay by observing the value detected by the soil moisture sensor to realize a simple automatic flower watering device.

Test Code

#define soilPin1 A0
#define soilPin2 A1
#define soilPin3 A2
#define soilPin4 A3
#define IN1 3
#define IN2 5
#define IN3 6
#define IN4 9

void setup() {
  Serial.begin(9600);
  pinMode(soilPin1, INPUT);
  pinMode(soilPin2, INPUT);
  pinMode(soilPin3, INPUT);
  pinMode(soilPin4, INPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

void loop() {
  int val1 = analogRead(soilPin1);
  int val2 = analogRead(soilPin2);
  int val3 = analogRead(soilPin3);
  int val4 = analogRead(soilPin4);
  Serial.print("SoilSensor 1 =  ");
  Serial.print(val1);
  Serial.print("  ");
  Serial.print("SoilSensor 2 =  ");
  Serial.print(val2);
  Serial.print("  ");
  Serial.print("SoilSensor 3 =  ");
  Serial.print(val3);
  Serial.print("  ");
  Serial.print("SoilSensor 4 =  ");
  Serial.println(val4);
  if(val1 < 420){
    digitalWrite(IN1, HIGH);
  }else{
    digitalWrite(IN1, LOW);
  }
  if(val2 < 420){
    digitalWrite(IN2, HIGH);
  }else{
    digitalWrite(IN2, LOW);
  }
  if(val3 < 420){
    digitalWrite(IN3, HIGH);
  }else{
    digitalWrite(IN3, LOW);
  }
  if(val4 < 420){
    digitalWrite(IN4, HIGH);
  }else{
    digitalWrite(IN4, LOW);
  }
}

Test Result

Upload the test code, touch and hold the soil moisture sensor with your hand, the corresponding relay is turned on, and the water pump pumps water. After releasing the hand, the relay is turned off and the water pump stops pumping.

Control an LCD1602 display

You can view values detected by the soil sensor on the Arduino IDE serial monitor. We can add an LCD1602 display to show humidity values.

Display character strings and values

Description

The LCD1602 display is used for showing character strings.


Test Code

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(2,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print("keyestudio");
}


void loop()
{
}


Test Result:

You can view the display show Hello World! on the first line and keyestudio on the second line.

Display soil humidity values

Automatic watering device

Resources

https://fs.keyestudio.com/KS0549