Kyle WinnJose Lopez
Published

MEGR 3171 Temperature Sensor Project

Using a temperature sensor and 2 Particle Argons to read temperature in the apartment

IntermediateFull instructions provided8 hours825
MEGR 3171 Temperature Sensor Project

Things used in this project

Hardware components

Argon
Particle Argon
×2
Jumper wires (generic)
Jumper wires (generic)
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1

Software apps and online services

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

Story

Read more

Schematics

Temperature Sensor

LCD Screen

Code

Temperature Sensor

C/C++
// 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 <ThingSpeak.h>



// This example assumes the sensor to be plugged into CONN2
#define DHTPIN 2     // what pin we're connected to

// Here we define the type of sensor used
#define DHTTYPE DHT11        // DHT 11 

DHT dht(DHTPIN, DHTTYPE);

bool humid = false;

TCPClient client;


unsigned long myChannelNumber = 919272;
const char * myWriteAPIKey = "X2KU2U3BSYN4214V";


void setup() {
    
    ThingSpeak.begin(client);
    
 pinMode(D2, OUTPUT);
 Serial.begin(9600); 
 dht.begin();


}

void loop() {
    // Wait a few seconds between measurements.
    delay(2000);

    // Sensor readings may also be up to 2 seconds 
    // Read temperature as Celsius
    float t = dht.getTempCelcius();
    // Read temperature as Farenheit
    float f = dht.getTempFarenheit();


    Particle.publish("Kyle_Jose_IOTf", String (f), ALL_DEVICES);
    
    ThingSpeak.setField(1,f);
    Serial.print(dht.getTempFarenheit());
    Serial.println("f");
    ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);  
    delay(60000); // ThingSpeak will only accept updates every 15 seconds. 

}

    void l(const char *event, const char *data) {
        
            digitalWrite(D2, HIGH);
            delay(2000);
            digitalWrite(D2, LOW);
            delay(1000);
       
    }

LCD-Screen

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

#include "application.h"



#include "LiquidCrystal/LiquidCrystal.h"

// Make sure to update these to match how you've wired your pins.
// pinout on LCD [RS, EN, D4, D5, D6, D7];
// pin nums LCD  [ 4,  6, 11, 12, 13, 14];
// Shield Shield [RS, EN, D4, D5, D6, D7];
// Spark Core    [D3, D5, D2, D4, D7, D8];
#define DHTPIN D2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(D0, D1, D2, D3, D4, D5);

void setup() {

  lcd.clear();
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Temperature In");
  Particle.subscribe("Kyle_Jose_IOTf", f, ALL_DEVICES);
  Serial.begin(19200);
  Serial.println("DHT22 test!");

  dht.begin();
}
void loop() {
    delay(2000);
    Particle.publish("Kyle_Jose_IOT",PUBLIC);
}

    void f(const char *event, const char *data) {
    lcd.setCursor(0,1);
    lcd.print("Apartment");
    lcd.setCursor(10,1);
    lcd.print(data);
    lcd.setCursor(14,1);
    lcd.print((char)223);
    lcd.print("F");
    }
   

Credits

Kyle Winn

Kyle Winn

1 project • 1 follower
Jose Lopez

Jose Lopez

0 projects • 1 follower

Comments