Things used in this project

Hardware components:
Photon new
Particle Photon
Comes with photon kit. Two to communicate between.
×2
Adafruit industries ada64 image 75px
Solderless Breadboard Half Size
Comes with Photon Kit. Two to communicate between.
×2
Adafruit industries ada161 image 75px
Photo resistor
Comes with Photon Kit.
×1
10167 01
DHT22 Temperature Sensor
Takes the temperature, humidity, and light measurements
×1
11026 02
Jumper wires (generic)
×1
Mfr 25frf52 10k sml
Resistor 10k ohm
×1
SparkFun Resistor 4.7k Ohm
×1
Adafruit industries ada260 image 90px
USB-A to Mini-USB Cable
Comes with Photon kit to power device. Keep in mind that there needs to be a power source connected to this, such as a wall outlet or a computer.
×2
Software apps and online services:
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service
Google sheets
Google Sheets

Schematics

Temperature Sensor Breadboard
This is the breadboard wiring for the temperature sensor. The temperature and humidity data is published into the cloud, which will then be picked up by the subscriber.
Screen shot 2017 04 12 at 7 45 27 pm c6cchqsctj
Photon Subscribe Breadboard
This is the photon particle that retrieve temperature data from the cloud and will either Toggle Digital Write HIGH if the temperature is greater than or equal to 20 degrees Celcius or Toggle a Digital Write LOW if the temperature is less than or equal to 19 degrees Celcius.
Screen shot 2017 04 12 at 7 40 57 pm firr17enex

Code

Temperature Sensor CircuitC/C++
This code is used for the breadboard with a temperature sensor on it. The temperature, humidity, and light data retrieved from the DHT 22 will show up on the particle console and these data are published into the cloud.
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_DHT/Adafruit_DHT.h"

// DHT parameters
#define DHTPIN 5
#define DHTTYPE DHT22

// Variables
int temperature;
int humidity;
int light;

// Pins
int light_sensor_pin = A0;

// DHT sensor
DHT dht(DHTPIN, DHTTYPE);

void setup() {
    
    // Start DHT sensor
    dht.begin();
}

void loop() {
    
    // Humidity measurement
    temperature = dht.getTempCelcius();
    
    // Humidity measurement
    humidity = dht.getHumidity();
    
    // Light level measurement
    float light_measurement = analogRead(light_sensor_pin);
    light = (int)(light_measurement/4096*100);
   
    // Publish data
    Particle.publish("temperature2807112", String(temperature), PRIVATE);
    digitalWrite(D7,HIGH);
    delay(2000);
    digitalWrite(D7,LOW);
    Particle.publish("humidity", String(humidity) + "%", PRIVATE);
    delay(2000);
    Particle.publish("light", String(light) + "%", PRIVATE);
    delay(2000);
   
    
  

    
}
Photon SubscribeC/C++
This is the code that is used for the photon subscribe breadboard, where the data is retrieved from the cloud and the D7 LED either turns on/off based on the temperature parameters of digital write toggle commands.
//Sets pin D4 as the power toggle pin
const int tog = D7;

//initializes temperature
int temperature;



void setup() {
    pinMode(tog, OUTPUT);
    //The relay is wired as normally closed and is non-latching so that if the photon loses power the light will remain on, setting the pin value to high defaults the light to the off position by opening the relay circuit.
    digitalWrite(tog, HIGH);

    //Subscribes the device to the  temperature data coming from the first photon and send it to the temperature handler function
    Particle.subscribe("temperature2807112", temperatureHandler, MY_DEVICES);
    //Compares the temperature value pulled from the cloud to the values set by the user to prevent the well from freezing
}
void loop() {
    if (temperature >= 20){
        //At a temperature greater than 20 deg C it opens the circuit and turns off the light
        digitalWrite(tog, HIGH);
    }
    else if (temperature <= 19){
        //At temperatures lower than 19 deg C it will close the circuit and turn on the light
        digitalWrite(tog, LOW);
    }
    else{
        //Reading any temperature in the "deadzone" between 15 and 20deg C restarts the loop
    }

}
//Takes the string data retrieved from the cloud and converts it to an integer value for comparison
void temperatureHandler(const char *event, const char *data){
    //sets a new string, which i have defined as "pew" to take in the temperature data
    String pew = data;
    //Converts this new string "pew" into the previously defined integer "temperature"
    temperature = pew.toInt();
}

Credits

Replications

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

Comments

Similar projects you might like

E-Paper Weather Display with Photon and IFTTT
Easy
  • 3,808
  • 18

Full instructions

Create a beautiful medium for weather information using Particle's cloud services and IFTTT.

2-Way Particle Photon Communication
Easy
  • 188
  • 4

Make two Particle Photons "talk" via the usage of webhooks!

Mask with Blinking Eye
Easy
  • 72
  • 3

Protip

Makes a great mask more eye-catching when one eye is blinking. Has an on-off switch, is powered by a cell , and driven by an ATtiny85.

IFTTT - Enabled Sensors with Particle Photon
Easy
  • 722
  • 12

Full instructions

Connect any sensor to Particle Photon and use it to trigger an IFTTT action with just a few lines of code.

WiFi Strength Meter
Easy
  • 410
  • 5

A meter that indicates the Wi-Fi signal strength in an intuitive way, using the parts I had on hand.

PHPoC - Detect Someone Taking Your Stuff
Easy
  • 619
  • 14

When your stuff is being taken away by a thief, PHPoC makes an alert and sends a notification to you via Gmail.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog