Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Knihovny pro ESP8266, MAX6675 a ThingSpeak:
- #include <ESP8266WiFi.h>
- #include <MAX6675_Thermocouple.h>
- #include <ThingSpeak.h>
- //Definice pro MAX6675:
- #define SCK_PIN 14 // D5
- #define CS_PIN 4 // D2
- #define SO_PIN 5 // D1
- #define CS2_PIN 0 // D3
- MAX6675_Thermocouple* thermocouple = NULL;
- MAX6675_Thermocouple* thermocouple2 = NULL;
- //Spusteni weboveho serveru:
- WiFiClient klient;
- WiFiServer server(80);
- //Udaje pro ThingSpeak:
- unsigned long ID_kanalu = 600888;
- const char * Write_API_Key = "I32RUVEGBQU3KGN4";
- //SSID a heslo pro Wi-Fi:
- const char* SSID = "*****************";
- const char* heslo = "*************************";
- void setup(){
- //Spusteni seriove linky na senzoru:
- Serial.begin(115200);
- thermocouple = new MAX6675_Thermocouple(SCK_PIN, CS_PIN, SO_PIN);
- thermocouple2 = new MAX6675_Thermocouple(SCK_PIN, CS2_PIN, SO_PIN);
- //Pripojeni k Wi-Fi a spusteni ThingSpeak serveru:
- Serial.println();
- Serial.println();
- Serial.print("Pripojovani k ");
- Serial.println(SSID);
- WiFi.begin(SSID, heslo);
- while (WiFi.status() != WL_CONNECTED){
- delay(500);
- Serial.print(".");
- }
- Serial.println("");
- Serial.println("Pripojeno!");
- Serial.println(WiFi.localIP());
- ThingSpeak.begin(klient);
- }
- void loop(){
- //Zmereni udaju a vypsani do seriove linky:
- const double celsius = thermocouple->readCelsius();
- const double celsius2 = thermocouple2->readCelsius();
- Serial.print("Teplota - senzor 1: ");
- Serial.println(String(celsius) + " st. C");
- Serial.print("Teplota - senzor 2: ");
- Serial.println(String(celsius2) + " st. C");
- delay(2000);
- //Odeslani na ThingSpeak:
- ThingSpeak.writeField(ID_kanalu, 1, String(celsius), Write_API_Key);
- delay(20000);
- ThingSpeak.writeField(ID_kanalu, 2, String(celsius2), Write_API_Key);
- delay(20000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement