Hello,
Im using nodemcu and dht11 tp semd humidity data to Cayyene.
Using arduino as IDE.
My sketch is here ::
#include "DHT.h" // including the library of DHT11 temperature and humidity sensor
#define DHTTYPE DHT11 // DHT 11
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#define dht_dpin 0 //D3
DHT dht(dht_dpin, DHTTYPE);
float h;
float t;
char ssid[] = "bla..bla";
char wifiPassword[] = "bla..bla";
char username[] = "bla..bla";
char password[] = "bla..bla";
char clientID[] = "bla..bla";
void setup(void)
{
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
dht.begin();
Serial.println("Humidity and temperature\n\n");
}
void loop() {
Serial.println("LOOP\n\n");
h = dht.readHumidity();
Serial.print("Current humidity = ");
Serial.print(h);
if (WiFi.status() == WL_CONNECTED) { Cayenne.loop(); }
}
CAYENNE_OUT_DEFAULT() //
{
float h1 = dht.readHumidity();
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(0, h1);
}
After successfully compile and upload im can see by serial log that wifi and cayyene are connected successfully but there are no data on Cayyene 's device.
any help appreciate.
Thanks