esphome: name: m16v2 esp32: board: esp32dev framework: type: arduino ota: - platform: esphome external_components: - source: type: git url: https://github.com/hzkincony/esphome-zmpt101b ref: v2.1.0 # Enable logging logger: # Enable Home Assistant API api: encryption: key: "D69bY/GXlmjYkovak6WIhgmbOH8vwyqvMxIHBriYoaY=" # Ethernet Configuration ethernet: type: LAN8720 mdc_pin: GPIO23 mdio_pin: GPIO18 clk_mode: GPIO17_OUT phy_addr: 0 use_address: 192.168.10.14 # Wifi Configuration # wifi: # ssid: xxxx # password: xxxx i2c: sda: 4 scl: 5 scan: true id: bus_a cd74hc4067: - id: cd74hc4067_1 pin_s0: 32 pin_s1: 33 pin_s2: 13 pin_s3: 16 web_server: port: 80 font: - file: "gfonts://Roboto" id: roboto size: 16 display: - platform: ssd1306_i2c model: "SSD1306 128x64" address: 0x3C lambda: |- it.printf(0, 0, id(roboto), "AC 1: %.1fV", id(voltage_1).state); it.printf(0, 20, id(roboto), "CT 1: %.1fA", id(CT_1_Current).state); it.printf(0, 40, id(roboto), "192.168.10.14"); sensor: - platform: adc pin: 34 id: adc34 update_interval: never attenuation: 12db # L2 Voltage ADC # - platform: adc # pin: 36 # id: adc36 # update_interval: never # attenuation: 12db # L3 Voltage ADC # - platform: adc # pin: 39 # id: adc39 # update_interval: never # attenuation: 12db - platform: zmpt101b name: "L1 Voltage" # name: "m16--AI zmpt 34" sensor: adc34 id: voltage_1 sensitivity: 538 # - platform: zmpt101b # name: "L2 Voltage" # # name: "m16--AI zmpt 36" # sensor: adc36 # id: voltage_2 # sensitivity: 538 # - platform: zmpt101b # name: "L3 Voltage" # # name: "m16--AI zmpt 39" # sensor: adc39 # id: voltage_3 # sensitivity: 538 - platform: sht3xd temperature: name: "Temperature" id: temperature humidity: name: "Humidity" id: humidity address: 0x44 update_interval: 5s # Current sensing ADC - platform: adc pin: 35 id: adc35 update_interval: never attenuation: 12db - platform: cd74hc4067 id: ai1 number: 0 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai2 number: 1 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai3 number: 2 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai4 number: 3 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai5 number: 4 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai6 number: 5 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai7 number: 6 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai8 number: 7 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai9 number: 8 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai10 number: 9 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai11 number: 10 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai12 number: 11 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai13 number: 12 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai14 number: 13 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai15 number: 14 sensor: adc35 update_interval: never - platform: cd74hc4067 id: ai16 number: 15 sensor: adc35 update_interval: never - platform: ct_clamp sensor: ai1 id: CT_1_Current name: "CT 1 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.290 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: template id: power1 name: "CT 1 Power" lambda: return id(CT_1_Current).state * id(voltage_1).state; device_class: power unit_of_measurement: 'W' update_interval: 5s - platform: total_daily_energy name: "CT 1 Total Daily Energy" power_id: power1 filters: - multiply: 0.001 unit_of_measurement: kWh accuracy_decimals: 3 icon: mdi:clock-alert device_class: energy - platform: ct_clamp sensor: ai2 id: CT_2_Current name: "CT 2 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.290 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai3 id: CT_3_Current name: "CT 3 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.293 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai4 id: CT_4_Current name: "CT 4 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.292 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai5 id: CT_5_Current name: "CT 5 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.293 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai6 id: CT_6_Current name: "CT 6 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.293 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai7 id: CT_7_Current name: "CT 7 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.289 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai8 id: CT_8_Current name: "CT 8 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.294 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai9 id: CT_9_Current name: "CT 9 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.290 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai10 id: CT_10_Current name: "CT 10 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.291 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai11 id: CT_11_Current name: "CT 11 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.290 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai12 id: CT_12_Current name: "CT 12 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.289 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai13 id: CT_13_Current name: "CT 13 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.290 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai14 id: CT_14_Current name: "CT 14 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.096 -> 2.95 - 0.290 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.1) return 0.0; else return x; - platform: ct_clamp sensor: ai15 id: CT_15_Current name: "CT 15 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.040 -> 2.95 # 50:1 CT clamp - 0.119 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.5) return 0.0; else return x; - platform: ct_clamp sensor: ai16 id: CT_16_Current name: "CT 16 Current" update_interval: never sample_duration: 250ms filters: - calibrate_linear: - 0.003 -> 0 - 0.031 -> 2.95 # 60:1 CT clamp - 0.100 -> 9.0 # - median: # window_size: 3 # send_every: 1 # send_first_at: 1 - lambda: if (x < 0.5) return 0.0; else return x; script: - id: scan_ct_channels mode: single then: # CH1 - component.update: ai1 - delay: 50ms - component.update: CT_1_Current - delay: 450ms # CH2 - component.update: ai2 - delay: 50ms - component.update: CT_2_Current - delay: 450ms # CH3 - component.update: ai3 - delay: 50ms - component.update: CT_3_Current - delay: 450ms # CH4 - component.update: ai4 - delay: 50ms - component.update: CT_4_Current - delay: 450ms # CH5 - component.update: ai5 - delay: 50ms - component.update: CT_5_Current - delay: 450ms # CH6 - component.update: ai6 - delay: 50ms - component.update: CT_6_Current - delay: 450ms # CH7 - component.update: ai7 - delay: 50ms - component.update: CT_7_Current - delay: 450ms # CH8 - component.update: ai8 - delay: 50ms - component.update: CT_8_Current - delay: 450ms # CH9 - component.update: ai9 - delay: 50ms - component.update: CT_9_Current - delay: 450ms # CH10 - component.update: ai10 - delay: 50ms - component.update: CT_10_Current - delay: 450ms # CH11 - component.update: ai11 - delay: 50ms - component.update: CT_11_Current - delay: 450ms # CH12 - component.update: ai12 - delay: 50ms - component.update: CT_12_Current - delay: 450ms # CH13 - component.update: ai13 - delay: 50ms - component.update: CT_13_Current - delay: 450ms # CH14 - component.update: ai14 - delay: 50ms - component.update: CT_14_Current - delay: 450ms # CH15 - component.update: ai15 - delay: 50ms - component.update: CT_15_Current - delay: 450ms # CH16 - component.update: ai16 - delay: 50ms - component.update: CT_16_Current - delay: 450ms interval: - interval: 20s then: - script.execute: scan_ct_channels time: - platform: sntp id: my_time # Calibration Steps for Current Meters: # https://www.kincony.com/forum/showthread.php?tid=3764&pid=10598#pid10598 # 1. when AC current is 0A, then see your LOG what's RAW value "X". # 2. use a large power AC load, use multi meter to test AC current value "Z". then see your LOG what's RAW value "Y". # use these two value make the map. # - X -> 0 # - Y -> Z