Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Program is dead after send json data several times #12

Open
YaoQ opened this issue Feb 22, 2016 · 2 comments
Open

Program is dead after send json data several times #12

YaoQ opened this issue Feb 22, 2016 · 2 comments

Comments

@YaoQ
Copy link

YaoQ commented Feb 22, 2016

Hi, I program the nodeMCU as my websocketclient, and send humidity and temperature data to the websocket server, for the first 5 times, the program update the data to the server successfully, but for the 6th time to send data, seemly the program is dead, this is no other information printed on the serial terminal. I have no idea what had happened. I am sure the server is OK, and the following is the information of the sketch.

Sketch uses 235,746 bytes (22%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 32,624 bytes (39%) of dynamic memory, leaving 49,296 bytes for local variables. Maximum is 81,920 bytes.

void loop() {
 h =  h + 1 ; //just for test
  t = t + 0.5; //just for test

  if (client.connected()) 
  {
   String       postStr ="{";
          postStr +="\"action\":\"update\",";
          postStr +="\"apikey\":\"";
          postStr += apikey;
          postStr +="\",";
          postStr +="\"deviceid\":\"";
          postStr += deviceID;
          postStr +="\",";
          postStr += "\"params\":";
          postStr += "{";
          postStr += "\"humidity\":\"";
          postStr += String(h);
          postStr +="\",";
          postStr += "\"temperature\":\"";
          postStr += String(t);
          postStr +="\"";
          postStr +="}";
          postStr +="}";

    webSocketClient.sendData(postStr);
    Serial.println("Update data");
    Serial.print("humidity: ");
    Serial.println(h);

  } else {
    Serial.println("Client disconnected.");
    while (1) {
      // Hang on disconnected
    }
  }

  // wait to fully let the client disconnect
  delay(20000);

}
@selvabha
Copy link

selvabha commented Dec 9, 2016

is ur problem solved???

@peterb0yd
Copy link

We noticed this library can't handle sending long strings. 5-6 bytes max, especially at these speeds. Highly recommend debouncing this as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants