{"id":22,"date":"2024-09-26T10:32:39","date_gmt":"2024-09-26T08:32:39","guid":{"rendered":"https:\/\/roess.ovh\/?page_id=22"},"modified":"2024-11-04T06:37:11","modified_gmt":"2024-11-04T05:37:11","slug":"poolueberwachung","status":"publish","type":"page","link":"https:\/\/roess.ovh\/index.php\/projekte\/pr\/poolueberwachung\/","title":{"rendered":"Pool\u00fcberwachung"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><strong>Wasserqualit\u00e4ts\u00fcberwacher f\u00fcr einen Pool.<\/strong><\/p>\n\n\n\n<p>Dieser sollte&nbsp; z.B. im Pumpenhaus untergebracht, t\u00e4glich \u00fcber WLAN Messwerte an einen WEB-Server oder per mail \u00fcbertragen. <\/p>\n\n\n\n<p>Dabei kann ein ESP32 dauerhaft stromversorgt werden und eine Verbindung zum WLAN aufrechterhalten. <\/p>\n\n\n\n<p>So k\u00f6nnte man feststellen, ob der ordentlich gewartet wird oder ob der Pool kurz vorm Umkippen ist.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"724\" height=\"1024\" src=\"https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/messung-esp-spanien-724x1024.png\" alt=\"\" class=\"wp-image-100\" srcset=\"https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/messung-esp-spanien-724x1024.png 724w, https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/messung-esp-spanien-212x300.png 212w, https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/messung-esp-spanien-768x1086.png 768w, https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/messung-esp-spanien.png 794w\" sizes=\"(max-width: 724px) 100vw, 724px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"has-large-font-size\"><strong>L\u00f6sungsansatz Der ESP32 sendet den Messwert \u00fcber einen MQTT-Server an einen zweiten ESP32, der die Messwerte darstellt.<\/strong><\/li>\n<\/ol>\n\n\n\n<p>Files:<\/p>\n\n\n\n<p style=\"font-style:normal;font-weight:700\">main.py<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-vivid-red-color has-text-color has-link-color has-large-font-size wp-elements-e05468aa026f2ec3bb0b8f92da232fd9\">ESP32 \u00dcberwachung<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-vivid-red-color has-text-color has-link-color has-large-font-size wp-elements-dcde83de618ac4d5bdd89c663a139471\">Complete project details at https:\/\/RandomNerdTutorials.com\/micropython-programming-with-esp32-and-esp8266\/<\/h1>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">def sub_cb(topic, msg):<br># print((&#8216;Uebertragung: &#8216;, topic, msg))<br>msg=str(msg)<br>msg= msg[2:]<br>msg=msg[:-5]<br>print((&#8216;NTC3905-100k: &#8216;, msg))<br># print [&#8220;%0.2f&#8221; % i]<br>def connect_and_subscribe():<br>global client_id, mqtt_server, topic_sub<br>client = MQTTClient(client_id, mqtt_server, user=mqtt_user, password=mqtt_pass, ssl=True)<br>client.set_callback(sub_cb)<br>client.connect()<br>client.subscribe(topic_sub)<br>print(&#8216;Connected to %s MQTT broker, subscribed to %s topic&#8217; % (mqtt_server, topic_sub))<br>return client<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">def restart_and_reconnect():<br>print(&#8216;Failed to connect to MQTT broker. Reconnecting\u2026&#8217;)<br>time.sleep(10)<br>machine.reset()<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">try:<br>client = connect_and_subscribe()<br>except OSError as e:<br>restart_and_reconnect()<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">while True:<br>try:<br>new_message = client.wait_msg()<br>client.publish(topic_pub, b&#8217;received&#8217;)<br>time.sleep(1)<br>except OSError as e:<br>restart_and_reconnect()<\/p>\n\n\n\n<p class=\"has-small-font-size\"><\/p>\n\n\n\n<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>boot.py:<\/strong><\/p>\n\n\n\n<h1 class=\"wp-block-heading has-vivid-red-color has-text-color has-link-color has-medium-font-size wp-elements-c79b0400492e013aa0926b838f716c16\">Complete project details at https:\/\/RandomNerdTutorials.com\/micropython-programming-with-esp32-and-esp8266\/<\/h1>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">import time<br>from umqttsimple import MQTTClient<br>import ubinascii<br>import machine<br>import micropython<br>import network<br>import esp<br>esp.osdebug(None)<br>import gc<br>gc.collect()<\/p>\n\n\n\n<p># ==&gt; eigene Werte einfuegen<\/p>\n\n\n\n<p class=\"has-foreground-color has-text-color has-link-color has-small-font-size wp-elements-edc05e1290113aec55c149ab00be3354\" style=\"line-height:1\">ssid = &#8216;<em>ssid<\/em>&#8216; <br>password = &#8216;<em>password<\/em>&#8216;<br>mqtt_server = &#8216;<em>mqtt_server<\/em>&#8216;<br>mqtt_user = &#8216;<em>mqtt_user<\/em>&#8216;<br>mqtt_pass = &#8216;<em>mqtt_password<\/em>&#8216;<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-vivid-red-color has-text-color has-link-color has-large-font-size wp-elements-a4d0a32eb24c0df1e59b6a92f44d15d6\">EXAMPLE IP ADDRESS<\/h1>\n\n\n\n<h1 class=\"wp-block-heading has-vivid-red-color has-text-color has-link-color has-large-font-size wp-elements-1192d8b87c0690e5ea28dc069dc5aee1\">mqtt_server = &#8216;192.168.1.144&#8217;<\/h1>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">client_id = ubinascii.hexlify(machine.unique_id())<br>topic_sub = b&#8217;hello&#8217;<br>topic_pub = b&#8217;notification&#8217;<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">last_message = 0<br>message_interval = 5<br>counter = 0<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">station = network.WLAN(network.STA_IF)<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">station.active(True)<br>station.connect(ssid, password)<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">while station.isconnected() == False:<br>pass<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">print(&#8216;Connection successful&#8217;)<br>print(station.ifconfig())<\/p>\n\n\n\n<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n\n\n\n<p>zus\u00e4tzlich Datei &#8216;umqttsimple.py&#8217; und eine SSL-Library auf den ESP32 schreiben.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-large-font-size\"><strong>2. Software- und Kalibrierungsaktualisierung<\/strong><\/p>\n\n\n\n<p>Die Aktualisierung des Messprogramms bzw. von Kalibrier-<br>Faktoren geschieht OTA (over the air) mit Hilfe eines GitHUB-<br>Repositories (<a href=\"https:\/\/github.com\/proess\/ESP32_OTA\">https:\/\/github.com\/proess\/ESP32_OTA<\/a>), welches die Aktualisierungen mit Hilfe von<br>Versionsnummern (Software bzw. Kalibrierwerte) erm\u00f6glicht.<\/p>\n\n\n\n<h1 class=\"wp-block-heading has-large-font-size\">ReadMe.md: <strong>MicroPython Over-the-Air updater<\/strong><\/h1>\n\n\n\n<p>This library enables you to update your MicroPython projects over the air, at start-up, or whenever you choose.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>To use this code:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add the <code>ota.py<\/code> to your MicroPython device<\/li>\n\n\n\n<li>Create a file named <code>WIFI_CONFIG.py<\/code> on your MicroPython device, which contains two variables: <code>SSID<\/code> and <code>PASSWORD<\/code>: <code>SSID = \"my wifi hotspot name\" PASSWORD = \"wifi password\"<\/code><\/li>\n\n\n\n<li>Add this to your main program code: <code>from ota import OTAUpdater from WIFI_CONFIG import SSID, PASSWORD firmware_url = \"https:\/\/raw.githubusercontent.com\/&lt;username&gt;\/&lt;repo_name&gt;\/&lt;branch_name&gt;\"<\/code> where <code>&lt;username&gt;<\/code> is your github username, <code>&lt;repo_name&gt;<\/code> is the name of the repository to check for updates and <code>&lt;branch_name&gt;<\/code> is the name of the branch to monitor.<\/li>\n\n\n\n<li>Add this to your main program code: <code>ota_updater = OTAUpdater(SSID, PASSWORD, firmware_url, \"test.py\") ota_updater.download_and_install_update_if_available()<\/code><\/li>\n\n\n\n<li>On your GitHub repository, add a <code>version.json<\/code> file, and add a <code>version<\/code> element to the JSON file, with a version number: <code>{ \"version\":3 }<\/code><\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>The <code>OTA-Updater<\/code> will connect to github over wifi using your provided wifi credentials, check what the most up-to-date version of the firmware is, compare this to a local file present on the device named <code>version.json<\/code>, which contains the version number of the current on device firmware.<\/p>\n\n\n\n<p>If the local file is not present it will create one with a version number of <code>0<\/code>. If the Github version is newer, it will download the latest file and overwrite the file on the device with the same name, then restart the MicroPython board.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>If you find this useful, please let me know on our discord server: <a href=\"https:\/\/www.kevsrobots.com\/discord\">https:\/\/www.kevsrobots.com\/discord<\/a><\/p>\n\n\n\n<p style=\"font-style:normal;font-weight:700\">ota_test.py<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">from ota import OTAUpdater<br>from WIFI_CONFIG import SSID, PASSWORD<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">firmware_url = &#8220;https:\/\/github.com\/proess\/ESP32_OTA\/blob\/main&#8221;<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">ota_updater = OTAUpdater(SSID, PASSWORD, firmware_url, &#8220;main.py&#8221;)<\/p>\n\n\n\n<p class=\"has-small-font-size\" style=\"line-height:1\">ota_updater.download_and_install_update_if_available()<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color has-link-color has-large-font-size wp-elements-f0f834a46ab056b60ce369e4ab45f50c\"><strong>Beispiel zur Messwert\u00fcbertragung und -darstellung<\/strong><\/p>\n\n\n\n<p>So k\u00f6nnte es aussehen, wenn man in Spanien einen Temperatur-Messf\u00fchler anfasst und wieder losl\u00e4sst \ud83d\ude42<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"769\" src=\"https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/WhatsApp-Bild-2024-11-04-um-06.30.14_47f99f87-1024x769.jpg\" alt=\"\" class=\"wp-image-109\" style=\"width:1099px;height:auto\" srcset=\"https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/WhatsApp-Bild-2024-11-04-um-06.30.14_47f99f87-1024x769.jpg 1024w, https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/WhatsApp-Bild-2024-11-04-um-06.30.14_47f99f87-300x225.jpg 300w, https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/WhatsApp-Bild-2024-11-04-um-06.30.14_47f99f87-768x576.jpg 768w, https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/WhatsApp-Bild-2024-11-04-um-06.30.14_47f99f87-1536x1153.jpg 1536w, https:\/\/roess.ovh\/wp-content\/uploads\/2024\/11\/WhatsApp-Bild-2024-11-04-um-06.30.14_47f99f87.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Wasserqualit\u00e4ts\u00fcberwacher f\u00fcr einen Pool. Dieser sollte&nbsp; z.B. im Pumpenhaus untergebracht, t\u00e4glich \u00fcber WLAN Messwerte an einen WEB-Server oder per mail \u00fcbertragen. Dabei kann ein ESP32 dauerhaft stromversorgt werden und eine Verbindung zum WLAN aufrechterhalten. So k\u00f6nnte man feststellen, ob der ordentlich gewartet wird oder ob der Pool kurz vorm Umkippen ist.&nbsp; Files: main.py ESP32 \u00dcberwachung [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":18,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-22","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/roess.ovh\/index.php\/wp-json\/wp\/v2\/pages\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/roess.ovh\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/roess.ovh\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/roess.ovh\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/roess.ovh\/index.php\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":18,"href":"https:\/\/roess.ovh\/index.php\/wp-json\/wp\/v2\/pages\/22\/revisions"}],"predecessor-version":[{"id":112,"href":"https:\/\/roess.ovh\/index.php\/wp-json\/wp\/v2\/pages\/22\/revisions\/112"}],"up":[{"embeddable":true,"href":"https:\/\/roess.ovh\/index.php\/wp-json\/wp\/v2\/pages\/18"}],"wp:attachment":[{"href":"https:\/\/roess.ovh\/index.php\/wp-json\/wp\/v2\/media?parent=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}