Aidan BrendleAngel Koshy
Published

MEGR 3171 - IoT Temperature Sensor Team 24

Utilizing Particle Argon microcontrollers to communicate wirelessly, the outside and inside temperatures can be compared from your home.

BeginnerFull instructions provided20 hours14
MEGR 3171 - IoT Temperature Sensor Team 24

Things used in this project

Hardware components

Temperature Sensor
Temperature Sensor
×2
Argon
Particle Argon
×3
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Jumper wires (generic)
Jumper wires (generic)
×20
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×3

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
https://io.adafruit.com

Story

Read more

Schematics

Temperature Sensor Sub-Circuit Wiring Diagram

The same wiring diagram was used for both indoor and outdoor temperature sensing circuits

LCD Sub-Circuit Wiring Diagram

Logic Flow Diagram

Code

Inside Temperature Sensor Code

C/C++
This code was used for the inside temperature system and collects and sends the temperature data to the LCD screen
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>

// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>



int analogvalue = 0;
int temp_fIN=0;
TCPClient client;

unsigned long myChannelNumber = 1574559;
const char * myWriteAPIKey = "VRFK6KC0JT3ZWCNG";

void setup(){

  ThingSpeak.begin(client);
  
  Particle.variable("analogvalue", analogvalue);
  Particle.variable("temp_fIN", temp_fIN);
 
Serial.begin(9600);

  pinMode(A5, INPUT);
  
}

void loop()
{
    delay(2000);
  // Read the analog value of the sensor (TMP36)
  analogvalue = analogRead(A5);
  //Convert the reading into degree 
  temp_fIN = ((analogvalue-500)/10-20.78); //To be accurate
  temp_fIN = (temp_fIN*(1.8))+32;
  
  
  Particle.publish("temperature inside",String (temp_fIN));// sends data to cloud
  ThingSpeak.setField(1,temp_fIN);
  Serial.print(temp_fIN);
  Serial.println("inside temperature");
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  delay(2000);
}

Outside Temperature Sensor Code

C/C++
This is the code for the outside sensor that sends temperature data to the LCD circuit. This also has the code for the critical temperature that makes sure that the system does not overheat.
#include <ThingSpeak.h>

int analogValue=0;
int temp;

int overheat;

TCPClient client;

unsigned long myChannelNumber = 2116122 ;
const char*myWriteAPIKey="1RTUKXDC58UEZA7L";

void setup() {
    ThingSpeak.begin(client);
    
    Particle.variable("analogValue", analogValue);
    Particle.variable("temp",temp);
    
    Particle.subscribe("overheat",overheatCheck,ALL_DEVICES);
    
    pinMode(A5, INPUT);
    
    Serial.begin(9600);
    
}

void loop() {
    while (overheat==1){
        temp = 999;
        Serial.print(temp);
        Serial.println("temp");
        delay(500000000000000000000000);
    }
    
    analogValue=analogRead(A5);
    temp = ((analogValue-500)/10-20.78); //To be accurate
    temp = (temp*(1.8))+32; 
    
    delay(2000);
    
    Particle.publish("temp", String (temp), ALL_DEVICES);
    ThingSpeak.setField(2,temp);
    Serial.print(temp);
    Serial.println("temp");
    
    ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);
    delay(2000);
}

void overheatCheck(const char*event, const char*data){
    String overheat=data;
    overheat=overheat.toInt();
}

LCD Screen Code

C/C++
This is the code for the LCD screen. It takes into account the two temperature system circuits, outdoor and indoor, then displays the data.
#include "application.h"

#include <LiquidCrystal.h>

int tempF=0;

int tempOUT;
int tempIN;
int overheat=0;


LiquidCrystal lcd(D0, D1, D2, D3, D4, D5);


void setup() {
    lcd.clear();
    lcd.begin(16,2);
   
    Particle.subscribe("temp", tempRead, ALL_DEVICES);
   
    Particle.subscribe("temperature inside", tempReadIN, ALL_DEVICES);
    
    Particle.variable("overheat", overheat);
}

void loop() {
    //Particle.publish("LCD",PUBLIC);
    
    while (tempOUT>75){
        lcd.clear();
        lcd.setCursor(0,0);
        lcd.print("Critical Temp");
        lcd.setCursor(0,1);
        lcd.print("Check Sensor");
        
        overheat=1;
        //Particle.publish("overheat", overheat, ALL_DEVICES);
        delay(50000000000000000000000000000000000000000000000000);
    }
    Particle.publish("overheat", String(overheat), ALL_DEVICES);
}

void tempRead(const char*event, const char*data){
    //lcd.clear();
    String temp=data;
    lcd.setCursor(0,0);
    lcd.print("Outside:");
    lcd.setCursor(10,0);
    lcd.print(temp);
    lcd.setCursor(14,0);
    lcd.print("F");
    
    tempOUT=temp.toInt();
}
void tempReadIN(const char*event, const char*dataIN){
    //lcd.clear();
    String tempIN=dataIN;
    lcd.setCursor(0,1);
    lcd.print("Inside:");
    lcd.setCursor(10,1);
    lcd.print(tempIN);
    lcd.setCursor(14,1);
    lcd.print("F");  
    
    tempIN=tempIN.toInt();
}

Credits

Aidan Brendle

Aidan Brendle

0 projects • 0 followers
Angel Koshy

Angel Koshy

0 projects • 0 followers

Comments

Add projectSign up / Login