Advertisement
Guest User

Untitled

a guest
May 26th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. //Payload
  2. {"StatusSNS":{"Time":"2018-05-26T16:29:48","DS18B20":{"Temperature":24.8},"TempUnit":"C"}}
  3.  
  4. //Code
  5.  
  6. HTTPClient http;    //Declare object of class HTTPClient
  7.  
  8.   //GET Data
  9.   String Link = "http://192.168.1.59/cm?user=admin&password=pass&cmnd=status%2010";
  10.  
  11.   http.begin(Link);     //Specify request destination
  12.  
  13.   int httpCode = http.GET();            //Send the request
  14.   String payload = http.getString();    //Get the response payload
  15.  
  16.   //Serial.println(httpCode);   //Print HTTP return code
  17.   //Serial.println("Payload: " + payload);    //Print request response payload
  18.  
  19.   //Start- und Endposition des Substring für die Temperatur
  20.   int posStart = payload.indexOf("re:") + 3;
  21.   int posEnd = payload.indexOf("},T");
  22.  
  23.   Serial.println("posStart: " + posStart);
  24.   Serial.println("posEnd: " + posEnd);
  25.  
  26. //Serial Output
  27. sStart:
  28. <empty line>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement