Daniel NaveiraKyle McClelland
Published

MEGR 3171 Group 49 IOT Temperature Project

Taking live temperature readings with two particle argons.

BeginnerFull instructions provided3 hours560
MEGR 3171 Group 49 IOT Temperature Project

Things used in this project

Hardware components

Argon
Particle Argon
×2
Jumper wires (generic)
Jumper wires (generic)
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Schematics

Particle Argon Temperature receiver

This is a Fritzing downloadable file of our particle argon temperature reciever circuit diagram and schematic.

Particle Argon Temperature receiver

This is the screenshot of the particle argon temperature receiver diagram.

Particle Argon Temperature Sensor

This is a Fritzing downloadable file of our particle argon temperature sensor circuit diagram and schematic.

Particle Argon Temperature Sensor

This is the screenshot of the particle argon temperature sensor diagram.

Code

Particle Argon Temperature receiver

C/C++
//Sets pin D4 as the power toggle pin
const int tog = D7;

//initializes temperature
int temp_f;
int Light_Position;

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("Temperature15117712", temperatureHandler, ALL_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 (temp_f >= 65){
        //At a temperature greater than 65 deg F it opens the circuit and turns off the light
        digitalWrite(tog, LOW), Light_Position = 0;
    }
    else if (temp_f <= 60){
        //At temperatures lower than 60 deg F it will close the circuit and turn on the light
        digitalWrite(tog, HIGH), Light_Position = 1;
    }
    else{
        //Reading any temperature in the "deadzone" between 15 and 20deg C restarts the loop
    }
    Particle.publish("DANSargonLightON1998", String(Light_Position), PUBLIC);
    delay(4000);
}   

//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"
    temp_f = pew.toInt();
}

Particle Temperature Sensor

C/C++
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>
// 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
const int tog = D7;
// Variables
int temperature;
int temp_f;
int Light_Position;
//This is needed for the setup of ThingSpeak
TCPClient client;

//This states the channel of the ThingSpeak and the API Key that was given by the website
unsigned long myChannelNumber = 919459;
const char * myWriteAPIKey = "QRGOMJLGMI3R0YVY";

// DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
    // Start DHT sensor
    //Start of ThingSpeak
    //Selects the pin light that will be turned on in the Argon
    //The subscribe function that connects to the other argon to allow one to talk to the other
    ThingSpeak.begin(client);
    Serial.begin(9600);
    dht.begin();
    pinMode(tog, OUTPUT);
    digitalWrite(tog, LOW);
    Particle.subscribe("DANSargonLightON1998", LightPosition, ALL_DEVICES);
}
void loop (){  
    if (Light_Position <= 0){
        digitalWrite(tog, LOW);
    }
    else if (Light_Position >= 1){
        digitalWrite(tog, HIGH);
    }
    else{
        
    }
    temperature = dht.getTempCelcius();
    //Above shows the if loop statements that will allow the light on the argon to turn on and off if the temperture is too high or low
    temp_f = (1.8)*(temperature) + 32;
    //changes the base temp. from celcius to fahrenheit
    // Publish data
    Particle.publish("Temperature15117712", String(temp_f), PUBLIC);
   
   //Sets up and sends data into a graph form on ThingSpeak website
    ThingSpeak.setField(1,temp_f);
    Serial.println("temp_f");
    ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);
    //makes a 15 second delay on the data for thingspeak
    delay(15000);
}
//sets up the function that the Light Position will Subscribe too
void LightPosition(const char *events, const char *data){
    String pew = data;
    Light_Position = pew.toInt();
}  

Credits

Daniel Naveira

Daniel Naveira

1 project • 0 followers
Kyle McClelland

Kyle McClelland

1 project • 0 followers

Comments