esp-mikrocontroller
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| esp-mikrocontroller [2023/02/07 11:49] – [ESP32] lars | esp-mikrocontroller [2026/02/14 18:05] (current) – lars | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Mikrocontroller der ESP-Familie ====== | ====== Mikrocontroller der ESP-Familie ====== | ||
| + | |||
| + | Referenz der Pins am ESP32: https:// | ||
| + | |||
| + | Welche ESP32-Modelle gibt es: https:// | ||
| + | |||
| + | Welche Mikrocontroller habe ich genau: [[Mikrocontroller_varianten|Mikrocontroller_varianten]] | ||
| ===== Programmieren / Flashen ===== | ===== Programmieren / Flashen ===== | ||
| Line 36: | Line 42: | ||
| Ich verbinde den Sensor mit den GPIO-PIN D8. GND und 3V3 nehme ich auf der gegenüberliegenden Seite ab. | Ich verbinde den Sensor mit den GPIO-PIN D8. GND und 3V3 nehme ich auf der gegenüberliegenden Seite ab. | ||
| + | |||
| + | ===== Einsatz ===== | ||
| + | |||
| + | ==== Heizungskeller / ESP8266 ==== | ||
| + | |||
| + | Ein ESP8266 steht im Heizungskeller. Er erfasst die Temperaturen verschiedener Rohrleitungen dort und auch der Gaszähler wird ausgelesen. | ||
| + | Als Software wird ESPEasy eingesetzt. Die Temperaturfühler sind DS18B20. | ||
| + | Zum auslesen des Gaszählers wird ein Reed-Kontakt verwendet. | ||
| + | Alles ist von AliExpress im Dez 2022 und Frühjahr '23 gekauft. | ||
| + | |||
| + | Hier ein paar Screenshots zur Konfiguration: | ||
| + | {{:: | ||
| + | {{: | ||
| + | Weil mit Telegraf (für die InfluxDB) das Auslesen eines einzelnen Werts schwieriger war als ein JSON zu parsen, nutze ich in ESPEasy nicht die Möglichkeit, | ||
| + | Das würde die Checkbox bei jedem Device machen. | ||
| + | Statt dessen gibt es eine Regel (~Rules), die eine JSON-Nachricht zusammenbaut und verschickt. \\ | ||
| + | {{: | ||
| + | Hier die Regeln (Stand Feb '23) als Text zum kopieren: \\ | ||
| + | <file text rules.txt> | ||
| + | On Zirkulation_Ruecklauf# | ||
| + | Publish " | ||
| + | Endon | ||
| + | |||
| + | On Heizung_Vorlauf# | ||
| + | // Der Messfühler ist typischerweise 1°C kühler als der im Keller auf der Uhr angezeigte Wert. Hier korrigiere ich das, weil ich annehme das mein Sensor eher falsch liegt. | ||
| + | let, | ||
| + | Publish " | ||
| + | Endon | ||
| + | |||
| + | On Warmwasser# | ||
| + | // Der Messfühler ist typischerweise 1°C kühler als der im Keller auf der Heizungssteuerung angezeigte Wert. Hier korrigiere ich das, weil ich annehme das mein Sensor eher falsch liegt. | ||
| + | let, | ||
| + | Publish " | ||
| + | Endon | ||
| + | |||
| + | On Raum# | ||
| + | Publish " | ||
| + | Endon | ||
| + | |||
| + | On gasreedpuls# | ||
| + | Publish " | ||
| + | Endon | ||
| + | </ | ||
| + | Beim MQTT-Server kommt das dann wie folgt an: \\ | ||
| + | {{: | ||
| + | |||
| + | ==== Flur EG / Thermometer auslesen / ESP32 ==== | ||
| + | |||
| + | In der Nähe des Kellerlochs im Flur im EG steht ein ESP32. | ||
| + | Dieser hat (im Gegensatz zum 8266) Bluetooth eingebaut. | ||
| + | Seine Aufgabe ist es, die im Haus aufgestellten Govee-Thermometer auszulesen. | ||
| + | Diese senden regelmäßig per BLE (Blutooth Low Energy) ihre Daten herum. | ||
| + | Der Mikrokontroller nimmt sie an und stellt sie als ein Sensor der HomeAssistant-Installation im Haus zur Verfügung. | ||
| + | |||
| + | Der ESP32 ist per ESPHome, also dem ESP-AddOn von HomeAssistant - prgrammiert. | ||
| + | Hier der Quelltext: \\ | ||
| + | <file text esp32-ble.yaml> | ||
| + | esphome: | ||
| + | name: esp32-ble | ||
| + | |||
| + | esp32: | ||
| + | board: esp32dev | ||
| + | framework: | ||
| + | type: arduino | ||
| + | |||
| + | # Enable logging | ||
| + | logger: | ||
| + | |||
| + | # Enable Home Assistant API | ||
| + | api: | ||
| + | encryption: | ||
| + | key: " | ||
| + | |||
| + | ota: | ||
| + | password: " | ||
| + | |||
| + | wifi: | ||
| + | ssid: !secret wifi_ssid | ||
| + | password: !secret wifi_password | ||
| + | |||
| + | # Enable fallback hotspot (captive portal) in case wifi connection fails | ||
| + | ap: | ||
| + | ssid: " | ||
| + | password: " | ||
| + | |||
| + | captive_portal: | ||
| + | | ||
| + | sensor: | ||
| + | # GOVEE Sensor1 CHANGE NAMES AS NEEDED here and in Lamda Section | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee1_humidity | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee1_temperature | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee1_battery | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | |||
| + | # GOVEE Sensor2 CHANGE NAMES AS NEEDED here and in Lamda Section | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee2_humidity | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee2_temperature | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee2_battery | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | |||
| + | # GOVEE Sensor3 CHANGE NAMES AS NEEDED here and in Lamda Section | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee3_humidity | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee3_temperature | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee3_battery | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | |||
| + | # GOVEE Sensor4 CHANGE NAMES AS NEEDED here and in Lamda Section | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee4_humidity | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee4_temperature | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee4_battery | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | |||
| + | # GOVEE Sensor5 CHANGE NAMES AS NEEDED here and in Lamda Section | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee5_humidity | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee5_temperature | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee5_battery | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | |||
| + | # GOVEE Sensor6 CHANGE NAMES AS NEEDED here and in Lamda Section | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee6_humidity | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee6_temperature | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee6_battery | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | |||
| + | # GOVEE Sensor7 CHANGE NAMES AS NEEDED here and in Lamda Section | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee7_humidity | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee7_temperature | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee7_battery | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | |||
| + | # GOVEE Sensor8 CHANGE NAMES AS NEEDED here and in Lamda Section | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee8_humidity | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee8_temperature | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: govee8_battery | ||
| + | unit_of_measurement: | ||
| + | icon: " | ||
| + | device_class: | ||
| + | state_class: | ||
| + | |||
| + | esp32_ble_tracker: | ||
| + | on_ble_advertise: | ||
| + | # Script For The First 5075 Govee Themometer/ | ||
| + | - mac_address: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | for (auto data : x.get_manufacturer_datas()) { | ||
| + | if(data.data.size()==6) { | ||
| + | int basenum = (int16_t(data.data[1]) << 16) + (int16_t(data.data[2]) << 8) + int16_t(data.data[3]); | ||
| + | bool is_negative = false; | ||
| + | if (basenum & 0x800000) { | ||
| + | is_negative = true; | ||
| + | basenum = basenum ^ 0x800000; | ||
| + | } | ||
| + | float temperature = ((basenum / 10000.0f)); | ||
| + | const float humidity = (basenum % 1000) / 10.0f; | ||
| + | const float battery_level = uint16_t(data.data[4]) / 1.0f; | ||
| + | if (is_negative) { | ||
| + | temperature = -temperature; | ||
| + | } | ||
| + | int16_t rssi=x.get_rssi(); | ||
| + | id(govee1_humidity).publish_state(humidity); | ||
| + | id(govee1_temperature).publish_state(temperature); | ||
| + | id(govee1_battery).publish_state(battery_level); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | # Script For The Second 5075 Govee Themometer/ | ||
| + | - mac_address: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | for (auto data : x.get_manufacturer_datas()) { | ||
| + | if(data.data.size()==6) { | ||
| + | int basenum = (int16_t(data.data[1]) << 16) + (int16_t(data.data[2]) << 8) + int16_t(data.data[3]); | ||
| + | bool is_negative = false; | ||
| + | if (basenum & 0x800000) { | ||
| + | is_negative = true; | ||
| + | basenum = basenum ^ 0x800000; | ||
| + | } | ||
| + | float temperature = ((basenum / 10000.0f)); | ||
| + | const float humidity = (basenum % 1000) / 10.0f; | ||
| + | const float battery_level = uint16_t(data.data[4]) / 1.0f; | ||
| + | if (is_negative) { | ||
| + | temperature = -temperature; | ||
| + | } | ||
| + | int16_t rssi=x.get_rssi(); | ||
| + | id(govee2_humidity).publish_state(humidity); | ||
| + | id(govee2_temperature).publish_state(temperature); | ||
| + | id(govee2_battery).publish_state(battery_level); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # Script For The Third 5075 Govee Themometer/ | ||
| + | - mac_address: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | for (auto data : x.get_manufacturer_datas()) { | ||
| + | if(data.data.size()==6) { | ||
| + | int basenum = (int16_t(data.data[1]) << 16) + (int16_t(data.data[2]) << 8) + int16_t(data.data[3]); | ||
| + | bool is_negative = false; | ||
| + | if (basenum & 0x800000) { | ||
| + | is_negative = true; | ||
| + | basenum = basenum ^ 0x800000; | ||
| + | } | ||
| + | float temperature = ((basenum / 10000.0f)); | ||
| + | const float humidity = (basenum % 1000) / 10.0f; | ||
| + | const float battery_level = uint16_t(data.data[4]) / 1.0f; | ||
| + | if (is_negative) { | ||
| + | temperature = -temperature; | ||
| + | } | ||
| + | int16_t rssi=x.get_rssi(); | ||
| + | id(govee3_humidity).publish_state(humidity); | ||
| + | id(govee3_temperature).publish_state(temperature); | ||
| + | id(govee3_battery).publish_state(battery_level); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # Script For The Fourth 5075 Govee Themometer/ | ||
| + | - mac_address: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | for (auto data : x.get_manufacturer_datas()) { | ||
| + | if(data.data.size()==6) { | ||
| + | int basenum = (int16_t(data.data[1]) << 16) + (int16_t(data.data[2]) << 8) + int16_t(data.data[3]); | ||
| + | bool is_negative = false; | ||
| + | if (basenum & 0x800000) { | ||
| + | is_negative = true; | ||
| + | basenum = basenum ^ 0x800000; | ||
| + | } | ||
| + | float temperature = ((basenum / 10000.0f)); | ||
| + | const float humidity = (basenum % 1000) / 10.0f; | ||
| + | const float battery_level = uint16_t(data.data[4]) / 1.0f; | ||
| + | if (is_negative) { | ||
| + | temperature = -temperature; | ||
| + | } | ||
| + | int16_t rssi=x.get_rssi(); | ||
| + | id(govee4_humidity).publish_state(humidity); | ||
| + | id(govee4_temperature).publish_state(temperature); | ||
| + | id(govee4_battery).publish_state(battery_level); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # Script For The Fifth 5075 Govee Themometer/ | ||
| + | - mac_address: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | for (auto data : x.get_manufacturer_datas()) { | ||
| + | if(data.data.size()==6) { | ||
| + | int basenum = (int16_t(data.data[1]) << 16) + (int16_t(data.data[2]) << 8) + int16_t(data.data[3]); | ||
| + | bool is_negative = false; | ||
| + | if (basenum & 0x800000) { | ||
| + | is_negative = true; | ||
| + | basenum = basenum ^ 0x800000; | ||
| + | } | ||
| + | float temperature = ((basenum / 10000.0f)); | ||
| + | const float humidity = (basenum % 1000) / 10.0f; | ||
| + | const float battery_level = uint16_t(data.data[4]) / 1.0f; | ||
| + | if (is_negative) { | ||
| + | temperature = -temperature; | ||
| + | } | ||
| + | int16_t rssi=x.get_rssi(); | ||
| + | id(govee5_humidity).publish_state(humidity); | ||
| + | id(govee5_temperature).publish_state(temperature); | ||
| + | id(govee5_battery).publish_state(battery_level); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # Script For The Sixth 5075 Govee Themometer/ | ||
| + | - mac_address: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | for (auto data : x.get_manufacturer_datas()) { | ||
| + | if(data.data.size()==6) { | ||
| + | int basenum = (int16_t(data.data[1]) << 16) + (int16_t(data.data[2]) << 8) + int16_t(data.data[3]); | ||
| + | bool is_negative = false; | ||
| + | if (basenum & 0x800000) { | ||
| + | is_negative = true; | ||
| + | basenum = basenum ^ 0x800000; | ||
| + | } | ||
| + | float temperature = ((basenum / 10000.0f)); | ||
| + | const float humidity = (basenum % 1000) / 10.0f; | ||
| + | const float battery_level = uint16_t(data.data[4]) / 1.0f; | ||
| + | if (is_negative) { | ||
| + | temperature = -temperature; | ||
| + | } | ||
| + | int16_t rssi=x.get_rssi(); | ||
| + | id(govee6_humidity).publish_state(humidity); | ||
| + | id(govee6_temperature).publish_state(temperature); | ||
| + | id(govee6_battery).publish_state(battery_level); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # Script For The Seventh 5075 Govee Themometer/ | ||
| + | - mac_address: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | for (auto data : x.get_manufacturer_datas()) { | ||
| + | if(data.data.size()==6) { | ||
| + | int basenum = (int16_t(data.data[1]) << 16) + (int16_t(data.data[2]) << 8) + int16_t(data.data[3]); | ||
| + | bool is_negative = false; | ||
| + | if (basenum & 0x800000) { | ||
| + | is_negative = true; | ||
| + | basenum = basenum ^ 0x800000; | ||
| + | } | ||
| + | float temperature = ((basenum / 10000.0f)); | ||
| + | const float humidity = (basenum % 1000) / 10.0f; | ||
| + | const float battery_level = uint16_t(data.data[4]) / 1.0f; | ||
| + | if (is_negative) { | ||
| + | temperature = -temperature; | ||
| + | } | ||
| + | int16_t rssi=x.get_rssi(); | ||
| + | id(govee7_humidity).publish_state(humidity); | ||
| + | id(govee7_temperature).publish_state(temperature); | ||
| + | id(govee7_battery).publish_state(battery_level); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # Script For The Eight 5075 Govee Themometer/ | ||
| + | - mac_address: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | for (auto data : x.get_manufacturer_datas()) { | ||
| + | if(data.data.size()==6) { | ||
| + | int basenum = (int16_t(data.data[1]) << 16) + (int16_t(data.data[2]) << 8) + int16_t(data.data[3]); | ||
| + | bool is_negative = false; | ||
| + | if (basenum & 0x800000) { | ||
| + | is_negative = true; | ||
| + | basenum = basenum ^ 0x800000; | ||
| + | } | ||
| + | float temperature = ((basenum / 10000.0f)); | ||
| + | const float humidity = (basenum % 1000) / 10.0f; | ||
| + | const float battery_level = uint16_t(data.data[4]) / 1.0f; | ||
| + | if (is_negative) { | ||
| + | temperature = -temperature; | ||
| + | } | ||
| + | int16_t rssi=x.get_rssi(); | ||
| + | id(govee8_humidity).publish_state(humidity); | ||
| + | id(govee8_temperature).publish_state(temperature); | ||
| + | id(govee8_battery).publish_state(battery_level); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | Die trickreichen Stellen waren: | ||
| + | * Das herausfinden der MAC-Adressen der Govee-Thermometer. Am besten ging es mit der Android-App [[https:// | ||
| + | * Wie man überhaupt die Werte annimmt und verrechnet. Das wird in den Posts dieser Unterhaltung gezeigt: https:// | ||
| + | * Der Umgang mit negativen Werten in der Temperatur. Auch in einigen Beiträgen des vorherigen Links zu finden. | ||
| + | * Das setzen der Felder " | ||
| ===== Weiterlesen ===== | ===== Weiterlesen ===== | ||
| Line 43: | Line 529: | ||
| * https:// | * https:// | ||
| * https:// | * https:// | ||
| + | * Programmieren mit Tasmota | ||
| + | ToDo: | ||
| + | * Sensordaten in InfluxDB schreiben: https:// | ||
| + | * Gaszähler nachbauen | ||
| + | ====== Sensoren ====== | ||
| + | Siehe [[ESP32-Sensoren|ESP32-Sensoren]]. | ||
| + | ====== Zubehör ====== | ||
| + | Es gibt auch eine Seite zu dem [[Mikrocontroller Zubehör|sonstigen Zubehör]] das ich für die Mikrocontroller habe. | ||
esp-mikrocontroller.1675766994.txt.gz · Last modified: (external edit)
