rinaldohack

Untitled

Jul 22nd, 2019
1,087
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ESP8266WiFi.h>
  2. #include <ESP8266HTTPClient.h>
  3.  
  4. //replace "ssid" with your WiFi SSID
  5. const char* ssid = "ssid";
  6.  
  7. //replace "pass" with your WiFi Pass
  8. const char* pass = "pass";
  9.  
  10. void setup () {
  11.  
  12. // Serial monitor Baud Rate
  13. Serial.begin(115200);
  14. // Begin WiFI connect
  15. WiFi.begin(ssid, pass);
  16.  
  17. // While wifi is not connected, print connecting every 1s (1000ms) to serial monitor.
  18. while (WiFi.status() != WL_CONNECTED)
  19. {
  20. delay(1000);
  21. Serial.println("Connecting ...");
  22. }
  23.  
  24. //report WiFI Connected with IP address
  25. Serial.println(F(""));
  26. Serial.println(F("WiFi connected"));
  27. Serial.println();
  28. Serial.print(F("IP address is "));
  29. Serial.println(WiFi.localIP());
  30.  
  31.  
  32. // initialize digital pin LED_BUILTIN as an output.
  33. pinMode(LED_BUILTIN, OUTPUT);
  34.  
  35. }
  36.  
  37.  
  38.  
  39. // the loop function runs over and over again forever
  40. void loop() {
  41. //turn the LED on (LOW is the voltage level)
  42. digitalWrite(LED_BUILTIN, LOW);
  43. //input to project.rinaldo.id/esp8266
  44. inputweb("blinktest2",0,0,0,0,0,0,"ON","LOW","");
  45. //delay 1s
  46. delay(1000);
  47.  
  48. //turn the LED of (HIGH is the voltage level)
  49. digitalWrite(LED_BUILTIN, HIGH);
  50. //input to project.rinaldo.id/esp8266
  51. inputweb("blinktest2",1,1,1,1,1,1,"OFF","HIGH","");
  52. //delay 1s
  53. delay(1000);
  54.  
  55.  
  56. }
  57.  
  58. void inputweb(char identifier[255], float sensor1, float sensor2, float sensor3, float sensor4, float sensor5, float sensor6, char char1[], char char2[], char char3[])
  59. {
  60. //Check WiFi connection status
  61. if (WiFi.status() == WL_CONNECTED)
  62. {
  63.  
  64. HTTPClient http; //Declare an object of class HTTPClient
  65.  
  66. http.begin(String("http://project.rinaldo.id/esp8266/input.php?")
  67. + String("identifier=") + identifier
  68. + String("&sensor1=") + String(sensor1)
  69. + String("&sensor2=") + String(sensor2)
  70. + String("&sensor3=") + String(sensor3)
  71. + String("&sensor4=") + String(sensor4)
  72. + String("&sensor5=") + String(sensor5)
  73. + String("&sensor6=") + String(sensor6)
  74. + String("&char1=") + char1
  75. + String("&char2=") + char2
  76. + String("&char3=") + char3
  77. ); //Specify request destination
  78.  
  79. int httpCode = http.GET(); //Send the request
  80.  
  81. if (httpCode > 0) //Check the returning code
  82. {
  83. String payload = http.getString(); //Get the request response payload
  84. Serial.println("Server returned : ");
  85. Serial.println(payload); //Print the response payload from server
  86.  
  87. }
  88.  
  89. http.end(); //Close connection
  90. }
  91. }
RAW Paste Data