Automatic watering – Learning path project 13

Our Learning Path is an itinerary designed to teach all the foundaments and a little more about electronics, coding and robotics.

When you complete all the projects you will be able to develop almost any project you can imagine. In each chapter new concepts are introduced. You will learn by doing in a funny way.

Build this system to take care of your plants with the humidity sensor and not have to worry!

Project 13
AUTOMATIC WATERING FOR A PLANT

First ambient sensor project. Learn how to use ebotics soil moisture sensor and control watering

BEFORE TO START

DIFFICULTY LEVEL: Intermediate
DURATION OF THE ACTIVITY: 45 min.

MATERIALS:
4in1 board
Buzzer
Battery holder & wires
Battery holder & wires

1 - Build&Code 4in1 board
1 - Soil Moisture sensor
1 - Servomotor

Battery holder, USB cable and wires.

13 - Soil moisture sensor

The soil moisture sensor helps control the humidity level in the ground or in plant's soil. After the measurement is taken, the sensor will give a tension proportional to the humidity that it has detected. That way, it can be known if the soil is dry, humid, or over-watered, to then program an efficient watering system.

Soil moisture technical specifications:

Power: +3.3V / +5V DC
Output voltage signal: 0~4.2v
Current: 35 mA
Definition of the pins: S-Sigal V-VCC G-GND
Fast response and high sensitivity

As you has deduced, yes, it's an analog sensor! Most ambient sensors have a response proportional to the quantity of measured value.

13 - Soil moisture sensor circuit

As analog sensor, it should be connected to an analog input port. Rest of components as habitual.

Connect wires from 4in1 board to components:
- DIO9 to Servomotor module
- A0 to Humidity sensor

13.1 - Soil humidity reading program

Use the soil moisture sensor and the 4in1 Build&Code board to measure the humidity of the soil. That way, you will know when the plant has enough water and when it does not.

Block Coding
Arduino Coding
int PortSoil = A0, SoilSensor; // Analog port of the soil moisture sensor; dependent on the data reading on a scale from 0 to 1023.
float Moisture; // Value of the soil humidity on a scale from 0 to 100

void setup() {
  // put your setup code here, to run once:
  Serial.begin (9600); // Configuration for values readings
}

void loop() {
  // put your main code here, to run repeatedly:
  SoilSensor = analogRead (PortSoil); // Sensor amount readings on a scale from 0 to 1023
  Moisture = (SoilSensor / 10.23); // Saved and conversion from amounts to a scale from 0 to 100
  Serial.println(Moisture); // Show the value of the plant's humidity on a scale from 0 to 100 on the screen
}

We will read a value between 0 and 1023. We must find this number’s equivalent on a scale from 0 to 100, using the following formula:

Maximum value of the sensor / Maximum value on the new scale = Scaled value

1023 / 100 = 10.23

Then in program: Humidity sensor reading / 10.23 = Value on a scale from 0 to 100

13.2 - Automatic watering system

We used live mode in mBlock to see sensor response, but also possible to use upload mode to use it as an autonomus system.

Block Coding
Arduino Coding
#include <Servo.h>
int PortSoil = A0, SoilSensor; // Analog port of the soil moisture sensor; dependent on the data reading on a scale from 0 to 1023.
float Moisture; // Value of the plant humidity on a scale from 0 to 100
int LED = 4; // Digital port of the LED
int Degree ; // Dependent on the servomotor degrees
Servo motor1; // Declare the servomotor as motor1

void setup() {
  // Put your setup code here, to run once:
  Serial.begin (9600); // Configuration for amount readings
  motor1.attach (9); // Digital port pwm 9 where servomotor 1 is connected
  Degree = 15; // Servomotor at 15º
  motor1.write (Degree); //
}

void loop() {
  // Put your main code here, to run repeatedly:
  SoilSensor = analogRead (PortSoil); // Sensor amount readings on a scale from 0 to 1023
  Moisture = (SoilSensor / 10.23); // Saved and conversion from amounts to a scale from 0 to 100
  Serial.println(Moisture); // Show the amounts of the plant's humidity on a scale from 0 to 100 on the screen.
  if(Moisture < 50) // If the amount of Moisture is less than 50
  {
    digitalWrite (LED, HIGH); // LED = ON
    for(int x=0; x<25; x++) // Move the servomotor 25 times at intervals of 5 degrees every 0.1 seconds so that the cup pours water.
    {
      motor1.write(Degree); // Servomotor = degrees of Degree
      Degree = Degree+5; // Degree increased by 5 degrees
      delay(100); // Wait time of 0.1 seconds
    }
    delay (2000); // Wait time of 2 seconds
    Degree = 15; // Degree is equal to 15 degrees
  }
  else // If the reading of Moisture is greater than 50
  {
    motor1.write(15); // Servomotor at 15 degrees
    digitalWrite (LED, LOW); // LED = OFF
  }
}

To know when it is necessary to water your plant, you can read the values before watering the plant and then, being careful not to let water touch ditrectly the humidity sensor. Repeat a few days and you will find the values when watering is needed.

Final project - Automatic watering of a plant

Most automatic watering systems, control some valve, and show to user the state. You can use some leds, or even add humidity value with the segment display.

To start you can use same code than previous exercise, and add yourself leds or anything you think about!
You can build it using some wood sticks for structure, and a plastic cup as water feeder. You can get more inspirations viewing our watering plant activity

SHARE YOUR WATERING SYSTEM!!
FINISHED!
previous arrow
next arrow
Slider

The Mega Maker Kit fits perfectly with the Learning Path, you can build all projects with it, but if you have other kits, you can also follow the entire itinerary and finish some projects, or buy the missing components. You can check in our Learning Path page.

0 0

0