Will VitolaJaden Preston
Published

MEGR 3171 Long Distance Wi-Fi Thermometer

Have you ever had the problem of wanting to know the exact temperature of wherever you are at that exact moment? Look no further!

BeginnerFull instructions provided103
MEGR 3171 Long Distance Wi-Fi Thermometer

Things used in this project

Hardware components

Argon
Particle Argon
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
ELEGOO 37-in-1 Sensor Module Kit V1.0
ELEGOO 37-in-1 Sensor Module Kit V1.0
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

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

Flow Chart

This is a flow chart that demonstrates how data is transferred between the cloud and devices.

Argon 1 Circuit in off Position

Argon 2 with Temperature Circuit

Both Argons and Their Circuits Working Next to Each Other

LED blue to signal that temperature is cool

LED red to signal that temperature is too hot

Argon 1 Circuit Diagram

Argon 2 Circuit Diagram

ThingSpeak Temperature VS Time Graph

Code

Argon 1 Code

C/C++
This is the code flashed to argon 1 that tells it to change the color of the LED based on the temperature reported by argon 2.
int temp_f = 0;


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

void setup()  
{ 
    //D2 Green Pin
    //D3 BLUE Pin 
    //D4 RED Pin
 pinMode(D2, OUTPUT);
 pinMode(D3, OUTPUT); 
 pinMode(D4, OUTPUT);
 pinMode(A0, INPUT_PULLUP);   
    
 //gets temp data from the cloud
 Particle.subscribe("temperature", temperatureHandler, MY_DEVICES);
 
 
} 

void loop()  
{ 
    if (digitalRead(A0) == HIGH) 
 { 
     //Light should be off when button is not pushed
   digitalWrite(D2, HIGH);
   digitalWrite(D3, LOW); 
   digitalWrite(D4, LOW);
 }
 
 else if (digitalRead(A0) == LOW) 
 { 
    
    if (temp_f >= 72)
   {
       //Red Light comes on to show hot temp
       digitalWrite(D2, LOW);
       digitalWrite(D3, LOW);
       digitalWrite(D4, HIGH); 
   }
   else if (temp_f < 72)
   {
       //Blue Light comes on to show cool temp
       digitalWrite(D2, LOW);
       digitalWrite(D3, HIGH);
       digitalWrite(D4, LOW);
   }
   
 } 
  
} 

Argon 2 Code (temp sensor)

C/C++
This code is flashed to Argon 2 allowing it to read the temperature sensor and post it to the cloud.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>


int analogvalue = 0;
int temp_f;
TCPClient client;

unsigned long myChannelNumber = 2108897;
const char * myWriteAPIKey = "H2ZDLWSDQMY46XGG";

void setup(){

  ThingSpeak.begin(client);
  
  Particle.variable("analogvalue", analogvalue);
  Particle.variable("temp_f", temp_f);
 
  pinMode(A0, INPUT);
  
}

void loop()
{
    delay(1500);
  // Read the value of the TMP36 sensor
  analogvalue = analogRead(A0);
  //Converts the reading from voltage to F
  temp_f = (analogvalue*-.08099688473520249+134); //To be accurate
  
  
  
  Particle.publish("temperature", String(temp_f));
  // sends data to cloud and graphs it
  ThingSpeak.setField(1,temp_f);
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  delay(20000);
  //delays data read to every 20 seconds

}

Credits

Will Vitola

Will Vitola

1 project • 1 follower
Jaden Preston

Jaden Preston

1 project • 1 follower

Comments