Things used in this project

Hardware components:
Photon new
Particle Photon
Comes with photon kit. Two to communicate between.
Adafruit industries ada64 image 75px
Solderless Breadboard Half Size
Comes with Photon Kit. Two to communicate between.
Adafruit industries ada161 image 75px
Photo resistor
Comes with Photon Kit.
10167 01
DHT22 Temperature Sensor
Takes the temperature, humidity, and light measurements
11026 02
Jumper wires (generic)
Mfr 25frf52 10k sml
Resistor 10k ohm
SparkFun Resistor 4.7k Ohm
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.
Software apps and online services:
IFTTT Maker service
Google sheets
Google Sheets


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


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

void setup() {
    // Start DHT sensor

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);
    Particle.publish("humidity", String(humidity) + "%", PRIVATE);
    Particle.publish("light", String(light) + "%", PRIVATE);

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);
        //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();


Melissa Thai
1 project • 2 followers
Fe Schultz
1 project • 2 followers


Add projectSign up / Login