Guest User

Untitled

a guest
Dec 14th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. //attempt to connect to wifi
  2.  
  3. float h = dht.readHumidity();
  4. float t = dht.readTemperature();
  5. String t1=String(t);
  6. Serial.println(h);
  7. Serial.println(t1);
  8.  
  9.  
  10. if(WiFi.status()== WL_CONNECTED)
  11. { //Check WiFi connection status
  12.  
  13. HTTPClient http; //Declare object of class HTTPClient
  14.  
  15. Serial.println("converted value="+t1);
  16. httpaddr = "http://iot.ijitm.com/add.php?t1="+t1;
  17. http.begin(httpaddr); //Specify request destination
  18. http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //Specify content-type header
  19.  
  20. Serial.println(httpaddr);
  21. int httpCode = http.GET(); //Send the request
  22. Serial.println("httpcode=");
  23. Serial.println(httpCode);
  24. String payload = http.getString(); //Get the response payload
  25.  
  26. Serial.println(httpCode); //Print HTTP return code
  27. Serial.println(payload); //Print request response payload
  28.  
  29. http.end(); //Close connection
  30.  
  31. }
  32. else
  33. {
  34. Serial.println("Error in WiFi connection");
  35. }
Add Comment
Please, Sign In to add comment