├── .github
├── dependabot.yml
└── workflows
│ ├── publish-firmware.yml
│ ├── ci.yml
│ └── publish-pages.yml
├── .gitignore
├── static
├── _config.yml
└── index.md
├── .vscode
└── settings.json
├── README.md
└── example
└── two_channel_energy_meter_based_on_xiao_esp32c6.yaml
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Gitignore settings for ESPHome
2 | # This is an example and may include too much for your use-case.
3 | # You can modify this file to suit your needs.
4 | /.esphome/
5 | /secrets.yaml
6 |
--------------------------------------------------------------------------------
/static/_config.yml:
--------------------------------------------------------------------------------
1 | # CHANGEME: Set these variable to your liking
2 | title: 2 Channel WiFi AC Energy Meter based on XIAO ESP32C6 Firmware Flasher
3 | description: Powered by Seeed Studio, ESPHome and ESP Web Tools
4 | theme: jekyll-theme-slate
5 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "MicroPython.executeButton": [
3 | {
4 | "text": "▶",
5 | "tooltip": "运行",
6 | "alignment": "left",
7 | "command": "extension.executeFile",
8 | "priority": 3.5
9 | }
10 | ],
11 | "MicroPython.syncButton": [
12 | {
13 | "text": "$(sync)",
14 | "tooltip": "同步",
15 | "alignment": "left",
16 | "command": "extension.execute",
17 | "priority": 4
18 | }
19 | ]
20 | }
--------------------------------------------------------------------------------
/static/index.md:
--------------------------------------------------------------------------------
1 | # About
2 |
3 | The **[2-Channel Wi-Fi AC Energy Meter](https://www.seeedstudio.com/)** is a smart device from Seeed Studio designed to detect the electricity usage of AC-powered appliances. Its dual-channel configuration supports independent detect of up to two loads, making it an excellent choice for automating a variety of devices in smart home environments.
4 |
5 | # Installation
6 |
7 | You can use the button below to install the pre-built firmware directly to your device via USB from the browser.
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.github/workflows/publish-firmware.yml:
--------------------------------------------------------------------------------
1 | name: Publish Firmware
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | permissions:
8 | contents: write
9 |
10 | jobs:
11 | build-firmware:
12 | name: Build Firmware
13 | uses: esphome/workflows/.github/workflows/build.yml@2025.1.0
14 | with:
15 | #### Modify below here to match your project ####
16 | files: example/two_channel_energy_meter_based_on_xiao_esp32c6.yaml
17 | esphome-version: 2024.10.3
18 | # combined-name: project-template
19 | #### Modify above here to match your project ####
20 |
21 | release-summary: ${{ github.event.release.body }}
22 | release-url: ${{ github.event.release.html_url }}
23 | release-version: ${{ github.event.release.tag_name }}
24 |
25 | upload-to-release:
26 | name: Upload to Release
27 | uses: esphome/workflows/.github/workflows/upload-to-gh-release.yml@2025.1.0
28 | needs:
29 | - build-firmware
30 | with:
31 | version: ${{ github.event.release.tag_name }}
32 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | pull_request:
5 | paths:
6 | - '*.yaml'
7 | - '.github/workflows/ci.yml'
8 | schedule:
9 | - cron: '0 0 * * *'
10 |
11 | concurrency:
12 | group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
13 | cancel-in-progress: true
14 |
15 | jobs:
16 | ci:
17 | name: Building ${{ matrix.file }} / ${{ matrix.esphome-version }}
18 | runs-on: ubuntu-latest
19 | strategy:
20 | fail-fast: false
21 | max-parallel: 3
22 | matrix:
23 | #### Modify below here to match your project ####
24 | file:
25 | - example/two_channel_energy_meter_based_on_xiao_esp32c6
26 | #### Modify above here to match your project ####
27 |
28 | esphome-version:
29 | - stable
30 | - beta
31 | - dev
32 | steps:
33 | - name: Checkout source code
34 | uses: actions/checkout@v4.1.7
35 | - name: ESPHome ${{ matrix.esphome-version }}
36 | uses: esphome/build-action@v6.0.0
37 | with:
38 | yaml-file: ${{ matrix.file }}.yaml
39 | version: ${{ matrix.esphome-version }}
40 | - name: ESPHome ${{ matrix.esphome-version }} Factory
41 | uses: esphome/build-action@v6.0.0
42 | with:
43 | yaml-file: ${{ matrix.file }}.factory.yaml
44 | version: ${{ matrix.esphome-version }}
45 |
--------------------------------------------------------------------------------
/.github/workflows/publish-pages.yml:
--------------------------------------------------------------------------------
1 | name: Publish Pages
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | paths:
8 | - 'static/**'
9 | - '.github/workflows/publish-pages.yml'
10 | workflow_run:
11 | workflows:
12 | - Publish Firmware
13 | types:
14 | - completed
15 | pull_request:
16 | paths:
17 | - 'static/**'
18 | - '.github/workflows/publish-pages.yml'
19 |
20 |
21 | concurrency:
22 | group: ${{ github.workflow }}-${{ github.ref }}
23 | cancel-in-progress: true
24 |
25 | jobs:
26 | build:
27 | name: Build
28 | runs-on: ubuntu-latest
29 | steps:
30 | - name: Checkout source code
31 | uses: actions/checkout@v4.2.2
32 |
33 | - run: mkdir -p output/firmware
34 |
35 | - name: Build
36 | uses: actions/jekyll-build-pages@v1.0.13
37 | with:
38 | source: ./static
39 | destination: ./output
40 |
41 | - name: Fetch firmware files
42 | uses: robinraju/release-downloader@v1.11
43 | with:
44 | latest: true
45 | fileName: '*'
46 | out-file-path: output/firmware
47 |
48 | - name: Upload artifact
49 | uses: actions/upload-pages-artifact@v3.0.1
50 | with:
51 | path: output
52 | retention-days: 1
53 |
54 | publish:
55 | if: github.event_name != 'pull_request'
56 | name: Publish
57 | runs-on: ubuntu-latest
58 | needs:
59 | - build
60 | permissions:
61 | pages: write
62 | id-token: write
63 | environment:
64 | name: github-pages
65 | url: ${{ steps.deployment.outputs.page_url }}
66 | steps:
67 | - name: Setup Pages
68 | uses: actions/configure-pages@v5.0.0
69 |
70 | - name: Deploy to GitHub Pages
71 | id: deployment
72 | uses: actions/deploy-pages@v4.0.5
73 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 2-Channel Energy Meter based on XIAO ESP32C6
2 |
3 | ## Overview
4 | The **[2-Channel Wi-Fi AC Energy Meter](https://www.seeedstudio.com/)** is a smart device from Seeed Studio designed to detect the electricity usage of AC-powered appliances. Its dual-channel configuration supports independent detect of up to two loads, making it an excellent choice for automating a variety of devices in smart home environments.
5 |
6 | This guide provides a detailed walkthrough, including setup, integration, and advanced configuration for users ranging from beginners to smart-home enthusiasts.
7 |
8 | ### Key Features and Specifications
9 |
10 |
11 |
12 |
13 |
14 | | Feature |
15 | Details |
16 |
17 |
18 |
19 |
20 | | Input Voltage |
21 | AC 100-240V, 50/60Hz |
22 |
23 |
24 | | Channels |
25 | 2 (independent detect for each channel) |
26 |
27 |
28 | | Connection Type |
29 | Wi-Fi |
30 |
31 |
32 | | Input Terminals |
33 | L (Live), N (Neutral), PE (Protective Earthing) |
34 |
35 |
36 | | Effective Range of Current Detection |
37 | 10mA-35A @ 1mΩ |
38 |
39 |
40 | | Active Electrical Energy |
41 | 1w-7700w @ 1mΩ |
42 |
43 |
44 |
45 |
46 |
47 | :::warning Safety Warning
48 |
49 | Always disconnect AC power before wiring.
50 |
51 | :::
52 |
53 | For more information, please visit: https://wiki.seeedstudio.com/2_channel_wifi_ac_energy_meter/
--------------------------------------------------------------------------------
/example/two_channel_energy_meter_based_on_xiao_esp32c6.yaml:
--------------------------------------------------------------------------------
1 | esphome:
2 | name: seeedstudio-2ch-em
3 | friendly_name: SeeedStudio-2CH-EM
4 | platformio_options:
5 | platform: https://github.com/mnowak32/platform-espressif32.git#boards/seeed_xiao_esp32c6
6 | on_boot:
7 | priority: 100
8 | then:
9 | - output.turn_on: gpio_14_output
10 | - output.turn_off: led_light
11 | # - light.turn_on: led_staus
12 | # - delay: 10s
13 | # - light.turn_off: led_staus
14 |
15 |
16 | output:
17 | - platform: gpio
18 | pin: GPIO14
19 | id: gpio_14_output
20 | - platform: gpio
21 | pin: GPIO19
22 | id: led_light
23 |
24 |
25 |
26 |
27 |
28 | esp32:
29 | board: seeed_xiao_esp32c6
30 | variant: ESP32C6
31 | flash_size: 4MB
32 | framework:
33 | type: esp-idf
34 | version: "5.2.1"
35 | platform_version: 6.6.0
36 | sdkconfig_options:
37 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB: y
38 |
39 |
40 | # Enable logging
41 | logger:
42 |
43 | # Enable Home Assistant API
44 | api:
45 | password: ""
46 |
47 | ota:
48 | - platform: esphome
49 | password: ""
50 |
51 | wifi:
52 | # output_power: 20dB
53 | # ssid: !secret wifi_ssid
54 | # password: !secret wifi_password
55 | # on_connect:
56 | # then:
57 | # - light.turn_on: led_staus
58 |
59 | # Enable fallback hotspot (captive portal) in case wifi connection fails
60 | ap:
61 | ssid: "SeeedStudio-2CH-EM"
62 | password: ""
63 |
64 | captive_portal:
65 |
66 | web_server:
67 | port: 80
68 |
69 |
70 |
71 | external_components:
72 | # use rtttl and dfplayer from ESPHome's dev branch in GitHub
73 | - source:
74 | type: git
75 | url: https://github.com/ackPeng/esphome.git
76 | ref: test
77 | components: [ bl0939 ]
78 | refresh: 0s
79 |
80 | debug:
81 |
82 |
83 | uart:
84 | tx_pin: GPIO16
85 | rx_pin: GPIO17
86 | baud_rate: 4800
87 |
88 | sensor:
89 | - platform: bl0939
90 | mode: 'current_transformer_mode'
91 |
92 | voltage:
93 | name: 'BL0939 Voltage'
94 | current_1:
95 | name: 'BL0939 Current 1'
96 | current_2:
97 | name: 'BL0939 Current 2'
98 | active_power_1:
99 | name: 'BL0939 Active Power 1'
100 | active_power_2:
101 | name: 'BL0939 Active Power 2'
102 | energy_1:
103 | name: 'BL0939 Energy 1'
104 | energy_2:
105 | name: 'BL0939 Energy 2'
106 | energy_total:
107 | name: 'BL0939 Energy Total'
108 |
109 |
110 |
111 | update_interval: 15s
112 |
113 | - platform: wifi_signal
114 | name: "wifi singnal strength"
115 | update_interval: 10s
116 |
117 | # light:
118 | # - platform: status_led
119 | # id: led_staus
120 | # name: "Switch state"
121 | # pin:
122 | # number: GPIO19
123 | # inverted: true
--------------------------------------------------------------------------------