From cd327fc6287d1c7db0a4ac7cb1a5d0086aa15cab Mon Sep 17 00:00:00 2001 From: Tizian Haider Date: Sun, 17 May 2026 16:25:43 +0200 Subject: [PATCH] add sensors via digital analog converter; --- README.md | 12 ++++++++ esphome_b4_controller.yaml | 59 ++++++++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 21 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..5bfda4e --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# Home Assistant +## Integrations +### ESP32Home - Hochbeet +- B4 Controller Config: esphome_b4_controller.yaml +#### Config Flashing +- in terminal swicht python environment
+```source ~/b4/bin/activate``` +- start esphome device builder
+```esphome-device-builder ~/esphome-configs``` +- access [ESPHome - Device Builder](http://localhost:6052/) +- connect controller with USB-C cable and choose serial port 'USB JTAG' +- sometimes after flashing new config controller have to repowered \ No newline at end of file diff --git a/esphome_b4_controller.yaml b/esphome_b4_controller.yaml index 95782b6..dd28a15 100644 --- a/esphome_b4_controller.yaml +++ b/esphome_b4_controller.yaml @@ -8,6 +8,7 @@ esp32: type: arduino logger: + hardware_uart: USB_SERIAL_JTAG api: encryption: @@ -26,17 +27,28 @@ wifi: captive_portal: i2c: - - id: bus_a + - id: bus_relay sda: 8 scl: 18 scan: true frequency: 400kHz + - id: bus_ads + sda: 13 + scl: 14 + scan: true + frequency: 100kHz + pcf8574: - id: pcf8574_hub_out_1 - i2c_id: bus_a + i2c_id: bus_relay address: 0x24 +ads1115: + - id: ads1115_hub + i2c_id: bus_ads + address: 0x48 + switch: - platform: gpio name: "Bewässerung Hochbeet 1" @@ -46,6 +58,7 @@ switch: number: 4 mode: OUTPUT inverted: true + restore_mode: ALWAYS_OFF icon: "mdi:sprinkler-variant" - platform: gpio @@ -56,6 +69,7 @@ switch: number: 5 mode: OUTPUT inverted: true + restore_mode: ALWAYS_OFF icon: "mdi:sprinkler-variant" - platform: gpio @@ -66,6 +80,7 @@ switch: number: 6 mode: OUTPUT inverted: true + restore_mode: ALWAYS_OFF icon: "mdi:sprinkler-variant" - platform: gpio @@ -76,6 +91,7 @@ switch: number: 7 mode: OUTPUT inverted: true + restore_mode: ALWAYS_OFF icon: "mdi:sprinkler-variant" binary_sensor: @@ -127,53 +143,54 @@ binary_sensor: - delayed_on: 10ms icon: "mdi:water-opacity" -ads1115: - - address: 0x48 - sensor: - platform: ads1115 + ads1115_id: ads1115_hub multiplexer: A0_GND - gain: 6.144 + gain: 4.096 resolution: 16_BITS name: "Feuchtigkeitsmessung V Hochbeet 1" id: b4_sensor1 - update_interval: 5s + update_interval: 2s unit_of_measurement: "V" accuracy_decimals: 3 state_class: measurement icon: "mdi:flash" - platform: ads1115 + ads1115_id: ads1115_hub multiplexer: A1_GND - gain: 6.144 + gain: 4.096 resolution: 16_BITS name: "Feuchtigkeitsmessung V Hochbeet 2" id: b4_sensor2 - update_interval: 5s + update_interval: 2s unit_of_measurement: "V" accuracy_decimals: 3 state_class: measurement icon: "mdi:flash" - platform: ads1115 + ads1115_id: ads1115_hub multiplexer: A2_GND - gain: 6.144 + gain: 4.096 resolution: 16_BITS name: "Feuchtigkeitsmessung V Hochbeet 3" id: b4_sensor3 - update_interval: 5s + update_interval: 2s unit_of_measurement: "V" accuracy_decimals: 3 state_class: measurement icon: "mdi:flash" - platform: ads1115 + ads1115_id: ads1115_hub multiplexer: A3_GND - gain: 6.144 + gain: 4.096 resolution: 16_BITS name: "Feuchtigkeitsmessung V Hochbeet 4" id: b4_sensor4 - update_interval: 5s + update_interval: 2s unit_of_measurement: "V" accuracy_decimals: 3 state_class: measurement @@ -186,14 +203,14 @@ sensor: accuracy_decimals: 0 device_class: humidity state_class: measurement - update_interval: 5s + update_interval: 2s icon: "mdi:water-percent" lambda: |- const float wet_voltage = 1.20; const float dry_voltage = 2.70; float v = id(b4_sensor1).state; if (isnan(v)) return NAN; - float p = (dry_voltage - v) * 100.0 / (dry_voltage - wet_voltage); + float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage); if (p < 0) p = 0; if (p > 100) p = 100; return p; @@ -205,14 +222,14 @@ sensor: accuracy_decimals: 0 device_class: humidity state_class: measurement - update_interval: 5s + update_interval: 2s icon: "mdi:water-percent" lambda: |- const float wet_voltage = 1.20; const float dry_voltage = 2.70; float v = id(b4_sensor2).state; if (isnan(v)) return NAN; - float p = (dry_voltage - v) * 100.0 / (dry_voltage - wet_voltage); + float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage); if (p < 0) p = 0; if (p > 100) p = 100; return p; @@ -224,14 +241,14 @@ sensor: accuracy_decimals: 0 device_class: humidity state_class: measurement - update_interval: 5s + update_interval: 2s icon: "mdi:water-percent" lambda: |- const float wet_voltage = 1.20; const float dry_voltage = 2.70; float v = id(b4_sensor3).state; if (isnan(v)) return NAN; - float p = (dry_voltage - v) * 100.0 / (dry_voltage - wet_voltage); + float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage); if (p < 0) p = 0; if (p > 100) p = 100; return p; @@ -243,14 +260,14 @@ sensor: accuracy_decimals: 0 device_class: humidity state_class: measurement - update_interval: 5s + update_interval: 2s icon: "mdi:water-percent" lambda: |- const float wet_voltage = 1.20; const float dry_voltage = 2.70; float v = id(b4_sensor4).state; if (isnan(v)) return NAN; - float p = (dry_voltage - v) * 100.0 / (dry_voltage - wet_voltage); + float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage); if (p < 0) p = 0; if (p > 100) p = 100; return p;