I am using this tutorial. I am also using a same Node MCU ESP8266. Ii connected it to my home network. The local ip address is also displayed but it doesn't connected to my thingspeak channel and it stuck at the waiting for the client.
I also checked that my thingspeak API is correct and my home network is also working.
It looks like you are using the Arduino IDE to program the NodeMCU. If this is the case, then all you have to do create a WiFiClient, then construct an HTTP POST request, and send it to ThingSpeak using the client.
Here are the relevant lines from my tutorial:
Before your setup add the lines:
#include <ESP8266WiFi.h>
WiFiClient client;
const char* server = "api.thingspeak.com";
String writeAPIKey = "XXXXXXXXXXXXXXXX";
In your loop, add the following lines to read A0 and send it to ThingSpeak:
if (client.connect(server, 80)) {
// Measure Analog Input (A0)
int valueA0 = analogRead(A0);
// Construct API request body
String body = "field1=";
body += String(valueA0);
Serial.print("A0: ");
Serial.println(valueA0);
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + writeAPIKey + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(body.length());
client.print("\n\n");
client.print(body);
client.print("\n\n");
}
client.stop();
// wait 20 seconds and post again
delay(20000);