Software apps and online services

IFTTT Maker service

Hand tools and fabrication machines

Soldering iron (generic)

Story

Background Information

70% of the worlds water is used for irrigation. Much of this is wasted due to irrigation systems watering plants and crops when they don’t need it. This can occur in many ways, one being if your sprinklers are on a timer and water your yard after it rains. My project seeks to help solve this problem by using a Particle Photon and soil moisture sensor to only water your yard/plants when needed. The soil moisture sensor will tell the Photon if the soil is wet or dry. If the soil is dry the Photon will turn on your sprinkler system and send a text to your phone telling you that your sprinklers are being turned on.

My inspiration for this project came while I was on Spring break at the beach. It had been raining all day and finally cleared up so I decided to go on a bike ride. As I was riding I saw many houses that had their sprinklers on and I thought to myself this is a huge waste of water because it just rained, the plants already have enough. I continued thinking, maybe there is some way to water your yard only when its needed instead of at a scheduled time like normal sprinkler systems, and I created this project.

About

The soil moisture sensor tells the Photon if the ground is wet or dry. If the soil is dry the Photon turns on your sprinklers, an LED, and send a text to your phone via IFTTT. If the soil is wet then the LED and sprinklers and turned off.

Step 1: Hardware

Connections to Photon

Soil Moisture Sensor VCC - VIN or 3v3

Soil Moisture Sensor GND - GND

Soil Moisture Sensor SIG - A0

Sprinkler Valve Negative - GND

Sprinkler Valve Positive - D6

LED Anode with 330 ohm resistor - D5

LED Cathode - GND

The soil moisture sensor has two probes which are acting as a variable resistor. When there is more water in the soil, there is better conductivity and results in a lower resistance and a higher SIG output. With less water in the soil there is less conductivity and high resistance, so there is a lower SIG output. Click here for more information.

***Make sure you calibrate your sensor and put this value into the code here

For the sprinkler valve I used the Orbit Jar Top Sprinkler valve. This sprinkler valve runs on 24v so I have a power converter because the Photon releases 3.3v. This might be different for the sprinkler valve you use. Make sure you read how many volts your valve uses. For most sprinkler valves the wires are not polarity sensitive so it does not matter which on is positive or negative.

Step 2: Setting Up IFTTT

If you have used IFTTT before this will be simple, but for those of you who haven't here are instructions.

3. You will need to create a new applet (click your username in the top right corner and click New Applet)

4. Click "this" in the "if this then that" statement, and choose Particle as your service

5. Choose New Event Published as the trigger

6. In the If(Event Name) blank type exactly what is in between the quotation marks in the Particle.publish("event-name") line of code. In this case it would be: Soil moisture low, turning on sprinklers!

7. You can leave the Is(Event Contents) spot blank. Make sure the Device Name or ID matches your Particle Photon and then click Create Trigger

8. Click "that" to add an action service

9. Click SMS if you want to receive a text message. You could also choose email or something else if you wish.

10. Choose send SMS message so you receive a text message

11. Complete the action fields and click create acton

12. Click Finish to complete your applet

Step 3: The Code

The code is attached below. Make sure you add the wet soil value (specific to your sensor) and check to make sure the the text in between the quotation marks on the Particle.publish("_") line of code is the same as the event name on IFTTT.

Code

The Code

C/C++

Copy and paste this into Particle Build (Web IDE) and flash it to your device

/* To view full project vist https://www.hackster.io/abigail131/conserving-water-by-preventing-over-irrigation-9b0b34*/#define WetSoilValue 3200 //sets the wet soil value to 3200 this is different for each sensor make sure to find your value, more info at https://learn.sparkfun.com/tutorials/soil-moisture-sensor-hookup-guide?_ga=2.219475673.1522345871.1522631550-971193973.1489890773#define Sensor_PIN A0 //makes A0 the pin for the sensor#define Sprinkler_PIN 6 //makes D6 the pin for the sprinkler valve#define LED_PIN 5 //makes D5 the LED pin#define TEXTING_INTERVAL 1800000 // makes the texting interval 30 minutes (1000ms * 60s * 30mins)intWetSoilValueReached=false;//defines the variable WetSoilValueReached to false unsignedlongLastTextTime=0;//sets last text time to 0voidsetup(){pinMode(Sensor_PIN,INPUT);//makes the sensor pin an inputpinMode(Sprinkler_PIN,OUTPUT);//makes the sprinkler pin an outputpinMode(LED_PIN,OUTPUT);//makes the LED pin an output}voidloop(){if(analogRead(Sensor_PIN)<WetSoilValue){//If the moisture reading is low and reaches the wet soil value amount then:WetSoilValueReached=true;//wet soil value reached becomes truedigitalWrite(Sprinkler_PIN,HIGH);//turns Sprinkler pin to highdigitalWrite(LED_PIN,HIGH);//turns LED pin to highunsignedlongnow=millis();if(now-LastTextTime>=TEXTING_INTERVAL){//If a text has not been sent in the last 30 minutes then:Particle.publish("Soil moisture low, turning on sprinklers!");//publishes an event which send the text}}else{WetSoilValueReached=false;//If the moisture reading is higher than wet soil value amountdigitalWrite(Sprinkler_PIN,LOW);//turns the Sprinkler pin lowdigitalWrite(LED_PIN,LOW);//turns the LED pin low}}