Automatic Irrigation System

Made by Ruipeng Liu

Found in DioT 2019: Augmented Objects



Watering plants have been a problem for my mom. The irrigation system is timed, which means the system will sprinkle water regardless of the soil's moisture level. The big problem with this is that a lot of water can be wasted, even when the soil might be wet already, and that watering can be lacking when the soils are dry. The system needs to be much smarter, while not complicated to employ. According to the client, my mom, the system is best if it can be automatic, because she can be away for a long period of time.



I found the solution to be quite intuitive and feasible, when I discovered that there are soil moisture sensors available in the studio. Since I don't have the irrigation system available around, I decided to use the motor to simulate the irrigation system. 

The solution, "Automatic Irrigation System", is set up as the above picture. When the moisture level is low (set up as "<1500"), the motor is off, and the led indication off. When the moisture level is high (">1500"), motor on with different turn frequencies based on the level, and the led on.

int val = 0;
int soilPin = A0;
int motor = D3;
int speed = 0;
int led1 = D2;

void setup() 
    pinMode(soilPin, INPUT);
    pinMode(motor, OUTPUT);
    pinMode(led1, OUTPUT);

void loop() 
    val = analogRead(soilPin);
    speed = map(val,0,4095,155,0);
    //int speed2 = (int)
    Particle.publish("Value", String(val));
    Particle.publish("Speed", String(speed));//send current moisture value
    if (val>1500) {
        digitalWrite(motor, LOW);
        digitalWrite(led1, LOW);
    } else {
        digitalWrite(motor, HIGH);
        digitalWrite(led1, HIGH);
    // }
Click to Expand


1. Picking the soil moisture sensor, soldering wires in place, I first tested out the soil moisture sensors' functionality by its own setting up the circuit. I looked at the log while testing the sensor soaking in water and checked the results. The readings were perfectly accurate.

2. Because I don't have an actual irrigating system to test out with, I temporarily simulate the system with a DC motor available at the studio. However, this is where I had some troubles with. The DC motors won't turn on with the sensor connecting. It turned out later that this is because the voltage the motor requires is higher and there needs to be a transistor in order for the system to function. I looked into the TIP120's datasheet online, and set up with Dylan's great help. He was also patient in explaining to me the mechanisms behind how it works.

3. The system finally functioned perfectly: I set a range of moisture levels for the motor to run within. Further, the motor's frequency will automatically adjust based on the moisture sensor's reading.

4. I added the led sensor and codes for indication to the users. The logic is simple: if the moisture level is high, the motor turn off, led off; if the moisture level low, the motor turns on, led on .
January 31, 2019
Rippen Liu -

Next Steps:


  • The system will be even smarter by incorporating more sensors to be a more comprehensive system. For instance, notifications to cellphones for the level of soil moisture, cellphone control that's similar to Apple's Homekit, etc.
  • Deeper incorporation with IFTTT. For instance, getting access to the weather channels' data, knowing exactly what time is going to rain, and preparing predicative mechanisms.
  • Multiple colors of LEDs indicating different states of operations.
  • There can be backup mechanisms. For instance, what if soil moisture sensor malfunctions? There should be a secondary sensor that prevents malfunctions from happening.



What really helped me is thinking backward and starting with problems, rather than seeing what sensors are available and figuring what to do with them. When you think of trying to solve the problem rather than connecting all the sensors to function, the solutions will actually be useful to the client. 

From my case, I believe that this little prototype can actually solve the problem elegantly, adding a few tweaks. I showed it to my mom via video, and she liked it a lot. The concern is that it should not be the only mechanism that completely replaces the previous one. There should be a double mechanism that acts as fail-safe in case there are malfunctions. She would also want to get information on her phone of the status of the system while away. This can be implemented with deeper incorporation with IFTTT.



Thanks Robert, Dylan and Taylor for the extensive patience guiding me finish the project. Thanks Daragh for the critical insights and Q&As.

Share this Project


49713 Designing for the Internet of Things

· 18 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.




January 31st, 2019