Data flood NodeMCU with DHT11


#1

Hello to you!

I tried my Hello World project which consist in a NodeMCU ESP8266 (ESP-12) and DHT11 sensor.
I manage to have connection and send the data to Cayenne.
I implemented the Deep sleep function by connecting the Pin D0 to RST. NodeMCU works fine, goes intro Deep Sleep and then came out.
The goal is to send the Temp and the relative humidity once at 1 minute (the code below send at 15 seconds for debugging purposes).
Therefore, the code is run once in the void setup().
In the serial console, all is OK but when checked into the Cayenne Data history, I see that the NodeMCU sensor send the data about 10 times in a second!

Here is the Serial output from NodeMCU:

So, this are my questions:
Why there are multiple entries if I send the data only once?
How to send the temp and the Hum only once?

Here is the code:

> /*
>  * Utilizeaza noile functii pentru trimiterea datelor pe canalele virtuale
>  * Foloseste deep sleep pentru a transmite mai putin de 60 de pachete pe minut
>  * http://community.mydevices.com/t/converting-cayenne-arduino-library-sketches-to-cayenne-mqtt-arduino/5759
>  */
> 
> 
> 
> 
> #define CAYENNE_DEBUG
> #define CAYENNE_PRINT Serial
> #include <CayenneMQTTESP8266.h>
> 
> #include "DHT.h"
> 
> 
> // WiFi network info.
> char ssid[] = ".....";
> char wifiPassword[] = ".....";
> 
> // DHT defs
> #define DHTPIN D1
> #define DHTTYPE DHT11   // DHT 22
> float h;
> float t;
> DHT dht(DHTPIN, DHTTYPE);    // Create object
> 
> // Deep Sleep parameters
> 
> #define SLEEP_DELAY_IN_SECONDS  15      // MAX TIME IS 36 MINUTES  a.k.a REPORT INTERVAL
> /* FOR DEEP SLEEP 
>  ON ADAFRUIT HUZZAH ESP8266 BREAKOUT BOARD, CONNECT RST TO PIN16!!!
>  ON NODEMCU CONNECT RST TO PIN D0
> */
> 
> // define virtual pins
> const int temp1 = 0;
> const int hum1 = 1;
> 
> // Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
> char username[] = "-----------";
> char password[] = "-----------";
> char clientID[] = "-------------";
> 
> 
>                 void setup() {
>                           Serial.begin(115200);
>                         Cayenne.begin(username, password, clientID, ssid, wifiPassword);
>                         dht.begin();
>                          // we run the code only once per out of sleep
>                         //  delay(1500);      // wait for good reading
>                              h = dht.readHumidity();
>                              t = dht.readTemperature();
>                             sendTemp1(temp1);
>                             sendHum1(hum1);
>                              
>                              Cayenne.loop();
>                           
>                                   Serial.println("Entering deep sleep...");
>                             //   delay(100);
>                                 ESP.deepSleep(SLEEP_DELAY_IN_SECONDS * 1000000, WAKE_RF_DEFAULT);
>                             //     delay(200);
>                         
>                          delay(500);
>                         }
> 
>               void sendTemp1(int temp1)
>                           {
>                             
>                             Cayenne.virtualWrite(temp1, t); //virtual pin
>                              Serial.println(t);
>                           }
>                           
>                void sendHum1(int hum1)
>                           {
>                             
>                             Cayenne.virtualWrite(hum1, h); //virtual pin
>                              Serial.println(t);
>                           }
>             
> 
>             void loop() {
>   
>                           }

Thanks
Adrian