Nodemcu esp8266 connecting to weathercloud

Hy guys im having a little trouble posting my temperature and humidity readings on weathercloud. In the serial monitor everithing is reading fine but when i go to weathercloud account it shows that the card connected but the temperature and humidity stay on zero. Here is the code. thanks

#include <ESP8266WiFi.h> //

#include <WiFiUdp.h>

#include <ESP8266WiFiMulti.h>
#include <ArduinoOTA.h>
#include <SPI.h>
#include <ESP8266mDNS.h>
#include <Wire.h>

ESP8266WiFiMulti wifiMulti;

//--------------------------------Setup Wifi----------------------------------------------

const char* ssid1 = “HUAWEI P30 lite”; //I use multiple SSID In my home, but you can only define one.

const char* password1 = “12345678”;

// ID Key ----------------------------------

char server = “”;;

char ID = “72389dd447e00ec0”;

char Key = “693ac7924969c7e86304f63973d23c15”;

unsigned int counter = 19;

float t;

float h;

float hic;

float dewpt_c;

#include “DHT.h”

#define DHTPIN 5 // Digital pin connected to the DHT sensor

// Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 –

// Pin 15 can work but DHT must be disconnected during program upload.

// Uncomment whatever type you’re using!

//#define DHTTYPE DHT11 // DHT 11

#define DHTTYPE DHT11 // DHT 22 (AM2302), AM2321

//#define DHTTYPE DHT21 // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V

// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1

// to 3.3V instead of 5V!

// Connect pin 2 of the sensor to whatever your DHTPIN is

// Connect pin 4 (on the right) of the sensor to GROUND

// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.

// Note that older versions of this library took an optional third parameter to

// tweak the timings for faster processors. This parameter is no longer needed

// as the current DHT reading algorithm adjusts itself to work on faster procs.


void setup() {


Serial.println(F(“DHTxx test!”));




void loop() {

// Wait a few seconds between measurements.


// Reading temperature or humidity takes about 250 milliseconds!

// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)

float h = dht.readHumidity();

// Read temperature as Celsius (the default)

float t = dht.readTemperature();

// Read temperature as Fahrenheit (isFahrenheit = true)

float f = dht.readTemperature(true);

float dewpt_c = (dewPoint(t, h)); //dew point

// Check if any reads failed and exit early (to try again).

if (isnan(h) || isnan(t) || isnan(f)) {

Serial.println(F(“Failed to read from DHT sensor!”));



// Compute heat index in Fahrenheit (the default)

float hif = dht.computeHeatIndex(f, h);

// Compute heat index in Celsius (isFahreheit = false)

float hic = dht.computeHeatIndex(t, h, false);

Serial.print(F("Humidity: "));


Serial.print(F("% Temperature: "));


Serial.print(F("°C "));


Serial.print(F("°F Heat index: "));


Serial.print(F("°C "));








///////////////////////////////// SEND DATA TO ////////////////////////////////////////////


void weathercloud(void)


if (counter == 20){


Serial.print("connecting to ");



WiFiClient client;

if (client.connect(server, 80)) {

Serial.print("connected to ");


} else {

Serial.println(“connection failed”);


client.print(“GET /set/wid/”);













client.println("/ HTTP/1.1");




if (!client.connected()) {

Serial.println(“client disconected.”);

if (client.connect(server, 80)) {


Serial.print("connected to ");


} else {

Serial.println(“connection failed”);







void startwifi()


Serial.print("Connecting to Wifi ");


wifiMulti.addAP(ssid1, password1); //if you have less SSID, delete the others

while ( != WL_CONNECTED) { delay(1000);




Serial.println(“WiFi connected”);

Serial.println("IP address: ");





/////////////////////////////////////////////// Calculate dew Point C ////////////////////////////////////////


double dewPoint(double t, double h)


double RATIO = 373.15 / (273.15 + t); // RATIO was originally named A0, possibly confusing in Arduino context

double SUM = -7.90298 * (RATIO - 1);

SUM += 5.02808 * log10(RATIO);

SUM += -1.3816e-7 * (pow(10, (11.344 * (1 - 1/RATIO ))) - 1) ;

SUM += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;

SUM += log10(1013.246);

double VP = pow(10, SUM - 3) * h;

double T = log(VP/0.61078); // temp var

return (241.88 * T) / (17.558 - T);



/////////////////////////////////////////////// Counter /////////////////////////////////////////////////////


void Counter()


if (counter == 20)


counter = 0; //10 minutes loop 30*20=600s = 10min




Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we’re trying to read your code. Don’t double-space!!

Please always do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

Please use code tags when you post code or warning/error messages. To do this, click the </> button on the forum toolbar, then paste the text you want to be in the code tags. Finally, move the cursor out of the code tags before adding any additional text you don’t want to be in the code tags. If your browser doesn’t show the posting toolbar, then you can manually add the code tags like this:
[code]``[color=blue]// your code is here[/color]``[/code]

The reason for doing this is that, without code tags, the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier for us to read your code and to copy it to the IDE or editor.

Using code tags and other important information is explained in the “How to use this forum” post. Please read it.

Now to help you with your problem. In your weathercloud function, you do things like this:

client.print(t * 10);

t is the global variable you declared near the top of your sketch:

float t;

In loop(), you do this:

float t = dht.readTemperature();

This creates a variable named t that is local to loop(), is only visible within loop(). Because it has the same name as you global variable t, you might think they are the same variables, but they are not. This is known as “variable shadowing”. The solution is to not declare a local variable in loop(). Instead, just define the value of the global variable:

t = dht.readTemperature();

hy thanks for your reply, im a little bit new in this field so i still dont know perfectly what am i doing. i tried to define the part as a global variable and with no luck. can you explain a little bit more what do i have to do. thanks

i tried to define the part as a global variable

Please post your updated code, using correct format and code tags this time.

with no luck

That's far too vague to be useful to use in helping you. Please provide a detailed description of what you mean by "no luck". If there are any error messages, post the full text of the error message, also using code tags.