Advertisement
Guest User

Untitled

a guest
May 21st, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <ESP8266WiFi.h>
  2.  
  3. int te = 25;
  4.  
  5. const char* ssid = ""; //tutaj wpisuje swoje dane wifi
  6. const char* haslo = "";
  7. const int port = 80;
  8. const char* host = "192.168.0.105";
  9.  
  10. WiFiClient client;
  11.  
  12. void setup() {
  13. Serial.begin(115200);
  14. delay (10);
  15.  
  16. WiFi.begin(ssid, haslo);
  17.  
  18. while (WiFi.status() != WL_CONNECTED) {
  19. delay (1000);
  20. Serial.println(".");
  21. }
  22. Serial.println("Połączono do: ");
  23. Serial.println(ssid);
  24.  
  25. Serial.println("Adres IP: ");
  26. Serial.println(WiFi.localIP());
  27.  
  28. }
  29.  
  30. void loop() {
  31. if (client.connect(host, port) == true)
  32. {
  33. Serial.println("połączono z serwerem!");
  34.  
  35.  
  36. client.print("GET /test.php");
  37. client.print("temp=");
  38. client.print(te);
  39.  
  40. Serial.println("Wysłano dane");
  41. }
  42. client.stop();
  43. Serial.println("Rozłączono z serwerem");
  44. delay(10000);
  45. }
  46.  
  47. /* Plik PHP na raspberry o nazwie test.php
  48. <?php
  49. $te = $_GET['temp'];
  50. echo $te
  51. ?>
  52. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement