Thingspeak connection problem program

Hello I am making a new code for a nodemcu8266 sensor, what I want to do is the following ...

1 read the DHT11 sensor data from the sensor connected to nodemcu8266 send them to thingspeak and write into the first two fields,

2 those fields are got from an extenral program processend and two new signals should be send to put on or off two leds red and blue according to level of temperature too high ...

3 the thingspeak should send the written data , 0 or 1 to nodemcu82666 and put on or off the leds accordingly.

Now the problem is that I am getting error when I connect and I dunno why...

this is the program I did:

#include "ThingSpeak.h"
#include <ESP8266WiFi.h>

#include <dht.h> // Include DHT Header file for DHT sensor.
#define dht_apin D2 // Analog Pin sensor is connected to pin D2.
 
dht DHT;// Including library for DHT sensor.

//Replace your wifi credentials here
//const char* ssid     = "******************";
//const char* password = "******************";

//change your channel number here
unsigned long channel = ******************;

//Weather Station using NodeMCU ESP8266 & Thingspeak IoT Analytics. 


String apiKey = "******************";     //  Enter your Write API key from ThingSpeak IoT Analytics Cloud platform.
String ReadapiKey = "******************";     //  Enter your read API key from ThingSpeak IoT Analytics Cloud platform.
//int LEDblu = 12 ;                  // Choose the pin for the LED (Pin D6, GPIO 12) 
//int LEDrosso = 15 ;                // Choose the pin for the LED (Pin D8, GPIO 15) 
unsigned int LEDblu_CH = 4; // dichiarazione channel field 4  
unsigned int LEDrosso_CH = 5; //dichiarazione channel field 5  
const char *ssid =  "******************";     // Replace with your Wi-Fi ssid.
const char *pass =  "******************"; // // Replace with your Wi-Fi wpa2 key.
const char *server = "api.thingspeak.com"; //Initializing Server.
WiFiClient client;
 
void setup() 
{
       // Program written in setup will run only once for connecting to Wi-Fi network.
       Serial.begin(115200); // Selecting the baud rate for Serial Communication.
       delay(500);
       // initialize digital pin LED_BUILTIN as an output.
       pinMode(LED_BUILTIN, OUTPUT);
       // initialize digital pin LEDblu,LEDrosso as an output.
       pinMode(D6, OUTPUT); // Led Blu
       pinMode(D8, OUTPUT); // Led Rosso
       digitalWrite(D6, 0);
       digitalWrite(D8, 0);
       Serial.println("Connecting to ");
       Serial.println(ssid);
 
       WiFi.begin(ssid, pass); // Wi-Fi network searching starts.
 
       while (WiFi.status() != WL_CONNECTED) 
           {
            delay(500);
            Serial.print(".");
           }
       Serial.println("");
       Serial.println("WiFi connected."); //Prints on serial monitor if Wi-Fi gets connected sucessfully.
}
 
void loop() 
{

  
  DHT.read11(dht_apin); // Reading DHT sensor pin D2's data.
   // prende i dati dai campi field di thingspeak creando delle var temporanee 
  int led_blu = ThingSpeak.readFloatField(channel, LEDblu_CH);
  int led_rosso = ThingSpeak.readFloatField(channel, LEDrosso_CH);
 
      float h = DHT.humidity; // Storing the humidity float value in variable h
      float t = DHT.temperature; // Storing the temperature float value in variable h
      
      if (isnan(h) || isnan(t)) 
         {
          Serial.println("Failed to read from DHT sensor!");
          return;
         }
                 
       if (client.connect(server,80))   // "184.106.153.149" or api.thingspeak.com
          {                  
           String postStr = apiKey;
           postStr +="&field1=";
           postStr += String(t);
           postStr +="&field2=";
           postStr += String(h);
          // postStr += "\r\n\r\n";
 
           client.print("POST /update HTTP/1.1\n");
           client.print("Host: api.thingspeak.com\n");
           client.print("Connection: close\n");
           client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
           client.print("Content-Type: application/x-www-form-urlencoded\n");
           client.print("Content-Length: ");
           client.print(postStr.length());
           client.print("\n\n");
           client.print(postStr);

           // Printing DHT Sensor's Humidity & Temperature on Serial Monitor.
           Serial.print("Temperature: "); 
           Serial.print(t);
           Serial.print(" C, Humidity: ");
           Serial.print(h);
           Serial.println("% ||| Data sent to Thingspeak IoT Analytics Cloud platform.");
                          if(led_blu == 1){
                            digitalWrite(D6, 1);
                            Serial.println("led blu is On..!");
                          } 
                          else if(led_blu == 0){
                            digitalWrite(D6, 0);
                            Serial.println("led blu is Off..!");
                          }
                        
                          if(led_rosso == 1){
                            digitalWrite(D8, 1);
                            Serial.println("led rosso is On..!");
                          }
                          else if(led_rosso == 0){
                            digitalWrite(D8, 0);
                            Serial.println("led rosso is Off..!");
                          }
                          
                          Serial.println(led_blu);
                          Serial.println(led_rosso);
          }
          client.stop();
          Serial.println("Waiting..."); // Waiting for new data to be sensed by DHT Sensor.
  
  // thingspeak needs minimum 15 sec delay between on Cloud console updates for free subscription.
  digitalWrite(LED_BUILTIN, HIGH); 
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
}

this is the error I am getting:

16:42:18.825 -> ............
16:42:24.575 -> WiFi connected.
16:42:24.575 -> 
16:42:24.575 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:42:24.575 -> 
16:42:24.575 -> Exception (28):
16:42:24.575 -> epc1=0x4020123f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
16:42:24.623 -> 
16:42:24.623 -> >>>stack>>>
16:42:24.623 -> 
16:42:24.623 -> ctx: cont
16:42:24.623 -> sp: 3ffffd20 end: 3fffffc0 offset: 0190
16:42:24.623 -> 3ffffeb0:  00000000 00000001 3fffff1c 3ffe85dc  
16:42:24.623 -> 3ffffec0:  3ffefa84 0000000e 3fffff10 40203917  
16:42:24.623 -> 3ffffed0:  001abfd9 0000000e 3fffff10 40203988  
16:42:24.623 -> 3ffffee0:  001abfd9 3ffefa84 3fffff10 40203a3c  
16:42:24.623 -> 3ffffef0:  3ffe8899 00000004 3ffee7a0 40203a65  
16:42:24.623 -> 3fffff00:  00000005 00000004 3ffee7a0 402013a3  
16:42:24.623 -> 3fffff10:  3ffefbec 000e000f 80000000 3ffefa84  
16:42:24.623 -> 3fffff20:  000e000f 89000034 3ffee788 40202a1a  
16:42:24.623 -> 3fffff30:  3ffe8860 00000100 0001c200 3ffee9ac  
16:42:24.623 -> 3fffff40:  3fffdad0 3ffee7a0 3ffee788 402015aa  
16:42:24.671 -> 3fffff50:  40202b7c 3ffe885e 3ffee920 40202b88  
16:42:24.671 -> 3fffff60:  40202b7c 3ffe885e 3ffee920 40202de8  
16:42:24.671 -> 3fffff70:  3ffe85d0 0000000f 3ffee920 40202ecc  
16:42:24.671 -> 3fffff80:  3ffef384 40201cb8 3ffee9ac 40202ef0  
16:42:24.671 -> 3fffff90:  3ffe85d0 3ffee8e4 3ffee920 3ffee9ac  
16:42:24.671 -> 3fffffa0:  3fffdad0 00000000 3ffee998 40203fc8  
16:42:24.671 -> 3fffffb0:  feefeffe feefeffe 3ffe85f0 40100c11  
16:42:24.671 -> <<<stack<<<
16:42:24.671 -> 
16:42:24.671 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:42:24.718 -> 
16:42:24.718 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
16:42:24.718 -> 
16:42:24.718 -> load 0x4010f000, len 3460, room 16 
16:42:24.718 -> tail 4
16:42:24.718 -> chksum 0xcc
16:42:24.718 -> load 0x3fff20b8, len 40, room 4 
16:42:24.718 -> tail 4
16:42:24.718 -> chksum 0xc9
16:42:24.718 -> csum 0xc9
16:42:24.718 -> v00045740
16:42:24.718 -> ~ld
16:42:25.287 -> Connecting to 
16:42:25.287 -> ***********
16:42:25.762 -> .....

and keeps going repeating this .. .what can be the issue?

thanks for any help!

Throw in some more serial prints to tell you how far it got in loop.

what do you mean? They are all the same ...

It looks like setup was executed correctly. So the failure is in your loop function, but so far you don't know where. Some serial print statements can help you narrow down where it crashes.

like this :

16:51:13.104 -> ....
16:51:14.577 -> WiFi connected.
16:51:14.625 -> 
16:51:14.625 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:14.625 -> 
16:51:14.625 -> Exception (28):
16:51:14.625 -> epc1=0x4020123f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
16:51:14.625 -> 
16:51:14.625 -> >>>stack>>>
16:51:14.625 -> 
16:51:14.625 -> ctx: cont
16:51:14.625 -> sp: 3ffffd20 end: 3fffffc0 offset: 0190
16:51:14.625 -> 3ffffeb0:  00000000 00000001 3fffff1c 3ffe85dc  
16:51:14.625 -> 3ffffec0:  3ffefac4 0000000e 3fffff10 4020392b  
16:51:14.625 -> 3ffffed0:  001abfd9 0000000e 3fffff10 4020399c  
16:51:14.625 -> 3ffffee0:  001abfd9 3ffefac4 3fffff10 40203a50  
16:51:14.625 -> 3ffffef0:  3ffe8899 00000004 3ffee7b8 40203a79  
16:51:14.672 -> 3fffff00:  00000005 00000004 3ffee7b8 402013a3  
16:51:14.672 -> 3fffff10:  3ffefc2c 000e000f 80000000 3ffefac4  
16:51:14.672 -> 3fffff20:  000e000f 89000034 3ffee7a0 40202a2e  
16:51:14.672 -> 3fffff30:  3ffe8860 00000100 0001c200 3ffee9c4  
16:51:14.672 -> 3fffff40:  3fffdad0 3ffee7b8 3ffee7a0 402015ba  
16:51:14.672 -> 3fffff50:  40202b90 3ffe885e 3ffee938 40202b9c  
16:51:14.672 -> 3fffff60:  40202b90 3ffe885e 3ffee938 40202dfc  
16:51:14.672 -> 3fffff70:  3ffe85d0 0000000f 3ffee938 40202ee0  
16:51:14.672 -> 3fffff80:  3ffef39c 40201ccc 3ffee9c4 40202f04  
16:51:14.672 -> 3fffff90:  3ffe85d0 3ffee8fc 3ffee938 3ffee9c4  
16:51:14.720 -> 3fffffa0:  3fffdad0 00000000 3ffee9b0 40203fdc  
16:51:14.720 -> 3fffffb0:  feefeffe feefeffe 3ffe85f0 40100c11  
16:51:14.720 -> <<<stack<<<
16:51:14.720 -> 
16:51:14.720 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:14.720 -> 
16:51:14.720 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
16:51:14.720 -> 
16:51:14.720 -> load 0x4010f000, len 3460, room 16 
16:51:14.720 -> tail 4
16:51:14.720 -> chksum 0xcc
16:51:14.720 -> load 0x3fff20b8, len 40, room 4 
16:51:14.720 -> tail 4
16:51:14.720 -> chksum 0xc9
16:51:14.720 -> csum 0xc9
16:51:14.720 -> v00045760
16:51:14.720 -> ~ld
16:51:15.289 -> Connecting to 
16:51:15.289 -> ***********
16:51:15.812 -> ...........
16:51:21.513 -> WiFi connected.
16:51:21.561 -> 
16:51:21.561 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:21.561 -> 
16:51:21.561 -> Exception (28):
16:51:21.561 -> epc1=0x4020123f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
16:51:21.561 -> 
16:51:21.561 -> >>>stack>>>
16:51:21.561 -> 
16:51:21.561 -> ctx: cont
16:51:21.561 -> sp: 3ffffd20 end: 3fffffc0 offset: 0190
16:51:21.561 -> 3ffffeb0:  00000000 00000001 3fffff1c 3ffe85dc  
16:51:21.561 -> 3ffffec0:  3ffefac4 0000000e 3fffff10 4020392b  
16:51:21.607 -> 3ffffed0:  001abfd9 0000000e 3fffff10 4020399c  
16:51:21.607 -> 3ffffee0:  001abfd9 3ffefac4 3fffff10 40203a50  
16:51:21.607 -> 3ffffef0:  3ffe8899 00000004 3ffee7b8 40203a79  
16:51:21.607 -> 3fffff00:  00000005 00000004 3ffee7b8 402013a3  
16:51:21.607 -> 3fffff10:  3ffefc2c 000e000f 80000000 3ffefac4  
16:51:21.607 -> 3fffff20:  000e000f 89000034 3ffee7a0 40202a2e  
16:51:21.607 -> 3fffff30:  3ffe8860 00000100 0001c200 3ffee9c4  
16:51:21.607 -> 3fffff40:  3fffdad0 3ffee7b8 3ffee7a0 402015ba  
16:51:21.607 -> 3fffff50:  40202b90 3ffe885e 3ffee938 40202b9c  
16:51:21.607 -> 3fffff60:  40202b90 3ffe885e 3ffee938 40202dfc  
16:51:21.655 -> 3fffff70:  3ffe85d0 0000000f 3ffee938 40202ee0  
16:51:21.655 -> 3fffff80:  3ffef39c 40201ccc 3ffee9c4 40202f04  
16:51:21.655 -> 3fffff90:  3ffe85d0 3ffee8fc 3ffee938 3ffee9c4  
16:51:21.655 -> 3fffffa0:  3fffdad0 00000000 3ffee9b0 40203fdc  
16:51:21.655 -> 3fffffb0:  feefeffe feefeffe 3ffe85f0 40100c11  
16:51:21.655 -> <<<stack<<<
16:51:21.655 -> 
16:51:21.655 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:21.655 -> 
16:51:21.655 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
16:51:21.655 -> 
16:51:21.655 -> load 0x4010f000, len 3460, room 16 
16:51:21.703 -> tail 4
16:51:21.703 -> chksum 0xcc
16:51:21.703 -> load 0x3fff20b8, len 40, room 4 
16:51:21.703 -> tail 4
16:51:21.703 -> chksum 0xc9
16:51:21.703 -> csum 0xc9
16:51:21.703 -> v00045760
16:51:21.703 -> ~ld
16:51:22.272 -> Connecting to 
16:51:22.272 -> ***********
16:51:22.749 -> ............
16:51:28.985 -> WiFi connected.
16:51:28.985 -> 
16:51:28.985 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:29.033 -> 
16:51:29.033 -> Exception (28):
16:51:29.033 -> epc1=0x4020123f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
16:51:29.033 -> 
16:51:29.033 -> >>>stack>>>
16:51:29.033 -> 
16:51:29.033 -> ctx: cont
16:51:29.033 -> sp: 3ffffd20 end: 3fffffc0 offset: 0190
16:51:29.033 -> 3ffffeb0:  00000000 00000001 3fffff1c 3ffe85dc  
16:51:29.033 -> 3ffffec0:  3ffefaac 0000000e 3fffff10 4020392b  
16:51:29.033 -> 3ffffed0:  001abfd9 0000000e 3fffff10 4020399c  
16:51:29.033 -> 3ffffee0:  001abfd9 3ffefaac 3fffff10 40203a50  
16:51:29.033 -> 3ffffef0:  3ffe8899 00000004 3ffee7b8 40203a79  
16:51:29.033 -> 3fffff00:  00000005 00000004 3ffee7b8 402013a3  
16:51:29.080 -> 3fffff10:  3ffefac4 000e000f 80000000 3ffefaac  
16:51:29.080 -> 3fffff20:  000e000f 89000034 3ffee7a0 40202a2e  
16:51:29.080 -> 3fffff30:  3ffe8860 00000100 0001c200 3ffee9c4  
16:51:29.080 -> 3fffff40:  3fffdad0 3ffee7b8 3ffee7a0 402015ba  
16:51:29.080 -> 3fffff50:  40202b90 3ffe885e 3ffee938 40202b9c  
16:51:29.080 -> 3fffff60:  40202b90 3ffe885e 3ffee938 40202dfc  
16:51:29.080 -> 3fffff70:  3ffe85d0 0000000f 3ffee938 40202ee0  
16:51:29.080 -> 3fffff80:  3ffef39c 40201ccc 3ffee9c4 40202f04  
16:51:29.080 -> 3fffff90:  3ffe85d0 3ffee8fc 3ffee938 3ffee9c4  
16:51:29.080 -> 3fffffa0:  3fffdad0 00000000 3ffee9b0 40203fdc  
16:51:29.080 -> 3fffffb0:  feefeffe feefeffe 3ffe85f0 40100c11  
16:51:29.128 -> <<<stack<<<
16:51:29.128 -> 
16:51:29.128 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:29.128 -> 
16:51:29.128 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
16:51:29.128 -> 
16:51:29.128 -> load 0x4010f000, len 3460, room 16 
16:51:29.128 -> tail 4
16:51:29.128 -> chksum 0xcc
16:51:29.128 -> load 0x3fff20b8, len 40, room 4 
16:51:29.128 -> tail 4
16:51:29.128 -> chksum 0xc9
16:51:29.128 -> csum 0xc9
16:51:29.128 -> v00045760
16:51:29.128 -> ~ld
16:51:29.701 -> Connecting to 
16:51:29.701 -> ***********
16:51:30.224 -> ............
16:51:36.448 -> WiFi connected.
16:51:36.448 -> 
16:51:36.448 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:36.448 -> 
16:51:36.448 -> Exception (28):
16:51:36.448 -> epc1=0x4020123f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
16:51:36.495 -> 
16:51:36.495 -> >>>stack>>>
16:51:36.495 -> 
16:51:36.495 -> ctx: cont
16:51:36.495 -> sp: 3ffffd20 end: 3fffffc0 offset: 0190
16:51:36.495 -> 3ffffeb0:  00000000 00000001 3fffff1c 3ffe85dc  
16:51:36.495 -> 3ffffec0:  3ffefac4 0000000e 3fffff10 4020392b  
16:51:36.495 -> 3ffffed0:  001abfd9 0000000e 3fffff10 4020399c  
16:51:36.495 -> 3ffffee0:  001abfd9 3ffefac4 3fffff10 40203a50  
16:51:36.495 -> 3ffffef0:  3ffe8899 00000004 3ffee7b8 40203a79  
16:51:36.495 -> 3fffff00:  00000005 00000004 3ffee7b8 402013a3  
16:51:36.495 -> 3fffff10:  3ffefc2c 000e000f 80000000 3ffefac4  
16:51:36.495 -> 3fffff20:  000e000f 89000034 3ffee7a0 40202a2e  
16:51:36.495 -> 3fffff30:  3ffe8860 00000100 0001c200 3ffee9c4  
16:51:36.543 -> 3fffff40:  3fffdad0 3ffee7b8 3ffee7a0 402015ba  
16:51:36.543 -> 3fffff50:  40202b90 3ffe885e 3ffee938 40202b9c  
16:51:36.543 -> 3fffff60:  40202b90 3ffe885e 3ffee938 40202dfc  
16:51:36.543 -> 3fffff70:  3ffe85d0 0000000f 3ffee938 40202ee0  
16:51:36.543 -> 3fffff80:  3ffef39c 40201ccc 3ffee9c4 40202f04  
16:51:36.543 -> 3fffff90:  3ffe85d0 3ffee8fc 3ffee938 3ffee9c4  
16:51:36.543 -> 3fffffa0:  3fffdad0 00000000 3ffee9b0 40203fdc  
16:51:36.543 -> 3fffffb0:  feefeffe feefeffe 3ffe85f0 40100c11  
16:51:36.543 -> <<<stack<<<
16:51:36.543 -> 
16:51:36.543 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:36.591 -> 
16:51:36.591 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
16:51:36.591 -> 
16:51:36.591 -> load 0x4010f000, len 3460, room 16 
16:51:36.591 -> tail 4
16:51:36.591 -> chksum 0xcc
16:51:36.591 -> load 0x3fff20b8, len 40, room 4 
16:51:36.591 -> tail 4
16:51:36.591 -> chksum 0xc9
16:51:36.591 -> csum 0xc9
16:51:36.591 -> v00045760
16:51:36.591 -> ~ld
16:51:37.163 -> Connecting to 
16:51:37.163 -> ***********
16:51:37.641 -> ...........
16:51:43.360 -> WiFi connected.
16:51:43.408 -> 
16:51:43.408 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:43.408 -> 
16:51:43.408 -> Exception (28):
16:51:43.408 -> epc1=0x4020123f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
16:51:43.408 -> 
16:51:43.408 -> >>>stack>>>
16:51:43.408 -> 
16:51:43.408 -> ctx: cont
16:51:43.408 -> sp: 3ffffd20 end: 3fffffc0 offset: 0190
16:51:43.408 -> 3ffffeb0:  00000000 00000001 3fffff1c 3ffe85dc  
16:51:43.408 -> 3ffffec0:  3ffefac4 0000000e 3fffff10 4020392b  
16:51:43.455 -> 3ffffed0:  001abfd9 0000000e 3fffff10 4020399c  
16:51:43.455 -> 3ffffee0:  001abfd9 3ffefac4 3fffff10 40203a50  
16:51:43.455 -> 3ffffef0:  3ffe8899 00000004 3ffee7b8 40203a79  
16:51:43.455 -> 3fffff00:  00000005 00000004 3ffee7b8 402013a3  
16:51:43.455 -> 3fffff10:  3ffefc2c 000e000f 80000000 3ffefac4  
16:51:43.455 -> 3fffff20:  000e000f 89000034 3ffee7a0 40202a2e  
16:51:43.455 -> 3fffff30:  3ffe8860 00000100 0001c200 3ffee9c4  
16:51:43.455 -> 3fffff40:  3fffdad0 3ffee7b8 3ffee7a0 402015ba  
16:51:43.455 -> 3fffff50:  40202b90 3ffe885e 3ffee938 40202b9c  
16:51:43.503 -> 3fffff60:  40202b90 3ffe885e 3ffee938 40202dfc  
16:51:43.503 -> 3fffff70:  3ffe85d0 0000000f 3ffee938 40202ee0  
16:51:43.503 -> 3fffff80:  3ffef39c 40201ccc 3ffee9c4 40202f04  
16:51:43.503 -> 3fffff90:  3ffe85d0 3ffee8fc 3ffee938 3ffee9c4  
16:51:43.503 -> 3fffffa0:  3fffdad0 00000000 3ffee9b0 40203fdc  
16:51:43.503 -> 3fffffb0:  feefeffe feefeffe 3ffe85f0 40100c11  
16:51:43.503 -> <<<stack<<<
16:51:43.503 -> 
16:51:43.503 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:43.503 -> 
16:51:43.503 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
16:51:43.503 -> 
16:51:43.503 -> load 0x4010f000, len 3460, room 16 
16:51:43.551 -> tail 4
16:51:43.551 -> chksum 0xcc
16:51:43.551 -> load 0x3fff20b8, len 40, room 4 
16:51:43.551 -> tail 4
16:51:43.551 -> chksum 0xc9
16:51:43.551 -> csum 0xc9
16:51:43.551 -> v00045760
16:51:43.551 -> ~ld
16:51:44.119 -> Connecting to 
16:51:44.119 -> ***********
16:51:44.592 -> ............
16:51:50.828 -> WiFi connected.
16:51:50.876 -> 
16:51:50.876 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:50.876 -> 
16:51:50.876 -> Exception (28):
16:51:50.876 -> epc1=0x4020123f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
16:51:50.876 -> 
16:51:50.876 -> >>>stack>>>
16:51:50.876 -> 
16:51:50.876 -> ctx: cont
16:51:50.876 -> sp: 3ffffd20 end: 3fffffc0 offset: 0190
16:51:50.876 -> 3ffffeb0:  00000000 00000001 3fffff1c 3ffe85dc  
16:51:50.876 -> 3ffffec0:  3ffefac4 0000000e 3fffff10 4020392b  
16:51:50.876 -> 3ffffed0:  001abfd9 0000000e 3fffff10 4020399c  
16:51:50.876 -> 3ffffee0:  001abfd9 3ffefac4 3fffff10 40203a50  
16:51:50.876 -> 3ffffef0:  3ffe8899 00000004 3ffee7b8 40203a79  
16:51:50.923 -> 3fffff00:  00000005 00000004 3ffee7b8 402013a3  
16:51:50.923 -> 3fffff10:  3ffefc2c 000e000f 80000000 3ffefac4  
16:51:50.923 -> 3fffff20:  000e000f 89000034 3ffee7a0 40202a2e  
16:51:50.923 -> 3fffff30:  3ffe8860 00000100 0001c200 3ffee9c4  
16:51:50.923 -> 3fffff40:  3fffdad0 3ffee7b8 3ffee7a0 402015ba  
16:51:50.923 -> 3fffff50:  40202b90 3ffe885e 3ffee938 40202b9c  
16:51:50.923 -> 3fffff60:  40202b90 3ffe885e 3ffee938 40202dfc  
16:51:50.923 -> 3fffff70:  3ffe85d0 0000000f 3ffee938 40202ee0  
16:51:50.923 -> 3fffff80:  3ffef39c 40201ccc 3ffee9c4 40202f04  
16:51:50.923 -> 3fffff90:  3ffe85d0 3ffee8fc 3ffee938 3ffee9c4  
16:51:50.923 -> 3fffffa0:  3fffdad0 00000000 3ffee9b0 40203fdc  
16:51:50.970 -> 3fffffb0:  feefeffe feefeffe 3ffe85f0 40100c11  
16:51:50.970 -> <<<stack<<<
16:51:50.970 -> 
16:51:50.970 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:50.970 -> 
16:51:50.970 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
16:51:50.970 -> 
16:51:50.970 -> load 0x4010f000, len 3460, room 16 
16:51:50.970 -> tail 4
16:51:50.970 -> chksum 0xcc
16:51:50.970 -> load 0x3fff20b8, len 40, room 4 
16:51:50.970 -> tail 4
16:51:50.970 -> chksum 0xc9
16:51:50.970 -> csum 0xc9
16:51:50.970 -> v00045760
16:51:50.970 -> ~ld
16:51:51.540 -> Connecting to 
16:51:51.540 -> ***********
16:51:52.067 -> ............
16:51:58.301 -> WiFi connected.
16:51:58.301 -> 
16:51:58.301 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:58.301 -> 
16:51:58.301 -> Exception (28):
16:51:58.301 -> epc1=0x4020123f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
16:51:58.301 -> 
16:51:58.301 -> >>>stack>>>
16:51:58.301 -> 
16:51:58.301 -> ctx: cont
16:51:58.301 -> sp: 3ffffd20 end: 3fffffc0 offset: 0190
16:51:58.349 -> 3ffffeb0:  00000000 00000001 3fffff1c 3ffe85dc  
16:51:58.349 -> 3ffffec0:  3ffefac4 0000000e 3fffff10 4020392b  
16:51:58.349 -> 3ffffed0:  001abfd9 0000000e 3fffff10 4020399c  
16:51:58.349 -> 3ffffee0:  001abfd9 3ffefac4 3fffff10 40203a50  
16:51:58.349 -> 3ffffef0:  3ffe8899 00000004 3ffee7b8 40203a79  
16:51:58.349 -> 3fffff00:  00000005 00000004 3ffee7b8 402013a3  
16:51:58.349 -> 3fffff10:  3ffefc2c 000e000f 80000000 3ffefac4  
16:51:58.349 -> 3fffff20:  000e000f 89000034 3ffee7a0 40202a2e  
16:51:58.349 -> 3fffff30:  3ffe8860 00000100 0001c200 3ffee9c4  
16:51:58.349 -> 3fffff40:  3fffdad0 3ffee7b8 3ffee7a0 402015ba  
16:51:58.349 -> 3fffff50:  40202b90 3ffe885e 3ffee938 40202b9c  
16:51:58.397 -> 3fffff60:  40202b90 3ffe885e 3ffee938 40202dfc  
16:51:58.397 -> 3fffff70:  3ffe85d0 0000000f 3ffee938 40202ee0  
16:51:58.397 -> 3fffff80:  3ffef39c 40201ccc 3ffee9c4 40202f04  
16:51:58.397 -> 3fffff90:  3ffe85d0 3ffee8fc 3ffee938 3ffee9c4  
16:51:58.397 -> 3fffffa0:  3fffdad0 00000000 3ffee9b0 40203fdc  
16:51:58.397 -> 3fffffb0:  feefeffe feefeffe 3ffe85f0 40100c11  
16:51:58.397 -> <<<stack<<<
16:51:58.397 -> 
16:51:58.397 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
16:51:58.444 -> 
16:51:58.444 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
16:51:58.444 -> 
16:51:58.444 -> load 0x4010f000, len 3460, room 16 
16:51:58.444 -> tail 4
16:51:58.444 -> chksum 0xcc
16:51:58.444 -> load 0x3fff20b8, len 40, room 4 
16:51:58.444 -> tail 4
16:51:58.444 -> chksum 0xc9
16:51:58.444 -> csum 0xc9
16:51:58.444 -> v00045760
16:51:58.444 -> ~ld
16:51:59.012 -> Connecting to 
16:51:59.012 -> ***********
16:51:59.491 -> .....

