From b0aa7991f992027049b6c2622ed8f0bc01e69df6 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Sat, 5 Nov 2022 23:47:51 +0100 Subject: [PATCH] Added geigercounter and display it on epaperframe. --- esphome/epaperframe.yaml | 42 ++++++++++++++++------- esphome/geigercounter.yaml | 69 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 esphome/geigercounter.yaml diff --git a/esphome/epaperframe.yaml b/esphome/epaperframe.yaml index e47d47c..09bc28e 100644 --- a/esphome/epaperframe.yaml +++ b/esphome/epaperframe.yaml @@ -175,6 +175,10 @@ sensor: - platform: homeassistant entity_id: sensor.schlafzimmer_heimkino_power id: media_sleepingroom + + - platform: homeassistant + entity_id: sensor.radioaktive_strahlungsleistung + id: radiation text_sensor: - platform: homeassistant @@ -312,7 +316,8 @@ font: '󰴾', # mdi-transmission-tower '󰚥', # mdi-power-plug '󱈹', # mdi-desk - '󰔂' # mdi-television + '󰔂', # mdi-television + '󰐼' # mdi-radiation ] - file: 'fonts/materialdesignicons-webfont.ttf' @@ -390,6 +395,7 @@ display: float outdoor_temp = id(temp_outdoor).state; int outdoor_humid = int(id(humid_outdoor).state); float air_pressure = id(airpressure).state; + float outdoor_radiation = id(radiation).state; float livingroom_temp = id(temp_livingroom).state; int livingroom_humid = int(id(humid_livingroom).state); int livingroom_pm25 = int(id(pm25_livingroom).state); @@ -413,31 +419,41 @@ display: /* C1024 logo */ it.image(10 , 37, id(c1024_logo)); - it.print(10, 115, id(mdi_small), TextAlign::BASELINE_LEFT, "󰊚"); // air pressure icon - it.print(375, 75, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer icon - it.print(375, 115, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent icon + it.print(10, 120, id(mdi_small), TextAlign::BASELINE_LEFT, "󰊚"); // air pressure icon + it.print(375, 80, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer icon + it.print(375, 120, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent icon + it.print(95, 80, id(mdi_small), TextAlign::BASELINE_LEFT, "󰐼"); // radioactive icon - if(outdoor_temp > -100 && outdoor_temp < 100) { - it.printf(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", outdoor_temp); + if(outdoor_radiation > 0 && outdoor_radiation < 100) { + it.printf(200, 80, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.2f", outdoor_radiation); + it.print(205, 80, id(sensor_unit), TextAlign::BASELINE_LEFT, "µS/h"); } else { - it.print(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC"); + it.print(200, 80, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - "); + it.print(205, 80, id(sensor_unit), TextAlign::BASELINE_LEFT, "µS/h"); + } + + if(outdoor_temp > -100 && outdoor_temp < 100) { + it.printf(357, 80, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", outdoor_temp); + } + else { + it.print(357, 80, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC"); } if(outdoor_humid >=0 && outdoor_humid <= 100) { - it.printf(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", outdoor_humid); + it.printf(357, 120, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", outdoor_humid); } else { - it.print(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %"); + it.print(357, 120, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %"); } if(air_pressure < 1200 && air_pressure >=800) { - it.printf(220, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%4.1f", air_pressure); - it.print(225, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "hPa"); + it.printf(220, 120, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%4.1f", air_pressure); + it.print(225, 120, id(sensor_unit), TextAlign::BASELINE_LEFT, "hPa"); } else { - it.print(220, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- "); - it.print(225, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "hPa"); + it.print(220, 120, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- "); + it.print(225, 120, id(sensor_unit), TextAlign::BASELINE_LEFT, "hPa"); } diff --git a/esphome/geigercounter.yaml b/esphome/geigercounter.yaml new file mode 100644 index 0000000..dd22322 --- /dev/null +++ b/esphome/geigercounter.yaml @@ -0,0 +1,69 @@ +esphome: + name: geigercounter + platform: ESP32 + board: nodemcu-32s + +wifi: + ssid: "Voltage-legacy" + password: !secret voltage_legacy_psk + use_address: geigercounter.home + power_save_mode: high + fast_connect: on + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Geigercounter Fallback Hotspot" + password: !secret fallback_psk + +captive_portal: + +# Enable logging +logger: + +# Enable Home Assistant API +api: + password: !secret api + encryption: + key: !secret apikey + +ota: + password: !secret ota + +spi: + clk_pin: 16 + mosi_pin: 19 + +display: + - platform: max7219 + cs_pin: 5 + num_chips: 1 + lambda: |- + it.print("01234567"); + +# Here we calc and include to the firmware a power and doze values of ionizing radiation as sensor outputs +sensor: + - platform: pulse_counter + pin: 23 + unit_of_measurement: "µSv/h" + name: "Radioaktive Strahlungsleistung" + icon: "mdi:radioactive" + count_mode: + rising_edge: DISABLE + falling_edge: INCREMENT + update_interval: 60s + accuracy_decimals: 3 + id: dose_meter + filters: + - sliding_window_moving_average: # 5-minutes moving average (MA5) here + window_size: 5 + send_every: 1 + - multiply: 0.0054 # SBM20 tube conversion factor of pulses into mkSv/Hour + - platform: integration + name: "Gesamte Strahlungsdosis" + unit_of_measurement: "µSv" + sensor: dose_meter # link entity id to the pulse_counter values above + icon: "mdi:radioactive" + accuracy_decimals: 5 + time_unit: min # integrate values every next minute + filters: + - multiply: 0.00009 # obtained doze (from mkSv/hour into mkSv/minute) conversion factor: 0.0054 / 60 minutes = 0.00009; so pulses * 0.00009 = doze every next minute, mkSv.