Skip to content

Instantly share code, notes, and snippets.

@flexgrip
Created March 31, 2017 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flexgrip/96dd7ec013e077ae7def72e88dece717 to your computer and use it in GitHub Desktop.
Save flexgrip/96dd7ec013e077ae7def72e88dece717 to your computer and use it in GitHub Desktop.
Example esp8266
client.println("POST /posts HTTP/1.1");
client.println("Host: jsonplaceholder.typicode.com");
client.println("Cache-Control: no-cache");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(PostData.length());
client.println();
client.println(PostData);
long interval = 2000;
unsigned long currentMillis = millis(), previousMillis = millis();
while(!client.available()){
if( (currentMillis - previousMillis) > interval ){
Serial.println("Timeout");
blinkLed.detach();
digitalWrite(2, LOW);
client.stop();
return;
}
currentMillis = millis();
}
while (client.connected())
{
if ( client.available() )
{
char str=client.read();
Serial.println(str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment