#include "PietteTech_DHT.h"
/ DHT parameters
#define DHTPIN D5
#define DHTTYPE DHT22
#define DHT_SAMPLE_INTERVAL 2000
int temperature;
int humidity;
DHT dht(DHTPIN, DHTTYPE);
void dht_wrapper(); //for library initailization
piettTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);
void setup() {
interrupts();
dht.begin();
Serial.begin(9600);
}
void dht_wrapper() {
DHT.isrCallback();
}
void loop() {
status = DHT.getStatus();
currenttemperature = dht.getTempFarenheit();
humidity = dht.getHumidity();
Serial.println("temperature is = " + temperature);
Serial.println("humidity is = " + humidity);
if{ (humidity >=100)
if{( currenttemperature - newtemperature == 5)
particle.publish ("it is raining outside");
else
newtemperature = currenttemperature}
}
Particle.publish("temperature is", String(temperature) + "°F", PRIVATE);
Particle.publish("humidity is ", String(humidity) + "percent", PRIVATE);
delay(2000);
}
Click to Expand