Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| esphome:watermeter [2023/12/11 08:01] – created photonicsguy | esphome:watermeter [2023/12/20 07:30] (current) – photonicsguy | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ===== Hardware ===== | ===== Hardware ===== | ||
| Using a ESP32 with QMC5883L compass module. TBD | Using a ESP32 with QMC5883L compass module. TBD | ||
| - | |||
| ===== Accuracy ===== | ===== Accuracy ===== | ||
| - | TBD | + | Quite accurate, each interval (max to min to max) from the water meter appears to be 32.5ml, this was confirmed over the course of a few days and about 1.6 m³ of water (about 49 thousand intervals). |
| + | {{ : | ||
| + | |||
| ===== ESPhome yaml ===== | ===== ESPhome yaml ===== | ||
| - | TBD | + | This is still a work in progress, and will need some customization for your specific installation (such as defining which magnetic axis to monitor and thresholds). |
| + | |||
| + | |||
| + | <file yaml watermeter.yaml> | ||
| + | esphome: | ||
| + | name: WaterMeter | ||
| + | friendly_name: | ||
| + | project: | ||
| + | name: " | ||
| + | version: " | ||
| + | on_boot: | ||
| + | priority: 300 | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | id(sample)=id(total_pulses); | ||
| + | |||
| + | esp32: | ||
| + | board: esp32dev | ||
| + | framework: | ||
| + | type: arduino | ||
| + | version: recommended | ||
| + | |||
| + | # Don't use VERBOSE or DEBUG logging when Hall sensor has fast updates | ||
| + | logger: | ||
| + | level: WARN | ||
| + | |||
| + | # Enable Home Assistant API | ||
| + | api: | ||
| + | encryption: | ||
| + | key: !secret ha_key | ||
| + | |||
| + | ota: | ||
| + | password: !secret ota_passwd | ||
| + | |||
| + | wifi: | ||
| + | ssid: !secret wifi_ssid | ||
| + | password: !secret wifi_password | ||
| + | |||
| + | i2c: | ||
| + | - id: bus_a | ||
| + | sda: 4 | ||
| + | scl: 15 | ||
| + | frequency: 800kHz | ||
| + | scan: true | ||
| + | |||
| + | text_sensor: | ||
| + | - platform: wifi_info | ||
| + | ip_address: | ||
| + | name: IP Address | ||
| + | entity_category: | ||
| + | |||
| + | switch: | ||
| + | - platform: restart | ||
| + | name: " | ||
| + | - platform: template | ||
| + | name: "Reset usage" | ||
| + | id: resetusage | ||
| + | optimistic: false | ||
| + | icon: mdi: | ||
| + | restore_mode: | ||
| + | turn_on_action: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | id(sample)=id(total_pulses); | ||
| + | id(wateruse).publish_state((id(total_pulses)-id(sample)) * 0.01 * id(offset)); | ||
| + | |||
| + | |||
| + | number: | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: minVal | ||
| + | optimistic: true | ||
| + | restore_value: | ||
| + | entity_category: | ||
| + | initial_value: | ||
| + | min_value: -200 | ||
| + | max_value: 200 | ||
| + | step: 5 | ||
| + | unit_of_measurement: | ||
| + | set_action: | ||
| + | - lambda: id(pulse).set_lower_threshold(x); | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: maxVal | ||
| + | optimistic: true | ||
| + | restore_value: | ||
| + | entity_category: | ||
| + | initial_value: | ||
| + | min_value: -200 | ||
| + | max_value: 200 | ||
| + | unit_of_measurement: | ||
| + | step: 5 | ||
| + | set_action: | ||
| + | - lambda: id(pulse).set_upper_threshold(x); | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: minVal2 | ||
| + | optimistic: true | ||
| + | restore_value: | ||
| + | entity_category: | ||
| + | initial_value: | ||
| + | min_value: -200 | ||
| + | max_value: 200 | ||
| + | step: 5 | ||
| + | unit_of_measurement: | ||
| + | set_action: | ||
| + | - lambda: id(pulse2).set_lower_threshold(x); | ||
| + | - platform: template | ||
| + | name: " | ||
| + | id: maxVal2 | ||
| + | optimistic: true | ||
| + | restore_value: | ||
| + | entity_category: | ||
| + | initial_value: | ||
| + | min_value: -200 | ||
| + | max_value: 200 | ||
| + | unit_of_measurement: | ||
| + | step: 5 | ||
| + | set_action: | ||
| + | - lambda: id(pulse2).set_upper_threshold(x); | ||
| + | |||
| + | |||
| + | globals: | ||
| + | - id: total_pulses | ||
| + | type: int | ||
| + | restore_value: | ||
| + | initial_value: | ||
| + | - id: sample | ||
| + | type: int | ||
| + | restore_value: | ||
| + | initial_value: | ||
| + | - id: offset | ||
| + | type: float | ||
| + | restore_value: | ||
| + | initial_value: | ||
| + | |||
| + | sensor: | ||
| + | - platform: wifi_signal | ||
| + | name: " | ||
| + | id: rssi_db | ||
| + | filters: | ||
| + | - delta: 2 | ||
| + | - throttle: 300s | ||
| + | entity_category: | ||
| + | - platform: qmc5883l | ||
| + | i2c_id: bus_a | ||
| + | address: 0x0D | ||
| + | field_strength_x: | ||
| + | name: "Field Strength X" | ||
| + | id: fsx | ||
| + | internal: true | ||
| + | range: 200uT | ||
| + | oversampling: | ||
| + | update_interval: | ||
| + | - platform: template | ||
| + | name: "Water Consumption new" | ||
| + | id: waterconsumption3 | ||
| + | device_class: | ||
| + | unit_of_measurement: | ||
| + | state_class: | ||
| + | icon: " | ||
| + | accuracy_decimals: | ||
| + | lambda: |- | ||
| + | return id(total_pulses) * 0.00001 * id(offset); | ||
| + | - platform: template | ||
| + | name: "Water usage" | ||
| + | id: wateruse | ||
| + | device_class: | ||
| + | unit_of_measurement: | ||
| + | state_class: | ||
| + | icon: " | ||
| + | accuracy_decimals: | ||
| + | lambda: |- | ||
| + | return (id(total_pulses)-id(sample)) * 0.01 * id(offset); | ||
| + | - platform: template | ||
| + | name: " | ||
| + | unit_of_measurement: | ||
| + | id: watercounter | ||
| + | lambda: |- | ||
| + | return id(total_pulses); | ||
| + | binary_sensor: | ||
| + | - platform: analog_threshold | ||
| + | name: " | ||
| + | id: pulse | ||
| + | #internal: True | ||
| + | sensor_id: fsx | ||
| + | threshold: | ||
| + | upper: 90 | ||
| + | lower: 80 | ||
| + | on_state: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | id(total_pulses) += 1; | ||
| + | id(waterconsumption3).publish_state(id(total_pulses) * 0.00001 * id(offset)); | ||
| + | id(wateruse).publish_state((id(total_pulses)-id(sample)) * 0.01 * id(offset)); | ||
| + | id(watercounter).publish_state(id(total_pulses)); | ||
| + | - platform: analog_threshold | ||
| + | name: " | ||
| + | id: pulse2 | ||
| + | sensor_id: fsx | ||
| + | threshold: | ||
| + | upper: 60 | ||
| + | lower: 40 | ||
| + | on_state: | ||
| + | then: | ||
| + | - lambda: |- | ||
| + | id(total_pulses) += 1; | ||
| + | id(waterconsumption3).publish_state(id(total_pulses) * 0.00001 * id(offset)); | ||
| + | id(wateruse).publish_state((id(total_pulses)-id(sample)) * 0.01 * id(offset)); | ||
| + | id(watercounter).publish_state(id(total_pulses)); | ||
| + | </ | ||