Advertisement
djkvidp

Untitled

Nov 14th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. //Knihovny pro ESP8266, MAX6675 a ThingSpeak:
  2.  
  3. #include <ESP8266WiFi.h>
  4. #include <MAX6675_Thermocouple.h>
  5. #include <ThingSpeak.h>
  6.  
  7. //Definice pro MAX6675:
  8.  
  9. #define SCK_PIN 14 // D5
  10. #define CS_PIN 4 // D2
  11. #define SO_PIN 5 // D1
  12. #define CS2_PIN 0 // D3
  13.  
  14. MAX6675_Thermocouple* thermocouple = NULL;
  15. MAX6675_Thermocouple* thermocouple2 = NULL;
  16.  
  17. //Spusteni weboveho serveru:
  18.  
  19. WiFiClient klient;
  20. WiFiServer server(80);
  21.  
  22. //Udaje pro ThingSpeak:
  23.  
  24. unsigned long ID_kanalu = 600888;
  25. const char * Write_API_Key = "I32RUVEGBQU3KGN4";
  26.  
  27. //SSID a heslo pro Wi-Fi:
  28.  
  29. const char* SSID = "*****************";
  30. const char* heslo = "*************************";
  31.  
  32. void setup(){
  33. //Spusteni seriove linky na senzoru:
  34.  
  35. Serial.begin(115200);
  36. thermocouple = new MAX6675_Thermocouple(SCK_PIN, CS_PIN, SO_PIN);
  37. thermocouple2 = new MAX6675_Thermocouple(SCK_PIN, CS2_PIN, SO_PIN);
  38.  
  39. //Pripojeni k Wi-Fi a spusteni ThingSpeak serveru:
  40.  
  41. Serial.println();
  42. Serial.println();
  43. Serial.print("Pripojovani k ");
  44. Serial.println(SSID);
  45.  
  46. WiFi.begin(SSID, heslo);
  47.  
  48. while (WiFi.status() != WL_CONNECTED){
  49. delay(500);
  50. Serial.print(".");
  51. }
  52. Serial.println("");
  53. Serial.println("Pripojeno!");
  54.  
  55. Serial.println(WiFi.localIP());
  56.  
  57. ThingSpeak.begin(klient);
  58. }
  59.  
  60. void loop(){
  61. //Zmereni udaju a vypsani do seriove linky:
  62.  
  63. const double celsius = thermocouple->readCelsius();
  64. const double celsius2 = thermocouple2->readCelsius();
  65.  
  66. Serial.print("Teplota - senzor 1: ");
  67. Serial.println(String(celsius) + " st. C");
  68. Serial.print("Teplota - senzor 2: ");
  69. Serial.println(String(celsius2) + " st. C");
  70. delay(2000);
  71.  
  72. //Odeslani na ThingSpeak:
  73.  
  74. ThingSpeak.writeField(ID_kanalu, 1, String(celsius), Write_API_Key);
  75. delay(20000);
  76. ThingSpeak.writeField(ID_kanalu, 2, String(celsius2), Write_API_Key);
  77. delay(20000);
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement