Things used in this project

Hardware components:
Photon new
Particle Photon
13637 01
SparkFun Soil Moisture Sensor (with Screw Terminals)
12002 04
Breadboard (generic)
11026 02
Jumper wires (generic)
Depending on how long of a connection you need, the amount of wires used can vary
Software apps and online services:
ThingSpeak API
IFTTT Maker service


Circuit Diagram and Schematics
Bb jdygkc5us4


Soil Moisture Sensing PhotonC#
This code is for the Photon with the sensor.
int soilPin = A0;//read pin A0
int soilPower = 7;//gives power to D7 (has an LED on Photon - You can clearly see when it takes a value this way. Good for troubleshooting.)
int value = readSoil();//starts readSoil() function below
#define publish_delay 600000//publish every 10 minutes
unsigned int lastPublish = 0;//sets time since last publish to an initial value of 0
void setup() {
    pinMode(soilPower, OUTPUT);//sets D7 as an OUTPUT
    digitalWrite(soilPower, LOW);//turns D7 off
    //Spark.variable for particle
    //"Moisture" is the name you're looking out for when you're using IFTTT
    //&value is the variable you're using from your code to send using IFTTT
    Spark.variable("Moisture", &value, INT);//sets Spark.variable to Moisture, with the value from variable "value". For use with IFTTT applet
void loop() {
    unsigned long now = millis(); 
    if ((now - lastPublish) < publish_delay) {
    int value = readSoil();//Calls function from below
    //Publishes the event "thingSpeakWrite_A0" to the Particle Cloud
    Particle.publish("thingSpeakWrite_A0", "{ \"1\": \"" + String(value) + "\", \"k\": \"EX4AMP13-REPLACE-WITH-YOUR-WRITE-KEY\" }", 60, PRIVATE);//publishes to ThingSpeak
    lastPublish = now;//resets lastPublish variable to now (resets timer)
int readSoil()
    digitalWrite(soilPower, HIGH);//turn D7 "On"
    delay(50);//wait 50 milliseconds 
    int val = analogRead(soilPin);//Read the SIG value form sensor 
    delay(50);//wait 50 milliseconds 
    digitalWrite(soilPower, LOW);//turns D7 off
    return val;//send current moisture value
Receiving and Notifying PhotonC#
This code is for the Photon that receives the code and notifies the user.
int num = Particle.subscribe("thingSpeakWrite_A0", MoistureNotify, "YOUR-DEVICE-ID#");
void setup() {
    Particle.subscribe("thingSpeakWrite_A0", MoistureNotify, "YOUR-DEVICE-ID#");
    Spark.variable("MoistureLvl", &num, INT);
void loop() {
void MoistureNotify(const char *event, const char *data)
    int num = atoi(data);
    if (num<=100) {
    }else if (num>100 && num<200) {
    }else {


Megr2156 rm7id9ahgc
Jordan West
1 project • 0 followers
I'm a mechanical engineering major at UNC Charlotte.
13697143 1264060730294265 1047035151165227350 n
Daniel Head
1 project • 0 followers
I'm a junior mechanical engineering student at UNC Charlotte.
Thanks to Ingo Lohs.


Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback


Add projectSign up / Login