hello guys,
I have issue with DHT22.
I read a lot of topics here, but nothing really help me out.
Can you please check this code, and tell me where is my mistake ?
Thanks
#define WIFI_NAME "xxxx"
#define WIFI_PASSWORD "xxxxx"
#define DEVICE_ID 2
#define DEVICE_NAME "esp8266xxxxx"
#define TOKEN "xxxxxx
#define DHTTYPE DHT22
#include <RemoteMe.h>
#include <RemoteMeSocketConnector.h>
#include <ESP8266WiFi.h>
#include "DHT.h"
uint8_t DHTPin = D2;
DHT dht(DHTPin, DHTTYPE);
float Temperature;
float Humidity;
RemoteMe& remoteMe = RemoteMe::getInstance(TOKEN, DEVICE_ID);
//*************** CODE FOR COMFORTABLE VARIABLE SET *********************
inline void setTemp_alpalouka(int32_t i) {remoteMe.getVariables()->setInteger("temp_alpalouka", i); }
//*************** IMPLEMENT FUNCTIONS BELOW *********************
void onTemp_alpaloukaChange(int32_t i) {
}
void setup() {
pinMode(DHTPin, INPUT);
dht.begin();
WiFi.begin(WIFI_NAME, WIFI_PASSWORD);
Serial.println("Connecting to ");
Serial.println(WIFI_NAME);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
}
remoteMe.getVariables()->observeInteger("temp_alpalouka" ,onTemp_alpaloukaChange);
remoteMe.setConnector(new RemoteMeSocketConnector());
remoteMe.sendRegisterDeviceMessage(DEVICE_NAME);
}
void loop() {
remoteMe.loop();
static long time=millis();
if (time+1000<millis()){
time=millis();
setTemp_alpalouka(getTemperature());
Serial.println("Temperature");
}
}
int32_t getTemperature(){
Temperature = dht.readTemperature();
return Temperature;
}