NO.
To narrow down you have to add serial-output
with commands
Serial.print();

If this hint is above your head the whole project is wayyyy above your head and you should learn the basics

The serial output just shows that your microcontroller keeps on resetting over and over again.

install the exception decoder plugin for the arduino-IDE to analyse what causes the exception
or follow this example code

best regards Stefan

I have added several serialprint(*) to check what is doing but it goes in loop trying to connect so there must be an error somewhere I am not finding, I already made this program work fine but the problem started when I added two pins to illuminate two leds on reading values from thingspeak , as long as I used a simplier program to write sensor data to thingspeak work ...

Basically I am trying to do a read and write actualization on the same nodemcu , I could solve I guess by using another nodemcu with leds and pass the values throght the external program , but i have limited nodemcus and I would like to use it for other tasks then ligthning up leds.

Any idea of what can cause the loop in the connection phase?

Ok I started to exclude all lines I added to the working program and I managed ro reach the offending lines, the problems start when I activate those two lines of code in the position where they are in the previous one ... I thought I could declare those variables there to store the read data, but I can't ??

 int led_blu = ThingSpeak.readFloatField(channel, LEDblu_CH);
 int led_rosso = ThingSpeak.readFloatField(channel, LEDrosso_CH);

readFloatField() returns this:

Value read, or 0 if the field is text or there is an error. Use getLastReadStatus() to get more specific information. Note that NAN, INFINITY, and -INFINITY are valid results.

It is probably best to read the value into a float, test it, and only if it is convertible to an int use it.
Maybe you get some ideas here: Writing program for NaN condition
Also, ensure you have compiler warnings enabled under preferences.

Sorry you mean here? I have the Italian version so I am not sure if matches the english.

Warning del compilatore: Nessuno // see what other options you have. Tutto ?

Ok enabling I do not get any error in the compiling and loading, I get the same loop in the monitor serial , I have tried changing that double line from int to fload and to unsigned int too but to no avail I still get the error, perhaps I can't declare those vars there?
could be not enough memory?

You can try something like this to handle unusable results in a float.
Maybe you can also make that field in the Thinkspeak channel an int instead of a float.
Setting compiler warnings on is simply to make some sorts of coding errors more visible. It does not show everything that can lead to a crash.

  float led_blue_F = ThingSpeak.readFloatField(channel, LEDblu_CH);

  int led_blu ;
  
  if ( isnan(led_blue_F) || led_blue_F == INFINITY || led_blue_F == -INFINITY ) {
    Serial.println( "Error led_blue_F unusable") ;
    led_blu = 0 ;
  }
  else {
    led_blu = (int) led_blue_F ;
    Serial.println( led_blu ) ;
  }

the thing is that I have set those linds, the if cycles, behind a // shield, I have checked that the lines that start the issue are the declaration of variables at the beginning of the cycle inside and after the check of connection so soon after the connection it gets the loop error I see... Mustn't be something related to that declaration?

Some things to try:

  1. Decode the stack trace: Stack Dumps — ESP8266 Arduino Core 3.1.1-7-ga9675ca8 documentation
  2. Create a the minimum size program that reproduces the error and post that.
  3. Defining a variable in the loop is OK but setting it to something invalid is not so, if you must assign a float to an int, check first that the float converts to a valid int.
  4. You have not supplied an API key with the readFloatField() so check that you have defined that channel correctly (public?).

The channel is public ...

I am wondering something now ...
Perhaps is not possible to contemporary write and read on the same API ? Like reading data from the sensors and write in the thingspeak json data and at the same time get the info data of two other fields from another source and update the fields there?

You are not actually reading and writing at the same time because these are separate and complete transactions.
Have you checked if reading is subject to the same "15 second" rule that writing is ?
If the read process blocks, that could cause the ESP to crash, but normally then with a WDT error message.

basically I wanted to send the DHT11 data to server, alter the server values there from another source and send back only values for field 3 and for to light up the leds, is this not possible ? Perhaps should I use a differend nodemcu with leds to have this data sent to ?

These are wild guessing without knowing what the real reason is, that it is not yet functioning.

You should test one thing at a time

Which server ? ThingSpeak-Server? write the exact name

What is the "another source" ?

send back to what device?
sending is an action initiated by a sender. I guess you mean the ThingSpeak-Server but I'm not sure. How do you want to make the ThingSpeak-Server send you values?

