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 = "ids2003"; //Definuj id zařízení:
- //SSID a heslo pro Wi-Fi:
- //const char* SSID = "";
- //const char* heslo = "";
- const char* SSID = "";
- const char* HESLO = "";
- void setup() {
- //Nacteni senzoru:
- thermocouple = new MAX6675_Thermocouple(SCK_PIN, CS_PIN, SO_PIN); // SENZOR 1
- thermocouple2 = new MAX6675_Thermocouple(SCK_PIN, CS2_PIN, SO_PIN); // SENZOR 2
- WiFi.softAPdisconnect (true); //zakazani AP rezimu
- Serial.begin(115200); // Startuje komunikaci po seriova lince s pocitacem
- delay(100); //Prodleva pro stabilizaci pripojeni
- Serial.println('\n');
- WiFi.begin(SSID, HESLO); // Pripojovani k siti
- Serial.print("Pripojovani k ");
- Serial.print(SSID); Serial.println(" ...");
- int i = 0;
- while (WiFi.status() != WL_CONNECTED) { // Cekani na pripojeni k WIFI
- delay(1000);
- Serial.print(++i); Serial.print(' ');
- }
- Serial.println('\n');
- Serial.println("Pripojeni je stabilni!");
- Serial.print("IP address:\t");
- Serial.println(WiFi.localIP()); // Zaslani prirazene ip adresy po seriova lince
- }
- // Smicka ktera se opakuje
- void loop() {
- if (WiFi.status() != WL_CONNECTED) {
- reconnect();
- }
- }
- void reconnect() {
- Serial.print("Reconnecting");
- WiFi.mode(WIFI_STA);
- WiFi.begin(SSID, HESLO);
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println("Connected!");
- }
- 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, ");
- HTTPClient http; //Declare object of class HTTPClient
- http.begin("http://.php?t1=" + String(celsius) + "&t2=" + String(celsius2) + "&z=" + ID_zarizeni); //Specify request destination
- int httpCode = http.GET(); //Odesila pozadavky na adresu
- //http.end(); //uzavira pripojeni
- }
- delay(10000); //Prodleva pred opakovanim (1 minuta)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement