Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KC868-M16v2 configure yaml for ESPhome
it showed "adc1 is already in use", please check whether is redefined.
Reply
Can I create a new "Total Daily Energy2" entity on my M16 composed of only some of the connected sensors?
Can anybody direct me on where to start?

Thank you
Reply
(09-02-2025, 11:34 AM)admin Wrote: it showed "adc1 is already in use", please check whether is redefined.

Look, this is the code you provided, 1:1. the component adc1 is not even defined, it is definitely part of the library you generate on Git.
I need help please!
Reply
Hello can you help me with these errors:  
INFO Compiling app...
Processing 1n-energija (board: esp32dev; framework: arduino; platform: https://github.com/pioarduino/platform-e...ssif32.zip)
--------------------------------------------------------------------------------
INFO Package configuration completed successfully
INFO Package configuration completed successfully
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
- framework-arduinoespressif32 @ 3.2.1
- framework-arduinoespressif32-libs @ 5.4.0+sha.858a988d6e
- tool-esptoolpy @ 5.0.2
- tool-mklittlefs @ 3.2.0
- toolchain-xtensa-esp-elf @ 14.2.0+20241119
Dependency Graph
|-- Networking @ 3.2.1
|-- AsyncTCP @ 3.4.5
|-- WiFi @ 3.2.1
|-- FS @ 3.2.1
|-- Update @ 3.2.1
|-- ESPAsyncWebServer @ 3.7.10
|-- ESPmDNS @ 3.2.1
|-- noise-c @ 0.1.10
|-- Wire @ 3.2.1
|-- ArduinoJson @ 7.4.2
Compiling .pioenvs/1n-energija/src/ZMPT101B.cpp.o
Compiling .pioenvs/1n-energija/src/esphome/components/display/display_buffer.cpp.o
Compiling .pioenvs/1n-energija/src/esphome/components/display/rect.cpp.o
Compiling .pioenvs/1n-energija/src/esphome/components/esp32/core.cpp.o
src/ZMPT101B.cpp:9:6: error: redefinition of 'void esphome::zmpt101b::ZMPT101BSensor:Confusedetup()'
    9 | void ZMPT101BSensor:Confusedetup() {
      |      ^~~~~~~~~~~~~~
In file included from src/ZMPT101B.cpp:1:
src/zmpt101b_custom_sensor.h:23:8: note: 'virtual void esphome::zmpt101b::ZMPT101BSensor:Confusedetup()' previously defined here
  23 |  void setup() override {
      |        ^~~~~
src/ZMPT101B.cpp:14:6: error: redefinition of 'void esphome::zmpt101b::ZMPT101BSensor::update()'
  14 | void ZMPT101BSensor::update() {
      |      ^~~~~~~~~~~~~~
src/zmpt101b_custom_sensor.h:28:8: note: 'virtual void esphome::zmpt101b::ZMPT101BSensor::update()' previously defined here
  28 |  void update() override {
      |        ^~~~~~
*** [.pioenvs/1n-energija/src/ZMPT101B.cpp.o] Error 1
========================= [FAILED] Took 26.30 seconds =========================
Reply
It looks like there are actually two different issues here:

1) adc_oneshot_new_unit(98): adc1 is already in use
This happens because the YAML is mixing both the external zmpt101b component (from KinCony repo) and ESPHome’s own adc platform sensors on ADC1 pins (GPIO34/35/36/39 with multiplexer on ADC35).
In Arduino-ESP32 3.x, the oneshot driver initializes ADC1, and the custom zmpt101b component also tries to initialize it – which causes a conflict.

How to solve:

Use only one ADC implementation. Either:

A) Drop the external zmpt101b component and read the ZMPT sensors with ESPHome’s adc platform (then apply filters/templates for RMS and scaling), or

B) Keep the external zmpt101b, but remove the ESPHome adc sensor on ADC35 with the multiplexer. Don’t mix both.

As a temporary workaround, you can pin Arduino core back to 2.0.x in platformio_options, but the clean fix is to unify the ADC handling.

2) Compilation error (redefinition of ... ZMPT101BSensor:Confusedetup() / update())
This comes from having two definitions of the same class functions: src/ZMPT101B.cpp and the header src/zmpt101b_custom_sensor.h (which already implements setup()/update() inline).
Solution: remove ZMPT101B.cpp or change the header to only contain declarations (move implementation out), so that each function is only defined once.

Summary:
The YAML on page 10 mixes zmpt101b and adc on the same ADC1, which causes the runtime error. The compilation error on page 11 is due to duplicate definitions in the custom component files. Cleaning up so that only one component “owns” ADC1 – and ensuring only one implementation of each function – should fix both problems.
Reply
(08-25-2025, 04:50 PM)alexnino881 Wrote:
(03-06-2024, 11:39 AM)admin Wrote: 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.
i was able to figure it it out, it works well on both wifi and ethernet. but the issue now is that am having the mcu crashing when i add SD card library. it seems to be hainh confict with the ethernet. any solution to this or a sample code with ethernet and SD card together?

thansk in advance


dears,

am using KC868-a16v3, and i have a webserver project that uses both wifi and Ethernet. i have tried every library to make it work, still it's not working. Can I get some advice on which library works and a sample code where i can work with to fix the issue? i started with esp32-eth01, which was working perfectly well, and i migrated to kc868-a16v3 and was stuck with no progress for weeks.

thansk in advance
Reply
(09-06-2025, 10:44 PM)hl-no Wrote: It looks like there are actually two different issues here:

1) adc_oneshot_new_unit(98): adc1 is already in use
This happens because the YAML is mixing both the external zmpt101b component (from KinCony repo) and ESPHome’s own adc platform sensors on ADC1 pins (GPIO34/35/36/39 with multiplexer on ADC35).
In Arduino-ESP32 3.x, the oneshot driver initializes ADC1, and the custom zmpt101b component also tries to initialize it – which causes a conflict.

How to solve:

Use only one ADC implementation. Either:

A) Drop the external zmpt101b component and read the ZMPT sensors with ESPHome’s adc platform (then apply filters/templates for RMS and scaling), or

B) Keep the external zmpt101b, but remove the ESPHome adc sensor on ADC35 with the multiplexer. Don’t mix both.

As a temporary workaround, you can pin Arduino core back to 2.0.x in platformio_options, but the clean fix is to unify the ADC handling.

2) Compilation error (redefinition of ... ZMPT101BSensor:Confusedetup() / update())
This comes from having two definitions of the same class functions: src/ZMPT101B.cpp and the header src/zmpt101b_custom_sensor.h (which already implements setup()/update() inline).
Solution: remove ZMPT101B.cpp or change the header to only contain declarations (move implementation out), so that each function is only defined once.

Summary:
The YAML on page 10 mixes zmpt101b and adc on the same ADC1, which causes the runtime error. The compilation error on page 11 is due to duplicate definitions in the custom component files. Cleaning up so that only one component “owns” ADC1 – and ensuring only one implementation of each function – should fix both problems.

Hello, ok but if I'm using the ESPHome ADC component I'm not able to apply the correct filters. Can you please help me with that? Do you have a proper config file?
Reply
After some assistance please with getting my 868-M16-V2.1 board at least connected/visible in HA. Have read through most of this forum and seems a regular issue people had was updates to ESP making the sample YAML file outdated. I can connect my board. Prep for use, and connect all OK ... and have pulled the newest sample YAML file from here, but still errors all over the place when I try to compile/run .... any help with ID'ing/Fixing, or a new up-to-date sample YAML file that works would be appreciated .... cheers.



INFO ESPHome 2025.9.1
INFO Reading configuration /config/esphome/KC868-M16v2-ESPHome.yaml...
WARNING [ethernet] The 'clk_mode' option is deprecated and will be removed in ESPHome 2026.1. Please update your configuration to use 'clk' instead.
WARNING GPIO5 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-a...pping-pins
WARNING Using `sensor.SENSOR_SCHEMA` is deprecated and will be removed in ESPHome 2025.11.0. Please use `sensor.sensor_schema(...)` instead. If you are seeing this, report an issue to the external_component author and ask them to update it. https://developers.esphome.io/blog/2025/...recations/. Component using this schema: zmpt101b_ns
WARNING Using `sensor.SENSOR_SCHEMA` is deprecated and will be removed in ESPHome 2025.11.0. Please use `sensor.sensor_schema(...)` instead. If you are seeing this, report an issue to the external_component author and ask them to update it. https://developers.esphome.io/blog/2025/...recations/. Component using this schema: zmpt101b_ns
WARNING Using `sensor.SENSOR_SCHEMA` is deprecated and will be removed in ESPHome 2025.11.0. Please use `sensor.sensor_schema(...)` instead. If you are seeing this, report an issue to the external_component author and ask them to update it. https://developers.esphome.io/blog/2025/...recations/. Component using this schema: zmpt101b_ns
WARNING `attenuation: 11db` is deprecated, use `attenuation: 12db` instead
INFO Detected timezone 'Australia/Sydney'
INFO Generating C++ source...
INFO Compiling app...
Processing m16v2 (board: esp32dev; framework: arduino; platform: https://github.com/pioarduino/platform-e...ssif32.zip)
--------------------------------------------------------------------------------
INFO Package configuration completed successfully
INFO Package configuration completed successfully
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
- framework-arduinoespressif32 @ 3.2.1
- framework-arduinoespressif32-libs @ 5.4.0+sha.858a988d6e
- tool-esptoolpy @ 5.0.2
- tool-mklittlefs @ 3.2.0
- toolchain-xtensa-esp-elf @ 14.2.0+20241119
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/local/lib/python3.12/site-packages/pip/__main__.py", line 22, in <module>
from pip._internal.cli.main import main as _main
File "/usr/local/lib/python3.12/site-packages/pip/_internal/cli/main.py", line 11, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python3.12/site-packages/pip/_internal/cli/autocompletion.py", line 12, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python3.12/site-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
from pip._internal.build_env import get_runnable_pip
File "/usr/local/lib/python3.12/site-packages/pip/_internal/build_env.py", line 19, in <module>
from pip._internal.cli.spinners import open_spinner
File "/usr/local/lib/python3.12/site-packages/pip/_internal/cli/spinners.py", line 22, in <module>
from pip._internal.utils.logging import get_console, get_indentation
File "/usr/local/lib/python3.12/site-packages/pip/_internal/utils/logging.py", line 25, in <module>
from pip._vendor.rich.logging import RichHandler
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap_external>", line 1128, in get_code
File "<frozen importlib._bootstrap_external>", line 757, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
Warning! Couldn't extract the list of installed Python packages.
Installing Arduino Python dependencies
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/local/lib/python3.12/site-packages/pip/__main__.py", line 22, in <module>
from pip._internal.cli.main import main as _main
File "/usr/local/lib/python3.12/site-packages/pip/_internal/cli/main.py", line 11, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python3.12/site-packages/pip/_internal/cli/autocompletion.py", line 12, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python3.12/site-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
from pip._internal.build_env import get_runnable_pip
File "/usr/local/lib/python3.12/site-packages/pip/_internal/build_env.py", line 19, in <module>
from pip._internal.cli.spinners import open_spinner
File "/usr/local/lib/python3.12/site-packages/pip/_internal/cli/spinners.py", line 22, in <module>
from pip._internal.utils.logging import get_console, get_indentation
File "/usr/local/lib/python3.12/site-packages/pip/_internal/utils/logging.py", line 25, in <module>
from pip._vendor.rich.logging import RichHandler
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap_external>", line 1128, in get_code
File "<frozen importlib._bootstrap_external>", line 757, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
*** Error 1
Dependency Graph
|-- Networking @ 3.2.1
|-- AsyncTCP @ 3.4.5
|-- WiFi @ 3.2.1
|-- FS @ 3.2.1
|-- Update @ 3.2.1
|-- ESPAsyncWebServer @ 3.7.10
|-- ESPmDNS @ 3.2.1
|-- noise-c @ 0.1.10
|-- Wire @ 3.2.1
|-- ArduinoJson @ 7.4.2
Compiling .pioenvs/m16v2/lib4c5/Network/NetworkClient.cpp.o
sh: 1: xtensa-esp32-elf-g++: not found
*** [.pioenvs/m16v2/lib4c5/Network/NetworkClient.cpp.o] Error 127
Compiling .pioenvs/m16v2/lib4c5/Network/NetworkEvents.cpp.o
sh: 1: xtensa-esp32-elf-g++: not found
*** [.pioenvs/m16v2/lib4c5/Network/NetworkEvents.cpp.o] Error 127
========================= [FAILED] Took 20.27 seconds =========================
Reply
Hi,
On the m16V2, I'm getting incorrect voltage and current values. They're low. To make the corrections, do I need to reload the yams file on the ESP32, or can I just edit it from Home Assistant?
Reply
you can re download firmware. Or edit from home assistant for calibration.
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)