Advertisement
djkvidp

Untitled

Nov 16th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. #include "ESP8266WiFi.h"
  2. #include <MAX6675_Thermocouple.h>
  3.  
  4. #define SCK_PIN 14 //(D5)
  5. #define CS_PIN 4 //(D2)
  6. #define SO_PIN 5 //(D1)
  7. #define CS2_PIN 0 //(D3)
  8.  
  9. MAX6675_Thermocouple* thermocouple = NULL;
  10. MAX6675_Thermocouple* thermocouple2 = NULL;
  11.  
  12. const char server[] = "192.168.10.14";
  13. const char* MY_SSID = "WWW.........CZ";
  14. const char* MY_PWD = "................";
  15.  
  16. WiFiClient client;
  17.  
  18.  
  19. void setup(){
  20. Serial.begin(115200);
  21. thermocouple = new MAX6675_Thermocouple(SCK_PIN, CS_PIN, SO_PIN);
  22. thermocouple2 = new MAX6675_Thermocouple(SCK_PIN, CS2_PIN, SO_PIN);
  23.  
  24.  
  25. Serial.print("Connecting to "+*MY_SSID);
  26. WiFi.begin(MY_SSID, MY_PWD);
  27. Serial.println("going into wl connect");
  28.  
  29. while (WiFi.status() != WL_CONNECTED) //not connected, ...waiting to connect
  30. {
  31. delay(2000);
  32. Serial.print(".");
  33. }
  34.  
  35. Serial.println("wl connected");
  36. Serial.println("");
  37. Serial.println("Credentials accepted! Connected to wifi\n ");
  38. Serial.println("");
  39. }
  40.  
  41. void loop() {
  42. const double t = thermocouple->readCelsius();
  43. const double v = thermocouple2->readCelsius();
  44.  
  45. Serial.print("Teplota - senzor 1: ");
  46. Serial.println(String(t) + " st. C");
  47. Serial.print("Teplota - senzor 2: ");
  48. Serial.println(String(v) + " st. C");
  49. delay(20000);
  50.  
  51. Serial.println("\nStarting connection to server...");
  52. // if you get a connection, report back via serial:
  53. if (client.connect(server, 80)) {
  54. Serial.println("connected to server");
  55. WiFi.printDiag(Serial);
  56.  
  57. String data = "t="
  58. + (String) t
  59. + "&v=" +(String) v;
  60.  
  61.  
  62. //change URL below if using your Sub-Domain
  63. client.println("POST /polycom/zpracuj.php HTTP/1.1");
  64. //change URL below if using your Domain
  65. client.print("Host: 192.168.0.103\n");
  66. client.println("User-Agent: ESP8266/1.0");
  67. client.println("Connection: close");
  68. client.println("Content-Type: application/x-www-form-urlencoded");
  69. client.print("Content-Length: ");
  70. client.print(data.length());
  71. client.print("\n\n");
  72. client.print(data);
  73. client.stop();
  74.  
  75. Serial.println("\n");
  76. Serial.println("My data string im POSTing looks like this: ");
  77. Serial.println(data);
  78. Serial.println("And it is this many bytes: ");
  79. Serial.println(data.length());
  80. delay(20000);
  81. }
  82.  
  83. }
  84.  
  85.  
  86. void printWifiStatus() {
  87. // print the SSID of the network you're attached to:
  88. Serial.print("SSID: ");
  89. Serial.println(WiFi.SSID());
  90.  
  91. // print your WiFi shield's IP address:
  92. IPAddress ip = WiFi.localIP();
  93. Serial.print("IP Address: ");
  94. Serial.println(ip);
  95.  
  96. // print the received signal strength:
  97. long rssi = WiFi.RSSI();
  98. Serial.print("signal strength (RSSI):");
  99. Serial.print(rssi);
  100. Serial.println(" dBm");
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement