Chance PellerinCaleb PatelTaylor Suber
Created November 20, 2019

DHT22 sensor with Particle Argon

How to use a DHT22 temperature sensor and a particle argon to record the temperature change within an area.

26
DHT22 sensor with Particle Argon

Things used in this project

Hardware components

Argon
Particle Argon
×3
Jumper wires (generic)
Jumper wires (generic)
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×2
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
×3

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

Particle Argon Receiving Data

Particle Argon sending data on the first floor

Particle Argon sending data on the third floor

Schematic of the DHT22 sensor connection to the Particle Argon

Live Data From First Floor

https://docs.google.com/spreadsheets/d/1aWzedESZE-dyJ3zA1rhNCHH235zD8hWbztz6xF75koY/edit#gid=0

Live Data From Third Floor

https://docs.google.com/spreadsheets/d/1UUAUNuhOw5i1ZKNHcW9BHIB_B3THNg6yF7tfGkXkos0/edit#gid=0

How the project works

Code

Particle Argon sending data on the first floor

C/C++
The code below is for the Particle Argon on the first floor of the apartment sending temperature data.
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

// what pin we're connected to
#define DHTPIN 2     

// DHT 22 (AM2302)
#define DHTTYPE DHT22		


DHT dht(DHTPIN, DHTTYPE);

void setup() {
	Serial.begin(9600); 
	Serial.println("DHTxx test!");

	dht.begin();
}

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


// Read temperature as Farenheit
	double f = dht.getTempFarenheit();
  

	//f is the temperature on the first floor
	//Defines f as variable in the cloud
	Particle.variable("f", f);
    
    //Publishes the temperature in Fahrenheit to the cloud        
    Particle.publish("f", String(f) , PRIVATE);
    
    
}

Particle Argon sending data on the third floor

C/C++
The code below is for the Particle Argon on the third floor of the apartment sending temperature data.
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

// what pin we're connected to
#define DHTPIN 2     

//What DHT Sensor we are wsing
#define DHTTYPE DHT22		


DHT dht(DHTPIN, DHTTYPE);

void setup() {
	Serial.begin(9600); 
	Serial.println("DHTxx test!");

	dht.begin();
}

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

// Read temperature as Fahrenheit
	double p = dht.getTempFarenheit();
  
    //p is the temperature on the third floor
	//Defines p as variable in the cloud
	Particle.variable("p", p);
    
    //Publishes the temperature in Fahrenheit to the cloud        
    Particle.publish("p", String(p) , PRIVATE);     
    
    
}

Particle Argon receiving the data

C/C++
The code below is for the Particle Argon receiving the data.
int p;
int f;

void setup() {
    // Subscribes the decive to other 2 argons that are reading temperature data and sends it to the temperature handler function
    Particle.subscribe("p", temperatureHandler, MY_DEVICES);
    Particle.subscribe("f", temperatureHandler, MY_DEVICES);
    
}

//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"
    p = pew.toInt();
    f = pew.toInt();
    //Publishes the device onto the events list where it reads the p and f temperature values from the other 2 argons
    Particle.publish("p",String (p), PRIVATE);
    Particle.publish("f",String (f), PRIVATE);
}

Credits

Chance Pellerin

Chance Pellerin

1 project • 0 followers
Caleb Patel

Caleb Patel

0 projects • 0 followers
Taylor Suber

Taylor Suber

0 projects • 0 followers

Comments