Skip to content

Commit ce8b8d3

Browse files
Merge branch 'feat/add_bl0942_chip' into 'master'
feat: add bl0942 chip for power_measure component See merge request ae_group/esp-iot-solution!1396
2 parents e3a4ed3 + 55d4c9f commit ce8b8d3

File tree

16 files changed

+1564
-85
lines changed

16 files changed

+1564
-85
lines changed

.gitlab/ci/target_test.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -346,31 +346,6 @@ components_test_openai:
346346
TEST_TARGET: esp32s3
347347
TEST_FOLDER: components/openai
348348

349-
components_test_power_measure:
350-
extends:
351-
- .pytest_template
352-
- .rules:build:components_sensors_power_measure_test_apps
353-
needs:
354-
- job: "build_components_sensors_power_measure_test_apps"
355-
artifacts: true
356-
optional: false
357-
parallel:
358-
matrix:
359-
- IDF_TARGET: esp32c3
360-
IDF_VERSION: "4.4"
361-
ENV_TAG: "generic"
362-
- IDF_TARGET: esp32c3
363-
IDF_VERSION: "5.0"
364-
ENV_TAG: "generic"
365-
tags:
366-
- ${IDF_TARGET}
367-
- ${ENV_TAG}
368-
image: $DOCKER_TARGET_TEST_v5_1_ENV_IMAGE
369-
variables:
370-
TEST_TARGET: esp32c3
371-
TEST_FOLDER: components/sensors/power_measure
372-
TEST_ENV: generic
373-
374349
components_test_esp_lcd_axs15231b:
375350
extends:
376351
- .pytest_template
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
## v0.2.0 - 2025-9-5
1+
## v0.2.1 - 2025-10-16
22

3-
### Improve:
3+
### Enhancement:
44

5-
* Integrate power measurement equipment into a unified management component.
5+
* Add BL0942 chip support for power_measure component
66

7-
## v0.1.0 - 2024-11-5
7+
## v0.2.0 - 2025-9-5
88

9-
### Enhancements:
9+
### Improve:
1010

11-
* Initial version
12-
* Support BL0937 chip to measure voltage, current, energy
11+
* Integrate power measurement equipment into a unified management component.
1312

1413
## v0.1.1 - 2024-12-10
1514

@@ -18,3 +17,10 @@
1817
* Modified the formatting of the document
1918
* Added more detailed documentation
2019
* Optimised some code
20+
21+
## v0.1.0 - 2024-11-5
22+
23+
### Enhancements:
24+
25+
* Initial version
26+
* Support BL0937 chip to measure voltage, current, energy

components/sensors/power_measure/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ set(srcs
22
src/power_measure_api.c
33
src/power_measure_bl0937.c
44
src/power_measure_ina236.c
5+
src/power_measure_bl0942.c
56
drivers/ina236/ina236.c
67
drivers/bl0937/bl0937.c
8+
drivers/bl0942/bl0942.c
79
)
810

911
set(incs "include")
1012

1113
set(priv_incs
1214
"drivers/bl0937"
1315
"drivers/ina236"
16+
"drivers/bl0942"
1417
)
1518

1619
idf_component_register(SRCS ${srcs}

components/sensors/power_measure/Kconfig

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ menu "power_measure"
1919
Features: Voltage, Current, Power measurement
2020
Interface: I2C
2121
Note: Does not support energy measurement or power factor
22+
23+
config POWER_MEASURE_CHIP_BL0942
24+
bool "BL0942"
25+
help
26+
BL0942 is a single-phase power measurement IC with UART/SPI interface
27+
Features: Voltage, Current, Power, Power Factor, Energy measurement
28+
Interface: UART or SPI
29+
Note: Supports both UART and SPI communication modes
2230
endchoice
2331

2432
config BL0937_IRAM_OPTIMIZED
@@ -28,6 +36,13 @@ menu "power_measure"
2836
help
2937
Enable IRAM optimization for BL0937
3038

39+
config BL0942_UART_OPTIMIZED
40+
bool "Enable UART optimization for BL0942"
41+
default n
42+
depends on POWER_MEASURE_CHIP_BL0942
43+
help
44+
Enable UART optimization for BL0942 communication
45+
3146
menu "BL0937 Hardware Configuration"
3247
config BL0937_VREF_MV
3348
int "Internal voltage reference (mV)"
@@ -62,6 +77,29 @@ menu "power_measure"
6277
Values below 500000 (0.5s) are not recommended.
6378
endmenu
6479

80+
menu "BL0942 Hardware Configuration"
81+
config BL0942_UART_BAUD_RATE
82+
int "UART baud rate"
83+
default 4800
84+
depends on POWER_MEASURE_CHIP_BL0942
85+
help
86+
UART baud rate for BL0942 communication
87+
88+
config BL0942_DEVICE_ADDRESS
89+
int "Device address"
90+
default 0
91+
depends on POWER_MEASURE_CHIP_BL0942
92+
help
93+
BL0942 device address (0-255)
94+
95+
config BL0942_USE_SPI
96+
bool "Use SPI interface instead of UART"
97+
default n
98+
depends on POWER_MEASURE_CHIP_BL0942
99+
help
100+
Enable SPI interface for BL0942 communication
101+
endmenu
102+
65103
menu "GPIO Pin Configuration"
66104
menu "BL0937 GPIO Pins"
67105
config BL0937_CF_GPIO
@@ -96,5 +134,49 @@ menu "power_measure"
96134
help
97135
GPIO pin for I2C data line
98136
endmenu
137+
138+
menu "BL0942 GPIO Pins"
139+
config BL0942_UART_TX_GPIO
140+
int "UART TX GPIO pin number"
141+
default 6
142+
depends on POWER_MEASURE_CHIP_BL0942
143+
help
144+
GPIO pin for BL0942 UART TX
145+
146+
config BL0942_UART_RX_GPIO
147+
int "UART RX GPIO pin number"
148+
default 7
149+
depends on POWER_MEASURE_CHIP_BL0942
150+
help
151+
GPIO pin for BL0942 UART RX
152+
153+
config BL0942_SPI_MOSI_GPIO
154+
int "SPI MOSI GPIO pin number"
155+
default -1
156+
depends on POWER_MEASURE_CHIP_BL0942
157+
help
158+
GPIO pin for BL0942 SPI MOSI (set to -1 if not used)
159+
160+
config BL0942_SPI_MISO_GPIO
161+
int "SPI MISO GPIO pin number"
162+
default -1
163+
depends on POWER_MEASURE_CHIP_BL0942
164+
help
165+
GPIO pin for BL0942 SPI MISO (set to -1 if not used)
166+
167+
config BL0942_SPI_SCLK_GPIO
168+
int "SPI SCLK GPIO pin number"
169+
default -1
170+
depends on POWER_MEASURE_CHIP_BL0942
171+
help
172+
GPIO pin for BL0942 SPI SCLK (set to -1 if not used)
173+
174+
config BL0942_SPI_CS_GPIO
175+
int "SPI CS GPIO pin number"
176+
default -1
177+
depends on POWER_MEASURE_CHIP_BL0942
178+
help
179+
GPIO pin for BL0942 SPI CS (set to -1 if not used)
180+
endmenu
99181
endmenu
100182
endmenu

0 commit comments

Comments
 (0)