Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h> //Knihovna pro rizeni ESP:
- #include <ESP8266HTTPClient.h> //Knihovna pro klienta:
- #include <MAX6675_Thermocouple.h> //Knihovna pro rizeni senzoru:
- //Definovani PINU pro pripojeni:
- #define SCK_PIN 14 //(D5)
- #define CS_PIN 16 //(D0) // SENZOR 1
- #define CS2_PIN 15 //(D8) // SENZOR 2
- #define SO_PIN 12 //(D6)
- MAX6675_Thermocouple* thermocouple = NULL;
- MAX6675_Thermocouple* thermocouple2 = NULL;
- const String ID_zarizeni = "ids2002"; //Definuj id zařízení:
- //SSID a heslo pro Wi-Fi:
- const char* SSID = "*********";
- const char* heslo = "*******";
- void setup() {
- Serial.begin(115200);
- thermocouple = new MAX6675_Thermocouple(SCK_PIN, CS_PIN, SO_PIN); // SENZOR 1
- thermocouple2 = new MAX6675_Thermocouple(SCK_PIN, CS2_PIN, SO_PIN); // SENZOR 2
- //Pripojeni k Wi-Fi:
- 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());
- }
- // Smicka ktera se opakuje
- void loop() {
- const double celsius = thermocouple->readCelsius();
- const double celsius2 = thermocouple2->readCelsius();
- Serial.println("Teplota senzor 1: ");
- Serial.println(String(celsius) + " C, ");
- Serial.println("Teplota senzor 2: ");
- Serial.println(String(celsius2) + " C, ");
- if (WiFi.status() == WL_CONNECTED) { //Kontroluje pripojeni k wifi
- HTTPClient http; //Deklaruje http klienta
- http.begin("http://***************/databaze.php?t1=" + String(celsius) + "&t2=" + String(celsius2) + "&z=" + ID_zarizeni); //Určete cílové požadavky (teplota,vlhkost atd)
- int httpCode = http.GET(); //Odesila pozadavky na adresu
- //Pouze pokud potřebujeme odpověď ze serveru, například JSON data
- /*
- if (httpCode > 0) { //Check the returning code
- // String payload = http.getString(); //Get the request response payload
- // Serial.println(payload); //Print the response payload
- }
- */
- http.end(); //uzavira pripojeni
- }
- delay(60000); //Prodleva pred opakovanim (1 minuta)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement