Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KC868-M16v2 configure yaml for ESPhome
#1
   
   
before you config ymal file, please upload zmpt101b folder to home assistant disk:
   
unzip files, 3 files upload to disk folder as image.

.zip   zmpt101b.zip (Size: 1.83 KB / Downloads: 616)



.txt   KC868-M16v2-ESPHome.txt (Size: 9.55 KB / Downloads: 539)
esphome:
  name: m16
  includes:
    - zmpt101b/ZMPT101B.h
    - zmpt101b/ZMPT101B.cpp
    - zmpt101b/zmpt101b_custom_sensor.h

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "D69bY/GXlmjYkovak6WIhgmbOH8vwyqvMxIHBriYoaY="


# Example configuration entry
ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0

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: 20

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(roboto), "T: %.1f°C", id(temperature).state);
      it.printf(0, 20, id(roboto), "H: %.1f%%", id(humidity).state);
      it.printf(0, 40, id(roboto), "AC:%.1fV", id(voltage_2).state);

# Example configuration entry
sensor:
  - platform: custom
    lambda: |-
      auto my_sensor34 = new ZMPT101BSensor(34);
      auto my_sensor36 = new ZMPT101BSensor(36);
      auto my_sensor39 = new ZMPT101BSensor(39);
      App.register_component(my_sensor34);
      App.register_component(my_sensor36);
      App.register_component(my_sensor39);
      return {my_sensor34, my_sensor36, my_sensor39};
    sensors:
      - name: "m16--AI zmpt 34"
        id: voltage_1
        unit_of_measurement: V
        accuracy_decimals: 1
        state_class: "measurement"
      - name: "m16--AI zmpt 36"
        id: voltage_2
        unit_of_measurement: V
        accuracy_decimals: 1
        state_class: "measurement"
      - name: "m16--AI zmpt 39"
        id: voltage_3
        unit_of_measurement: V
        accuracy_decimals: 1
        state_class: "measurement"

  - platform: sht3xd
    temperature:
      name: "sht Temperature"
      id: temperature
    humidity:
      name: "sht Humidity"
      id: humidity
    address: 0x44
    update_interval: 5s

  - platform: adc
    pin: 35
    id: adc35
    update_interval: never
    attenuation: 11db

  # - platform: adc
  #  name: "m16--AI-1"
  #  pin: 36
  #  id: adc36
  #  update_interval: 60s
  #  attenuation: 11db

  # - platform: adc
  #  pin: 34
  #  name: "m16--AI-2"
  #  id: adc34
  #  update_interval: 60s
  #  attenuation: 11db

  # - platform: adc
  #  pin: 39
  #  name: "m16--AI-3"
  #  id: adc39
  #  update_interval: 60s
  #  attenuation: 11db




  - platform: cd74hc4067
    id: ai1
    number: 0
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai2
    number: 1
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai3
    number: 2
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai4
    number: 3
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai5
    number: 4
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai6
    number: 5
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai7
    number: 6
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai8
    number: 7
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai9
    number: 8
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai10
    number: 9
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai11
    number: 10
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai12
    number: 11
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai13
    number: 12
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai14
    number: 13
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai15
    number: 14
    sensor: adc35
    update_interval: 60s

  - platform: cd74hc4067
    id: ai16
    number: 15
    sensor: adc35
    update_interval: 60s


  - platform: ct_clamp
    sensor: ai1
    id: Measured_Current_1
    name: "Measured Current-1"
    update_interval: 5s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0.0034 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: template
    id: power1
    name: "power1"
    lambda: return id(Measured_Current_1).state * id(voltage_1).state;
    device_class: power
    unit_of_measurement: 'W'
    update_interval: 60s

  - platform: total_daily_energy
    name: "Total Daily Energy1"
    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
    name: "Measured Current-2"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai3
    name: "Measured Current-3"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai4
    name: "Measured Current-4"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai5
    name: "Measured Current-5"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai6
    name: "Measured Current-6"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai7
    name: "Measured Current-7"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai8
    name: "Measured Current-8"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai9
    name: "Measured Current-9"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai10
    name: "Measured Current-10"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai11
    name: "Measured Current-11"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai12
    name: "Measured Current-12"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai13
    name: "Measured Current-13"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai14
    name: "Measured Current-14"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai15
    name: "Measured Current-15"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

  - platform: ct_clamp
    sensor: ai16
    name: "Measured Current-16"
    update_interval: 60s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0 -> 0
          # Known load: 4.0A
          # Value shown in logs: 0.1333A
          - 0.31749 -> 8.95608

time:
  - platform: sntp
    id: my_time
Reply
#2
Hi,

Today I received my KC-868-M16-V2.1

I copied the files to the correct folder and created an yaml definition file for the board as described in this post.

During the compile of the yaml file //i get the errors below in the screenshot, any help is more than welcome, because I'm out of options.


Attached Files Image(s)
   
Reply
#3
take a photo of your component folder and file structure.
Reply
#4
(02-28-2024, 09:47 PM)admin Wrote: take a photo of your component folder and file structure.

I guess you mean this?


Attached Files Image(s)
   
Reply
#5
Any news on this issue?
Reply
#6
do you install your home assistant on a raspberry pi? i suggest you delete your ESPhome, re install it.
it's correct as your photo about fold and files.
Reply
#7
My home assistant is running on an ODROID N2+ and I have tried to reinstall ESPhome, but without any luck.
Reply
#8
the easiest way, you can install ESPHome on your computer or raspberry pi (not use ODROID N2 hardware), compile these code directly to test it. Because all our customers work well, so i think maybe some environment issue.
Reply
#9
Hello,
I bought 3 KC868-M16V2.1 boards from you, and I successfully connected them to Home Assistant.
I want to measure power and energy for three-phase 5 devices. How can I adjust the YAML template for this purpose?
Attached is a table showing how I want to connect the terminals for these devices.

Thanks


Attached Files Image(s)
   
Reply
#10
sure ,you can detect it. just chose correctly CT clamp sensors range.
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)