I guess you mean your device is requesting field 3 and field 4 from the ThingSpeak-Server. And depending on the values received switch on / off LEDs.

You have to much more precise and specific in your description to make it understandable what you really want.

best regards Stefan

Ok to be more specific , I am using a game engine, named unreal to communicate throguth api read , get , post limited to those commands, I can read data from server channel of thingspeak that i send data to from the nodemcu8266 , I then load those data throught get url and I read the json format I split the data and I get the values from the different fields to represent in the game engine, after that I wanted to send back some info from the engine to the server of thingspeak recording only two fields, the 3rd and 4rth , recording there a 1 or 0 value to setup the led lights on or off according if the temperature is too high or too low ...

I know I could do this much easier if I did this directly on the nodemcu setting the leds to red or blue on or off and without passing for the server and game engine back and forward, but the point is to get if I can make the double communication work on a single nodemcu or if I need instead to setup two different nodemcus one for leds and one for sensors, but then I would like to be able to make communicate and get orders or commands from the engine to the sensor, switching it off or else ( but those are just more advanced future iterations on the subject out of scope now , basically just command it from the engine and at the same time use it to gather data from there ) .

When I tested the engine I am getting the problem that when I update the json file with a get or a post it sets to null all fields apart the one of interest, so I didn't find a way to write only one field and I had to pass again the same values previously read and write so the whole array of fields back to thingspeak , from there I could then try to read back I guess on nodemcus, but I am not sure how , how should I setup a read and write event perhaps ? or make it all inside a single loop ? this is whats confusing, and at the end of the day I want to understand if is better to just use two nodemcus rather than one and , why shoudl I do so eventually .

Not sure if I was more clear in the description of what I am trying to do ?