Monitor Temp & Humidity
Required Parts:
- Particle Photon
- DHT11 Sensorf link
- 3 Male/Female & 3 Male Wires
- OPTIONAL: PowerShield (Battery) link
Step 1: SETUP WIFI & RESET PHOTON
Step 2: Connect Temperature Sensor & Resistor to Photon
- Connect your sensor onto the Photon. Follow these examples for hooking up common sensors.
Sensor Pin | Photon Pin
pin1 | VIN (on the left) of the sensor to +5V (Red)
pin2 | D2 middle pin (Yellow)
pin3 | GROUND by the D7 pin side of Photon (Black)
Resistor
Connect a resistor from pin 2 (data) to pin 1 (power) of the sensor
Set up the hardware
Should look like this
Step 3: Setup BLYNK APP
- Download iOS or Android App and setup account on BLYNK (link)[https://blynk.io/en/getting-started]
- Log In to Blynk app and press QR button in Projects gallery & SCAN BELOW QR CDOE TO GET PROJECT
- Connect Blynk App to YOUR Photon: Tap on Octagon Icon and rename existing to your photon under devices
- Tap Refresh and then Email
- Check your Email and save the Auth Token for later use
Step 4: Create Particle App
- Go to https://build.particle.io/build/new
- Title: Monitor_Temperature_Humidity
- Add Library: Adafruit_DHT_Particle
- Add Library: blynk
- Paste Below Code
- On line 88 put your BLYNK auth code where it say s “BLYNKTOKENHERE” (keep quotes)
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_DHT_Particle.h"
#include "blynk.h"
//Temp / Humditity using DHT11 sensor
// Written by Chuck Konkol public domain
#define DHTPIN D2 // what pin we're connected to
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT11 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
DHT dht(DHTPIN, DHTTYPE);
//DANGER - DO NOT SHARE!!!!
char auth[] = "BLYNKTOKENHERE"; // Put your blynk token here
bool run;
void setup() {
Blynk.begin(auth);
Particle.publish("state", "DHT11 test start");
run = true;
dht.begin();
delay(2000);
}
void loop() {
run = true;
Blynk.run();
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a
// very slow sensor)
// Read Humidity
float h = dht.getHumidity();
// Read temperature as Celsius
float t = dht.getTempCelcius();
// Read temperature as Farenheit
float f = dht.getTempFarenheit();
// Read Farenheit as int to test later
int t1 = dht.getTempFarenheit();
// Read Humidity as int (not using)
int h1 = dht.getHumidity();
//Particle.publish("temps", String(t1));
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
run = false;
}
// Compute heat index
// Must send in temp in Fahrenheit!
if (run == true){
// Read HeatIndex
float hi = dht.getHeatIndex();
// Read DewPoint
float dp = dht.getDewPoint();
// Read TempKelvin
float k = dht.getTempKelvin();
//Publish all reading to log
Particle.publish("readings", String::format("{\"Hum(\%)\": %4.2f, \"Temp(°F)\": %4.2f, \"DP(°C)\": %4.2f, \"HI(°C)\": %4.2f}", h, f, dp, hi));
//Set int Fahrenheigt and Humidity to String
String sf(f, 0);
String sh(h, 0);
//virtual pin 1 will be the temperature (int)
Blynk.virtualWrite(V1, sf);
Particle.publish("Temp(F)", sf);
//virtual pin 2 will be the humidity (int)
Blynk.virtualWrite(V2, sh);
Particle.publish("Humidity", sh);
//pause 2 seconds
delay(2000);
}else{
run = true;
//if temp above 100 or below 30 then publish false reading (caused by noise)
//Particle.publish("errors", String(t1));
delay(2000);
}
delay(10000);
}
MonitorTemperature_Humidity
Get App Code: Click Here
- Click Save
- Click Verify
- Click Flash
That’s It! You should now see updates in Blynk App
- Tap the PLAY button in the blynk app