Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. #include <ESP8266WiFi.h> //Knihovna pro rizeni ESP:
  2. #include <ESP8266HTTPClient.h> //Knihovna pro klienta:
  3. #include <MAX6675_Thermocouple.h> //Knihovna pro rizeni senzoru:
  4.  
  5. //Definovani PINU pro pripojeni:
  6.  
  7. #define SCK_PIN 14 //(D5)
  8. #define CS_PIN 16 //(D0) // SENZOR 1
  9. #define CS2_PIN 15 //(D8) // SENZOR 2
  10. #define SO_PIN 12 //(D6)
  11.  
  12.  
  13. MAX6675_Thermocouple* thermocouple = NULL;
  14. MAX6675_Thermocouple* thermocouple2 = NULL;
  15.  
  16. const String ID_zarizeni = "ids2003"; //Definuj id zařízení:
  17.  
  18. //SSID a heslo pro Wi-Fi:
  19. //const char* SSID = "";
  20. //const char* heslo = "";
  21. const char* SSID = "";
  22. const char* HESLO = "";
  23.  
  24.  
  25. void setup() {
  26.  
  27.  
  28. //Nacteni senzoru:
  29. thermocouple = new MAX6675_Thermocouple(SCK_PIN, CS_PIN, SO_PIN); // SENZOR 1
  30. thermocouple2 = new MAX6675_Thermocouple(SCK_PIN, CS2_PIN, SO_PIN); // SENZOR 2
  31.  
  32. WiFi.softAPdisconnect (true); //zakazani AP rezimu
  33. Serial.begin(115200); // Startuje komunikaci po seriova lince s pocitacem
  34. delay(100); //Prodleva pro stabilizaci pripojeni
  35. Serial.println('\n');
  36.  
  37. WiFi.begin(SSID, HESLO); // Pripojovani k siti
  38. Serial.print("Pripojovani k ");
  39. Serial.print(SSID); Serial.println(" ...");
  40.  
  41. int i = 0;
  42. while (WiFi.status() != WL_CONNECTED) { // Cekani na pripojeni k WIFI
  43. delay(1000);
  44. Serial.print(++i); Serial.print(' ');
  45. }
  46.  
  47. Serial.println('\n');
  48. Serial.println("Pripojeni je stabilni!");
  49. Serial.print("IP address:\t");
  50. Serial.println(WiFi.localIP()); // Zaslani prirazene ip adresy po seriova lince
  51.  
  52. }
  53.  
  54. // Smicka ktera se opakuje
  55.  
  56. void loop() {
  57. if (WiFi.status() != WL_CONNECTED) {
  58. reconnect();
  59. }
  60. }
  61. void reconnect() {
  62. Serial.print("Reconnecting");
  63. WiFi.mode(WIFI_STA);
  64. WiFi.begin(SSID, HESLO);
  65. while (WiFi.status() != WL_CONNECTED) {
  66. delay(500);
  67. Serial.print(".");
  68. }
  69. Serial.println("Connected!");
  70. }
  71.  
  72. const double celsius = thermocouple->readCelsius();
  73. const double celsius2 = thermocouple2->readCelsius();
  74.  
  75. Serial.println("Teplota senzor 1: ");
  76. Serial.println(String(celsius) + " C, ");
  77.  
  78. Serial.println("Teplota senzor 2: ");
  79. Serial.println(String(celsius2) + " C, ");
  80.  
  81. HTTPClient http; //Declare object of class HTTPClient
  82.  
  83. http.begin("http://.php?t1=" + String(celsius) + "&t2=" + String(celsius2) + "&z=" + ID_zarizeni); //Specify request destination
  84.  
  85. int httpCode = http.GET(); //Odesila pozadavky na adresu
  86.  
  87. //http.end(); //uzavira pripojeni
  88. }
  89.  
  90. delay(10000); //Prodleva pred opakovanim (1 minuta)
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement