ruzne:nacteni_teploty_ze_stranky_a_jeji_preposlani
no way to compare when less than two revisions
Rozdíly
Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.
— | ruzne:nacteni_teploty_ze_stranky_a_jeji_preposlani [2020/10/29 08:28] (aktuální) – vytvořeno multitricker | ||
---|---|---|---|
Řádek 1: | Řádek 1: | ||
+ | ====== Načtení teploty ze stránky a její přeposlání ====== | ||
+ | Autorem je Jiří Liška - [[lisak72@seznam.cz]]\\ | ||
+ | https:// | ||
+ | |||
+ | <file php tmepsender.php> | ||
+ | <?php | ||
+ | //$templ = file_get_contents(' | ||
+ | //echo $templ; | ||
+ | $handle = fopen(' | ||
+ | stream_set_timeout($handle, | ||
+ | if($handle==FALSE) { | ||
+ | | ||
+ | } | ||
+ | $contents = stream_get_contents($handle); | ||
+ | fclose($handle); | ||
+ | |||
+ | $str=$contents; | ||
+ | $from=" | ||
+ | $to="& | ||
+ | $contents=getStringBetween($str, | ||
+ | |||
+ | function getStringBetween($str, | ||
+ | { | ||
+ | $sub = substr($str, | ||
+ | return substr($sub, | ||
+ | } | ||
+ | if($contents!=FALSE && $contents!="" | ||
+ | $contents=trim($contents); | ||
+ | $contents=floatval($contents); | ||
+ | //echo $contents; | ||
+ | |||
+ | $handle2 = fopen(' | ||
+ | $response=stream_get_contents($handle2); | ||
+ | fclose($handle2); | ||
+ | |||
+ | echo $response; | ||
+ | } //end of if | ||
+ | exit | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | <file c TempSkleniky.ino> | ||
+ | //esp32 WROOM arduino | ||
+ | // | ||
+ | // client https:// | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | // dallas more sensors https:// | ||
+ | //hw https:// | ||
+ | // hw ESP32 Wroover module, standard configuration | ||
+ | // ntp client from https:// | ||
+ | // cidla kabel hneda +5V; zelena GND; zluta DATA | ||
+ | // Jiri Liska, liska.tbn@gmail.com, | ||
+ | // new hardware | ||
+ | // | ||
+ | #include " | ||
+ | #include " | ||
+ | #include " | ||
+ | #include " | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | //< | ||
+ | const byte DallasPin=19; | ||
+ | const byte DallasPowerPin=33; | ||
+ | const byte LED=13; | ||
+ | const bool WebServerOn=1; | ||
+ | const bool WebServer1On=0; | ||
+ | const String deviceName=" | ||
+ | //< | ||
+ | const bool Sensor1=1; | ||
+ | // | ||
+ | DeviceAddress internal1Adr={0x28, | ||
+ | const String Sensor1Place=" | ||
+ | //</ | ||
+ | //< | ||
+ | const bool Sensor2=1; | ||
+ | // | ||
+ | DeviceAddress external2Adr={0x28, | ||
+ | const String Sensor2Place=" | ||
+ | //</ | ||
+ | //< | ||
+ | const bool Sensor3=1; | ||
+ | DeviceAddress external3Adr={0x28, | ||
+ | // | ||
+ | const String Sensor3Place=" | ||
+ | const float calibration3=0.0; | ||
+ | //</ | ||
+ | int counter; | ||
+ | const float tempLimit=5.0; | ||
+ | float t1=-99.0, t2=-99.0, | ||
+ | String bcgcolor=" | ||
+ | //< | ||
+ | bool CLIENT=1; | ||
+ | const char *ssid = " | ||
+ | const char *password = " | ||
+ | //</ | ||
+ | //< | ||
+ | bool AP=0; | ||
+ | const char* APssid=" | ||
+ | const char* APpassword=" | ||
+ | IPAddress APIP(192, | ||
+ | IPAddress APGW(192, | ||
+ | const IPAddress IPMask(255, | ||
+ | //</ | ||
+ | //< | ||
+ | String tempWeb=" | ||
+ | String tempWebFin=" | ||
+ | String head01="< | ||
+ | //String head01="< | ||
+ | const String tail03="</ | ||
+ | const bool Debug=0; | ||
+ | //</ | ||
+ | //</ | ||
+ | |||
+ | OneWire DallasOW(DallasPin); | ||
+ | DallasTemperature Sensors(& | ||
+ | |||
+ | AsyncWebServer server(80); | ||
+ | WiFiServer server1(80); | ||
+ | |||
+ | float nactiTeplotu(int index){ | ||
+ | Sensors.requestTemperatures(); | ||
+ | return(Sensors.getTempCByIndex(index)); | ||
+ | } | ||
+ | |||
+ | float nactiTeplotuAddr(DeviceAddress adr){ | ||
+ | Sensors.requestTemperatures(); | ||
+ | return(Sensors.getTempC(adr)); | ||
+ | } | ||
+ | |||
+ | String searchAddr() | ||
+ | { | ||
+ | String addrs="< | ||
+ | byte addr[8]; | ||
+ | DallasOW.search(addr); | ||
+ | for(int i=0; i< | ||
+ | addrs+=String(addr[i], | ||
+ | addrs+=":"; | ||
+ | } | ||
+ | return addrs; | ||
+ | } | ||
+ | |||
+ | void blinkLed(){ | ||
+ | digitalWrite(LED, | ||
+ | delay(20); | ||
+ | digitalWrite(LED, | ||
+ | delay(50); | ||
+ | } | ||
+ | |||
+ | void setBackgroundColor(float measTemp){ | ||
+ | if(measTemp< | ||
+ | else bcgcolor=" | ||
+ | } | ||
+ | |||
+ | void setBackgroundColor(float measTemp1, float measTemp2){ | ||
+ | if((measTemp1< | ||
+ | else bcgcolor=" | ||
+ | } | ||
+ | |||
+ | void setBackgroundColor(float measTemp1, float measTemp2, float measTemp3){ | ||
+ | if((measTemp1< | ||
+ | else bcgcolor=" | ||
+ | } | ||
+ | |||
+ | void readingTempCorrect(float tt){ | ||
+ | if(tt< | ||
+ | counter++; | ||
+ | if(counter> | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void setup(){ | ||
+ | if(Debug){ | ||
+ | AP=1; | ||
+ | CLIENT=0; | ||
+ | head01="< | ||
+ | } | ||
+ | Serial.begin(115200); | ||
+ | pinMode(LED, | ||
+ | pinMode(DallasPowerPin, | ||
+ | digitalWrite(LED, | ||
+ | //Dallas reset | ||
+ | pinMode(DallasPowerPin, | ||
+ | pinMode(DallasPin, | ||
+ | digitalWrite(DallasPowerPin, | ||
+ | digitalWrite(DallasPin, | ||
+ | delay(1000); | ||
+ | digitalWrite(DallasPowerPin, | ||
+ | pinMode(DallasPin, | ||
+ | //end of Dallas reset | ||
+ | NTP.begin (" | ||
+ | |||
+ | // | ||
+ | WiFi.mode(WIFI_STA); | ||
+ | |||
+ | if(CLIENT){ | ||
+ | WiFi.begin(ssid, | ||
+ | while(WiFi.status()!= WL_CONNECTED) | ||
+ | { | ||
+ | delay(500); | ||
+ | Serial.print(" | ||
+ | blinkLed(); | ||
+ | counter++; | ||
+ | if(counter> | ||
+ | } | ||
+ | counter=0; | ||
+ | } | ||
+ | |||
+ | if(AP){ | ||
+ | WiFi.softAP(APssid, | ||
+ | WiFi.softAPConfig(APIP, | ||
+ | Serial.println(WiFi.softAPIP()); | ||
+ | } | ||
+ | |||
+ | digitalWrite(LED, | ||
+ | | ||
+ | Serial.println(" | ||
+ | Serial.println(" | ||
+ | Serial.println(WiFi.localIP()); | ||
+ | | ||
+ | Sensors.begin(); | ||
+ | |||
+ | if(WebServerOn){ | ||
+ | server.on("/", | ||
+ | request-> | ||
+ | // | ||
+ | }); | ||
+ | server.begin(); | ||
+ | } | ||
+ | |||
+ | if(WebServer1On){ | ||
+ | server1.begin(); | ||
+ | } | ||
+ | |||
+ | } //end of setup part | ||
+ | |||
+ | |||
+ | //String temp01, temp02; | ||
+ | void loop(){ | ||
+ | if(CLIENT && WiFi.status()!= WL_CONNECTED) { | ||
+ | digitalWrite(LED, | ||
+ | WiFi.reconnect(); | ||
+ | delay(20000); | ||
+ | if(WiFi.status()!= WL_CONNECTED) ESP.restart(); | ||
+ | } | ||
+ | else digitalWrite(LED, | ||
+ | t1=nactiTeplotuAddr(internal1Adr); | ||
+ | tempWeb="< | ||
+ | delay(10); | ||
+ | if(Sensor1){ | ||
+ | tempWeb+=" | ||
+ | tempWeb+=" | ||
+ | tempWeb+=String(t1, | ||
+ | } | ||
+ | | ||
+ | delay(10); | ||
+ | t2=nactiTeplotuAddr(external2Adr); | ||
+ | tempWeb+=" | ||
+ | tempWeb+=" | ||
+ | tempWeb+=String(t2, | ||
+ | } | ||
+ | | ||
+ | delay(10); | ||
+ | t3=nactiTeplotuAddr(external3Adr); | ||
+ | t3-=calibration3; | ||
+ | tempWeb+=" | ||
+ | tempWeb+=" | ||
+ | tempWeb+=String(t3, | ||
+ | } | ||
+ | readingTempCorrect(t1);// | ||
+ | readingTempCorrect(t2); | ||
+ | readingTempCorrect(t3); | ||
+ | setBackgroundColor(t1, | ||
+ | if(Debug){ | ||
+ | DallasOW.reset_search(); | ||
+ | tempWeb+="</ | ||
+ | } | ||
+ | tempWebFin=tempWeb; | ||
+ | delay(5000); | ||
+ | } | ||
+ | </ |