Open-sourcing a DC power meter that plugs directly into an XT60 circuit: ESP32-S3 MCU, TI ADS131M02 24-bit dual-channel simultaneous sampling (4 kSPS), 1 mΩ four-terminal Kelvin shunt + 101:1 precision divider, measures 0–90V, rated ±30A (peak ±75A). The 1.83-inch IPS touch color screen runs LVGL 9, with an oscilloscope-style waveform page; after connecting to a WiFi router, you can open a web console in a browser to view data and waveforms, change settings, and export CSV. Hardware, firmware, enclosure, and production files are all open source.
When doing RC models, drones, or battery charge/discharge testing, you often need a power meter that can go inline in the circuit. You want to clearly see voltage sag under high current, catch the inrush at the moment of plugging/unplugging, and ideally sync data to a PC. Products you can buy either have small screens, no waveform display, or only let you view data locally. So this project happened.
Let's get one thing straight first: the software part of this project was developed by AI. I designed the hardware myself. For the firmware, I basically handed everything from architecture design to implementation over to AI, while I did requirements definition, design review, and real-hardware validation. If that bothers you, you can stop reading here. If you care more about "does it work / how do I build one", keep reading—the code, docs, and test tools are all public.
▶ Electronics/MCU tech QQ group: 307449735
▶ eeClub – Electronics Engineer Community: https://bbs.eeclub.top/
Download links are at the end of the article.
Design Specs
| Item | Spec |
|---|---|
| Main controller | ESP32-S3-WROOM-1-N16R8 (16MB Flash + 8MB octal PSRAM, dual-core 240MHz) |
| Metering ADC | TI ADS131M02, 24-bit Σ-Δ, dual-channel simultaneous sampling, 4 kSPS |
| Voltage range | Designed measurement 0–90V (101:1 divider chain theoretical full scale ±121V, limited by the 100V max input of the auxiliary supply) |
| Voltage resolution | About 14.5 µV/LSB |
| Current range | Peak ±75A (ADC full scale); rated ±30A (limited by XT60 connector) |
| Current resolution | About 8.94 µA/LSB |
| Current sensing | 1mΩ / 5W four-terminal Kelvin shunt, PGA 16x |
| Display | 1.83-inch IPS, 240×284 (landscape 284×240), NV3030B, QSPI 4-bit |
| Touch | CST816D capacitive touch, I2C |
| Sensors | AHT20 temperature/humidity, SC7A20HTR 3-axis accelerometer (auto screen rotation) |
| Connectivity | WiFi 2.4GHz, STA/AP, HTTP + WebSocket |
| Power | Three inputs: XT60 input / USB-C / single-cell Li-ion battery; TPS2116 prioritizes USB, TP4057 charges at 400mA |
| Self-consumption | About 0.7W |
| Enclosure | Three-piece 3D-printed top cover / middle frame / bottom cover, SolidWorks source files + 3MF |
| Firmware | v0.6.9, ESP-IDF v6.1 + LVGL 9.6 |
A few things that are easy to misread:
- ±75A is the ADC full scale, not a continuous current. The 1mΩ shunt is rated to 70A (70mV drop and 4.9W dissipation at 70A), but the XT60 connector only goes to 30A (30mV drop and 0.9W at 30A). So the whole unit is rated ±30A; if you want to run higher current long-term, you'll need to modify the base board and switch to XT90 yourself.
- 90V isn't the limit of the divider chain either. The divider itself can handle ±121V; it's the auxiliary supply (the Buck fed from XT60) with a 100V max input that caps the whole unit at 90V.
- It's normal to show 0 when current is below 2mA. The 1mΩ shunt has fairly high small-signal noise (σ≈2mA per frame). The firmware uses a 200ms block average plus a 2mA deadband to suppress no-load jitter; the waveform page uses raw samples, so mA-level changes are still visible.
- This is not a metering instrument. It's good enough for hobbyist measurement and debugging; don't use it as a reference meter.
Photos
The body is a three-piece 3D-printed enclosure: top cover, middle frame, and bottom cover, held together with M2.5 screws. On the front is a 1.83-inch IPS screen; to its left are the status LED and reset button. There are two physical buttons, K1/K2, on the side (long-press K2 to bring up the quick menu). The switch next to the Type-C port selects power: one side is battery / USB, the other is XT60 input.
Screen UI
The screen has three swipeable pages: Measure, Waveform, and Settings; it stops at the first and last pages. You can operate it by touch or with buttons only.
| Main measurement screen | Oscilloscope-style waveform page |
|---|---|
| Large voltage / current / power numbers; energy, temperature/humidity, and peak/valley values at the bottom | V/I/P multi-mode, six time windows from 1s to 10min, auto-ranging |
| Settings page | Pull-up quick menu |
|---|---|
| Measurement, display, buzzer, WiFi, energy statistics, alarms, about, factory reset | Data refresh rate, clear energy statistics (with confirmation) |
A few details that make it nicer to use:
- The energy readout at the bottom of the home screen is tappable and toggles between Wh and Ah.
- The waveform page's vertical axis ticks are anchored to the standard 1-2-5 values, so you can read them mentally; trailing zeros are also trimmed, showing 3V / 0.2A instead of 3.00V / 0.200A.
- Popup width follows screen orientation (260px landscape, 216px portrait), so nothing gets clipped on the sides in portrait.
- After 15 / 30 / 60 seconds of inactivity (configurable), the backlight dims to 10%; touch or any button press restores it immediately.
- The UI screenshots above were generated with the project's PC-side LVGL simulator (
tools/ui_sim), which shares the same UI source code as the real device—they're not Photoshopped.
Hardware Design
System Architecture
The whole unit is two PCBs stacked top and bottom:
- Top board: main controller, screen, touch, sensors, buttons, buzzer, voltage divider, power management.
- Bottom board: XT60 input/output, 1mΩ shunt, high-current copper busbar.
The battery sits between the two boards, attached to the back of the top board (the ESP32-S3 module side).
| Module | Main components | Role |
|---|---|---|
| Main controller | ESP32-S3-WROOM-1-N16R8 | Sampling scheduling, UI rendering, WiFi communication, data storage |
| Metering front end | ADS131M02 + LRA8551A | Simultaneous voltage/current sampling, 24-bit, 4kSPS |
| Display/UI | NV3030B LCD + CST816D + K1/K2 + buzzer | Local display and controls |
| Sensors | SC7A20HTR + AHT20 | Screen orientation, internal temperature/humidity |
| Power | SY8511BADC / TLV62084 / TPS2116 / TP4057 | Three-input switching, 3.3V regulation, battery charging |
| Storage/upgrade | 16MB Flash + dual OTA partitions | Firmware, font resources, OTA and rollback |
Voltage Sampling
The voltage channel uses a 101:1 precision divider (100kΩ / 1kΩ, ±0.1% thin-film resistors). After division, it's buffered by a zero-drift op amp LRA8551A and fed into ADS131M02 CH1 (PGA 1x).
The divider chain itself has a theoretical full scale of ±121V, but the unit's auxiliary supply has a 100V max input, so the designed measurement range is 0–90V. At this range, one LSB is about 14.5µV.
Current Sampling
The current channel uses a 1mΩ / 5W four-terminal Kelvin shunt. The voltage sense points are separate from the high-current trace, so copper resistance doesn't get into the measurement loop; after RC filtering, the signal goes directly into ADS131M02 CH0 (PGA 16x).
With PGA 16x, the ADC full scale corresponds to ±75A peak, and 1 LSB ≈ 8.94µA.
Why 1mΩ? To cover ±75A peak and 30A rated while keeping the shunt's own heating under 5W, 1mΩ is what falls out of those constraints. The tradeoff is higher small-signal noise, which the firmware compensates for with block averaging and a deadband.
Power and Battery Management
- XT60 input: SY8511BADC steps down to 3.3V / 1A.
- USB / battery: TLV62084 steps down to 3.3V / 2A. The V2 board uses TPS2116 to automatically switch between USB and battery, prioritizing USB.
- Charging: TP4057, 400mA, single-cell Li-ion. Battery voltage goes through a 1:1 divider into the ESP32-S3 ADC for battery level display.
- The V1 board also had a version using discrete MOSFETs for power switching; schematics for both versions are open source.
PCB Design
When laying out the board, I mainly focused on these things:
- Stack the top and bottom boards, connected with pin headers/sockets. Put the screen and all the chips on the top board, and push all high-current paths to the bottom board.
- ISENSE is a small differential signal; keep its traces as short as possible and away from the DC-DC inductor and switching nodes.
- Shorten the ADC's SPI and DRDY traces; don't run them in parallel with clock lines or switching noise for long distances.
- Thicken the copper on high-current paths and use a copper busbar to keep voltage drop and temperature rise down at 30A rated and 75A peak.
- For how the analog front end and digital section grounds/power are split, see the schematic and PCB project files; I won't go into it here.
Enclosure and Assembly
The enclosure was drawn in SolidWorks. Source files include three parts—top cover / middle frame / bottom cover—plus an assembly; the 3MF print files are separate.
Assembly order:
- Press heat-set inserts into the 8 screw holes on the middle frame; heating them with a soldering iron is enough.
- Install the bottom board into the bottom cover. Pay attention to the middle frame orientation; after placing the middle frame, tighten the four screws in the bottom cover.
- Wrap the battery in a layer of fish paper insulation, connect the battery holder, and stick it to the underside of the top board (the ESP32 module side) with double-sided tape.
- Align the board-to-board pin headers and snap the top board, together with the battery, onto the middle frame.
- Put on the top cover.
- Finally connect the screen and secure it with double-sided tape on the back.
Software Design
The firmware is based on ESP-IDF v6.1 + LVGL 9.6. Layered dependencies may only go top-down; business code is not allowed to call raw peripheral APIs directly.
main/ 启动流程、任务创建、参数下发
components/
├── drivers/ ads131m02 / lcd_nv3030b / touch_cst816d / key_button
│ buzzer / imu_sc7a20h / aht20 / battery_adc / status_led
├── middleware/ data_store(seqlock)/ web_console / wifi_manager
│ lvgl_port / fs_storage / event_bus / ota_update
└── services/ power_measure / ui / settings / orientation / device_ctrl
tools/
├── ui_sim/ PC 端 LVGL UI 模拟器(走查 + 回归截图)
└── fonts/ 字库生成脚本
Measurement Chain
- ADS131M02 asserts DRDY every 250µs. SPI3 + GDMA reads the full 4-word frame: STATUS / CH0 / CH1 / CRC. The transfer is started directly in the DRDY falling-edge interrupt, locking the read window to the sampling phase.
- After CRC-16/CCITT passes, the values are converted to voltage, current, and instantaneous power using calibration parameters.
- Raw samples go into a three-stage ring buffer in PSRAM; the waveform page's history view and downsampling both read from there.
- Every 200ms it computes block averages, average power, peak/valley values, and alarms, while integrating energy and capacity.
- Every 25ms it produces a 40Hz snapshot frame. The UI and web page only read snapshots and never touch measurement data directly.
Dual-core split: Core 1 runs sampling and measurement; Core 0 runs LVGL rendering, buttons, and the WiFi/HTTP server. Why not put measurement on Core 0? The WiFi stack periodically eats a fair amount of CPU, and competing with 4kHz sampling for the core causes sampling jitter that shows up directly in the readings. For instrument firmware, trading hardware resources for timing determinism is standard practice.
Web Console
The web page is compiled directly into the firmware and doesn't depend on an external CDN, so it opens even without internet. Five tabs: Live Data / Waveform / Settings / API / Logs.
- WebSocket
/wspushes snapshots at 15Hz; if disconnected, it automatically falls back to polling and reconnects every 5s. - The reading refresh rate can be set to 15 / 10 / 5 / 2 / 1 Hz. Lower settings average multiple received frames for steadier readings; the device send rate and waveform buffer are unaffected.
- The waveform page is hand-drawn with Canvas, with V/I/P three-channel overlay, ten time windows, pause, drag-to-review, crosshair, range lock, and CSV export.
- The settings page reads current values back from the device when opened, so it won't show frontend defaults; calibration parameters (voltage/current gain and offset) can be read and written directly on the web page.
- The API page is numbered card-style documentation. Each card has a "▶ Test" button; clicking it sends a real request in place and shows the status code, latency, and response body.
Main endpoints: /api/state, /api/config (GET/POST), /api/info, /api/wifi/scan, /api/export.csv, /ws.
Engineering
- Dual OTA partitions + boot rollback:
ota_update_start(url)pull-based upgrade writes to the spare partition; if boot fails, it automatically rolls back to the old version. The web console doesn't have a firmware upload entry yet, so unbricking is still done via USB / serial flashing. - coredump: crash state is written to a separate partition for later export and analysis.
- PC-side UI simulator:
tools/ui_simrenders the same UI source on Windows and takes batch screenshots, so you can run a layout regression before flashing. - Host-side unit tests: pure logic parts (two's complement extension, calibration conversion, energy integration, button state machine, AHT20 CRC) can be tested without hardware.
- Font subsetting: the main UI uses GB2312 Level 1+2, 6763 characters, two weights totaling about 4.2MB, stored in a separate storage partition; the boot screen uses a tiny separate subset of about 197 characters compiled directly into the app, so the first frame already shows complete Chinese.
A quick war story: the boot screen used to wait for the filesystem to mount and the full font library to load before showing anything, so the screen took 1.42s to light up. After moving the display chain (LCD / touch / LVGL / IMU / orientation) earlier to steps 9–13 and moving fs_storage later, it now lights up in about 1.09s.
Usage
- Wiring: Connect the XT60 input to a power supply or battery and the output to the load; watch the polarity. Input and output can be swapped; reverse current will show as negative.
- Power on: Flip the switch to USB / battery to power on. If it's set to XT60 input, the input needs to be above 5V for it to start.
- Measure: The main screen shows voltage, current, power, and energy. Tap the energy row at the bottom to toggle between Wh and Ah.
- Waveform: Swipe to the waveform page, swipe up to bring up the quick menu, and switch time window and V/I/P mode.
- Quick menu: On the measurement page, swipe up or long-press K2 to adjust refresh rate or clear energy statistics (with a confirmation first).
- WiFi setup: Settings → WiFi & hotspot → Scan WiFi → enter password. You can also have it create a hotspot; connect your phone to the device hotspot and configure WiFi from the web page.
- Web: Once WiFi is configured, open the device IP from a phone or computer on the same LAN.
- Charging: Connect 5V to USB-C; TP4057 charges at 400mA, and the status bar shows battery level.
Power Consumption and Testing
Measured self-consumption is about 0.7W. That's the power the device itself draws; it adds to the circuit under test, so keep this baseline in mind when testing low-power devices.
Validation of the sampling chain focused on two things: frame integrity during continuous sampling, and timing stability from DRDY to SPI start. At 4kHz, the 250µs period window is tight; if a read frame crosses the conversion-complete point, DRDY gets suppressed by the hardware and the frequency drops immediately. The final approach was 20MHz SPI to shorten the read window, plus starting GDMA directly in the DRDY interrupt to lock the phase; in continuous runs the frame rate was stable.
For accuracy, the current calibration method is: auto-zero the current at no load, then correct gain/offset using a known voltage and a reference meter. There's no multi-point calibration or long-term drift testing. So this unit is positioned as a "debugging tool", not a "metering instrument". If you want higher accuracy, you can add your own calibration points; gain and offset can be changed on both the device settings page and the web page.
Build Notes
-
The files are a complete set—don't just download the firmware folder. Schematics, LCEDA project, Gerber, BOM, stencil, SolidWorks enclosure, and 3MF are all in the same repository.
-
For PCB fabrication, 1.2mm board thickness is recommended; impedance and lamination can use the default process. Gerber files are in
05-生产文件/01-PCB/; the stencil file has top and bottom combined on one sheet, so you can just order a laser stencil on Taobao. -
For soldering, use the "stencil + hot plate" route: align and secure the stencil → apply solder paste → place components according to the interactive BOM → reflow on a hot plate or with hot air → finally solder through-hole parts. Open the interactive BOM in a browser; reference designators highlight, making it easy to find components.
-
There are two ways to flash. If you have ESP-IDF v6.1 installed, use the scripts:
cd 02-Software/XT60-Power-Meter-Firmware .\build_fw.bat .\flash_fw.bat COM3If you don't want to install the environment, open ESPConnect in Chrome / Edge and flash the full firmware over Web Serial.
-
The firmware consists of 5 images; don't flash only the app.
idf.py flashhandles it automatically according toflash_args; if flashing manually, note thatstorage.binis at0x830000and contains the full Chinese font. If you change the font library, you must flash the full set; OTA alone will result in "upgrade succeeded but Chinese turns into boxes". -
Don't get the calibration order backwards: first do current zero calibration at no load (the device averages a 3-second block), then calibrate voltage gain and offset, and finally calibrate current with a reference meter in series. Parameters are written to NVS and survive power loss and upgrades.
-
I recommend printing the enclosure in translucent material, so the screen and status LED can shine through; it looks much better than solid colors.
Features to Implement
- Complete OTA upgrade flow. The foundation is there: dual OTA partitions, pull-based upgrade middleware, and boot rollback validation all work; what's missing is the web-side firmware upload entry and post-upgrade self-check gating.
- USB serial host functionality + companion host software. Right now there's only the WiFi web page; the "plug in a cable and view data" use case hasn't been implemented yet.
I'll add these two when I have time; you can also implement them yourself and submit a PR.
Known Issues
When powered by USB / battery, 3.3V back-feeds into the XT60 connector.
The path is: 3.3V goes through the body diode of the internal MOS in the Buck chip for XT60 input, then through the body diode of the power-control MOS (Q4), and back-feeds to the XT60 terminals. So even with nothing connected to XT60, the measurement screen shows about 2.45V (3.3V minus two body-diode drops).
Three fixes, from least to most modification:
- Don't change the circuit and don't use XT60 input: simply don't solder the Buck for XT60 input and power it from battery only.
- Change just one component: add a back-to-back MOS in series after Q4 to break the body-diode path. This is what I'll change in the next version.
- Just don't use battery / USB: switch to XT60 power and there's no back-feed path, but it must be connected to XT60 to power on.
A few other known limitations:
- When switched to XT60 power, the input must be at least 5V to start.
- Current |I| < 2mA is treated as 0; this is by design, not a fault.
- The web console has no OTA upload entry; upgrading still requires a cable.
- Measurements are DC block averages, not true RMS. Measuring AC or ripple would require a different design.
Schematics
The complete schematic PDFs (top board V1 / V2, bottom board) and LCEDA project are under 01-Hardware/ in the repository.
Download Links
The provided files include LCEDA project files, top/bottom board schematic PDFs, Gerber fabrication files, stencil files, BOM, reference designator map, interactive soldering helper HTML, SolidWorks enclosure source files, 3MF print files, datasheets for all components, and the complete ESP-IDF firmware project (including architecture docs, flashing guide, pin table, and PC-side UI simulator).
Repository structure:
XT60-Power-Meter/
├── 01-Hardware/ 硬件设计
│ ├── 01-XT60功率计-立创EDA工程.epro2
│ ├── 02-上板原理图_V1.pdf / V2.pdf
│ └── 02-下板原理图.pdf
├── 02-Software/
│ └── XT60-Power-Meter-Firmware/ ESP-IDF 固件工程
│ ├── main/ 启动与任务编排
│ ├── components/ 驱动 / 中间件 / 服务
│ ├── docs/ 架构、烧录、引脚文档
│ └── tools/ 字体工具、UI 模拟器
├── 03-Datasheet/ 器件数据手册与屏幕资料
├── 04-外壳设计/ SolidWorks 源文件与 PCB 模型
├── 05-生产文件/
│ ├── 01-PCB/ Gerber 与手工焊接钢网
│ ├── 02-贴片/ BOM、位号图、交互式焊接辅助
│ └── 03-外壳3D打印文件/ 3MF 打印文件
├── LICENSE 硬件 CERN OHL-S v2
├── README.md
└── README.en.md
- Gitee repo: https://gitee.com/zeruns/xt60-power-meter (development uses the
developbranch) - GitHub repo: https://github.com/zeruns/xt60-power-meter
- OSHWHub page: https://oshwhub.com/zeruns/xt60-power-meter-esp32
- Demo video: https://www.bilibili.com/video/BV1pNWU6qE3P/
For licensing, the hardware (schematics, PCB, enclosure, production files) uses CERN OHL-S v2, a strongly reciprocal open hardware license; derivative hardware must be open-sourced under the same license. Firmware uses MIT. Third-party components such as LVGL, esp_lvgl_port, and Noto Sans SC keep their original licenses; details are in THIRD_PARTY.md.
Disclaimer
- Measurements from this device are not valid for metrology certification.
- 90V / ±75A peak are hazardous voltages and currents. When wiring, soldering, and testing, guard against short circuits, electric shock, and reverse connection; use suitable wire gauge and connectors for high-current tests.
- The author is not liable for any direct or indirect loss caused by using this project's hardware or firmware.
- Feel free to report issues and suggest improvements in the comments or on Gitee Issues.
Open-Source Project Recommendations
- I open-sourced a three-phase energy monitor that makes it easy to monitor household power usage: https://blog.zeruns.com/archives/771.html
- Open-source STM32-based synchronous rectification Buck-Boost digital power supply: https://blog.zeruns.com/archives/791.html
- Open-source CH32V307-based smart electronic load, an embedded competition project: https://blog.zeruns.com/archives/785.html
- [Open Source] SC8703-based Buck-Boost adjustable DC-DC power supply, adjustable voltage and current, supports PD fast-charge input: https://blog.zeruns.com/archives/929.html
- Open-source 140W+65W Buck-Boost PD3.1 fast-charge module (2C+1A ports), IP6557+IP6538, 205W desktop charger: https://blog.zeruns.com/archives/801.html
- [Open Source] 24V3A flyback switching power supply (based on UC3842, includes circuit and transformer parameter calculation process): https://blog.zeruns.com/archives/910.html
- Open-source Type-C dock, 4× 10Gbps USB-A ports + 2.5G NIC + card reader: https://blog.zeruns.com/archives/868.html
Recommended Reading
- Recommendations for high-value and cheap VPS/cloud servers: https://blog.zeruns.com/archives/383.html
- Minecraft server setup tutorial: https://blog.zeruns.com/tag/mc/
- Cross-border e-commerce standalone site tutorial, WordPress foreign trade site guide: https://blog.zeruns.com/archives/889.html
- Complete Hermes Agent deployment guide, step-by-step to build your first AI assistant: https://blog.zeruns.com/archives/939.html
- Ugreen DXP4800Pro NAS unboxing review and teardown: https://blog.zeruns.com/archives/949.html
- Discourse forum setup tutorial: deploy a Discourse open-source community forum from scratch: https://blog.zeruns.com/archives/919.html
English Version of the Article: https://blog.zeruns.top/archives/107.html
开源一个能直接插进 XT60 回路的直流功率计:ESP32-S3 主控,TI ADS131M02 24bit 双通道同步采样(4kSPS),1mΩ 四端开尔文分流器 + 101:1 精密分压,测量 0~90V、额定 ±30A(峰值 ±75A)。1.83 寸 IPS 触控彩屏跑 LVGL 9,带示波器风格波形页;WiFi 连上路由器后可以用浏览器打开网页控制台看数据、看波形、改设置、导 CSV。硬件、固件、外壳、生产文件全部开源。
做航模、无人机、电池充放电测试的时候,经常需要一台能直接串在回路里的功率计。要看得清大电流下的电压跌落,要抓得住插拔瞬间的浪涌,最好还能把数据同步到电脑。市面上能买到的产品,要么屏幕小,要么没有波形,要么数据只能自己看。于是就有了这个项目。
先说清楚一件事:本项目的软件部分由 AI 开发。硬件是我自己画的,固件从架构设计到具体实现基本都交给了 AI,我再做需求定义、方案评审和实机验证。如果你介意这一点,看到这里就可以关掉;如果你更关心"能不能用、怎么复刻",那继续往下看,代码、文档、测试工具都是公开的。
▶ 电子/单片机技术交流QQ群:307449735
▶ eeClub-电子工程师社区: https://bbs.eeclub.top/
资料下载地址在文章末尾。
设计参数
| 项目 | 参数 |
|---|---|
| 主控 | ESP32-S3-WROOM-1-N16R8(16MB Flash + 8MB 八线 PSRAM,双核 240MHz) |
| 计量 ADC | TI ADS131M02,24bit Σ-Δ,双通道同步采样,4 kSPS |
| 电压量程 | 设计测量 0~90V(101:1 分压链路理论满量程 ±121V,受辅助电源 100V 输入上限限制) |
| 电压分辨率 | 约 14.5 µV/LSB |
| 电流量程 | 峰值 ±75A(ADC 满量程);额定 ±30A(XT60 接口限制) |
| 电流分辨率 | 约 8.94 µA/LSB |
| 电流采样 | 1mΩ / 5W 四端开尔文分流器,PGA 16x |
| 显示 | 1.83 寸 IPS,240×284(横屏 284×240),NV3030B,QSPI 4bit |
| 触摸 | CST816D 电容触摸,I2C |
| 传感器 | AHT20 温湿度、SC7A20HTR 三轴加速度计(自动转屏) |
| 通信 | WiFi 2.4GHz,STA/AP,HTTP + WebSocket |
| 供电 | XT60 输入 / USB-C / 单节锂电池三路供电,TPS2116 优先 USB,TP4057 以 400mA 充电 |
| 自身功耗 | 约 0.7W |
| 外壳 | 上盖 / 中框 / 底盖三件式 3D 打印,SolidWorks 源文件 + 3MF |
| 固件 | v0.6.9,ESP-IDF v6.1 + LVGL 9.6 |
先说几个容易被误读的点:
- ±75A 是 ADC 满量程,不是可持续电流。 1mΩ 分流器额定到 70A(70A 时压降 70mV、功耗 4.9W),但 XT60 接口只到 30A(30A 时压降 30mV、功耗 0.9W)。所以整机额定写 ±30A,想长期跑更大电流得自己改底板换 XT90。
- 90V 也不是分压链路的极限。 分压本身能到 ±121V,是辅助电源(XT60 取电那路 Buck)最高输入 100V 把整机卡在了 90V。
- 电流小于 2mA 时显示 0 是正常的。 1mΩ 分流器的小信号噪声不小(单帧 σ≈2mA),固件用 200ms 块均值加 2mA 死区压住空载跳动;波形页用的是原始样本,mA 级变化照样能看。
- 这不是计量器具。 爱好者测量和调试够用,别拿去当标准表。
实物图
机身是上盖、中框、底盖三件式 3D 打印外壳,M2.5 螺丝固定。正面一块 1.83 寸 IPS 屏,屏幕左侧是状态指示灯和复位按键,机身侧面有 K1/K2 两颗实体按键(K2 长按可以呼出快速菜单)。Type-C 口旁边那个开关用来切供电:一边是电池 / USB,一边是 XT60 取电。
屏幕界面
屏幕上是三页滑动结构:测量、波形、设置,首末页到头即止。触屏和纯按键都能操作。
| 测量主界面 | 示波器风格波形页 |
|---|---|
| 电压 / 电流 / 功率大数字,底部是电能、温湿度、峰谷值 | V/I/P 多模式,1s~10min 六档时间窗,自动量程 |
| 设置页 | 上拉快速菜单 |
|---|---|
| 测量、显示、蜂鸣器、WiFi、电能统计、告警、关于、恢复出厂 | 数据刷新率、清除电能统计(二次确认) |
几个用起来比较顺手的细节:
- 首页底部那条电能数据可以点,在 Wh 和 Ah 之间切换。
- 波形页纵轴刻度按 1-2-5 标准格值锚定,直接心算就能读数;刻度还做了去尾零处理,显示 3V / 0.2A 而不是 3.00V / 0.200A。
- 弹窗宽度跟着屏幕方向走(横屏 260px、竖屏 216px),竖屏不会左右被裁。
- 无操作 15 / 30 / 60 秒(可设)背光降到 10%,触摸或按任意键立刻恢复。
- 上面这些界面图是用项目自带的 PC 端 LVGL 模拟器(
tools/ui_sim)生成的,和真机共用同一份界面源码,不是 P 的。
硬件设计
系统框架
整机是上下两块 PCB 叠起来的:
- 上板:主控、屏幕、触摸、传感器、按键、蜂鸣器、电压分压、电源管理。
- 下板:XT60 输入输出、1mΩ 分流器、大电流铜排。
电池夹在两层板中间,贴上上板背面(也就是 ESP32-S3 模组那一面)。
| 模块 | 主要器件 | 职责 |
|---|---|---|
| 主控 | ESP32-S3-WROOM-1-N16R8 | 采样调度、UI 渲染、WiFi 通信、数据存储 |
| 计量前端 | ADS131M02 + LRA8551A | 电压 / 电流同步采样,24bit,4kSPS |
| 显示交互 | NV3030B LCD + CST816D + K1/K2 + 蜂鸣器 | 本地显示与操作 |
| 传感器 | SC7A20HTR + AHT20 | 屏幕方向、机内温湿度 |
| 电源 | SY8511BADC / TLV62084 / TPS2116 / TP4057 | 三路输入切换、3.3V 稳压、电池充电 |
| 存储升级 | 16MB Flash + 双 OTA 分区 | 固件、字体资源、OTA 与回滚 |
电压采样
电压通道用 101:1 精密分压(100kΩ / 1kΩ,±0.1% 薄膜电阻),分压后经零漂移运放 LRA8551A 缓冲,再进 ADS131M02 的 CH1(PGA 1x)。
分压链路本身理论满量程 ±121V,但整机辅助电源最高输入 100V,所以设计测量范围取 0~90V。按这个量程折算,单 LSB 约 14.5µV。
电流采样
电流通道是 1mΩ / 5W 四端开尔文分流器,电压引出点独立于大电流走线,避免铜箔电阻串进测量回路;信号经 RC 滤波后直接进 ADS131M02 的 CH0(PGA 16x)。
PGA 16x 下 ADC 满量程对应 ±75A 峰值,1 LSB≈8.94µA。
为什么选 1mΩ?要覆盖 ±75A 峰值和 30A 额定,又要把分流器自身发热压在 5W 以内,1mΩ 是这几个约束交叉出来的结果。代价就是小信号噪声偏大,靠固件的块均值和死区来补。
电源与电池管理
- XT60 取电:SY8511BADC 降到 3.3V / 1A。
- USB / 电池:TLV62084 降到 3.3V / 2A。V2 板用 TPS2116 在 USB 和电池之间自动切换,优先 USB。
- 充电:TP4057,400mA,单节锂电池。电池电压经 1:1 分压进 ESP32-S3 的 ADC,用来显示电量。
- V1 板还做过一版用分立 MOS 实现电源切换的方案,两版原理图都开源了。
PCB 设计
画板的时候主要盯了这几件事:
- 上下板叠层,板间用排针排母连接。屏幕和各种芯片放上板,大电流路径全部丢下板。
- ISENSE 是差分小信号,走线尽量短,离 DC-DC 电感和开关节点远一点。
- ADC 的 SPI 和 DRDY 走线缩短,别跟时钟线、开关噪声长距离并行。
- 大电流路径铜箔加粗,再配合铜排,把 30A 额定、75A 峰值下的压降和温升压下来。
- 模拟前端和数字部分的地 / 电源怎么分,看原理图和 PCB 工程文件,这里不展开。
外壳与组装
外壳用 SolidWorks 画的,源文件在上盖 / 中框 / 底盖三个零件加一个装配体,3MF 打印文件单独放。
组装顺序:
- 中框上的 8 个螺丝孔压入热熔螺母,用烙铁加热压就行。
- 下板装进底盖,注意中框方向,放上中框后拧底盖的四颗螺丝。
- 电池包一层青稞纸绝缘,接好电池座,用双面胶粘在上板底面(ESP32 模组那一面)。
- 对准板间排针,把上板连同电池扣到中框上。
- 盖上上盖。
- 最后接屏幕,屏幕背面贴双面胶固定。
软件设计
固件基于 ESP-IDF v6.1 + LVGL 9.6,分层依赖只能自上而下,业务代码不许直接调裸外设 API。
main/ 启动流程、任务创建、参数下发
components/
├── drivers/ ads131m02 / lcd_nv3030b / touch_cst816d / key_button
│ buzzer / imu_sc7a20h / aht20 / battery_adc / status_led
├── middleware/ data_store(seqlock)/ web_console / wifi_manager
│ lvgl_port / fs_storage / event_bus / ota_update
└── services/ power_measure / ui / settings / orientation / device_ctrl
tools/
├── ui_sim/ PC 端 LVGL UI 模拟器(走查 + 回归截图)
└── fonts/ 字库生成脚本
测量链路
- ADS131M02 每 250µs 拉一次 DRDY,SPI3 + GDMA 读完整 4 字帧:STATUS / CH0 / CH1 / CRC。DRDY 下降沿中断里直接启动传输,把读窗和采样相位锁死。
- CRC-16/CCITT 校验通过后,按标定参数换算成电压、电流和瞬时功率。
- 原始样本写进 PSRAM 的三级环形缓冲,波形页回看和降采样都从这里取。
- 每 200ms 结算一次块均值、平均功率、峰谷值和告警,同时积分电能和容量。
- 每 25ms 产出一帧 40Hz 快照,UI 和网页都只读快照,不直接碰测量数据。
双核分工:Core 1 跑采样和测量,Core 0 跑 LVGL 渲染、按键和 WiFi/HTTP 服务。为什么不把测量放 Core 0?WiFi 协议栈会周期性吃掉不少 CPU,和 4kHz 采样抢核会造成采样抖动,直接反映到读数上。仪器类固件用硬件资源换时序确定性,是常规做法。
网页控制台
网页是直接编进固件的,不依赖外部 CDN,断网也能打开。五个页签:实时数据 / 波形图 / 设置 / API / 日志。
- WebSocket
/ws以 15Hz 推快照,断线自动退化成轮询并每 5s 重连一次。 - 读数刷新率可以设 15 / 10 / 5 / 2 / 1 Hz,低档位会对收到的多帧做平均,读数更稳;设备发送速率和波形缓冲不受影响。
- 波形页是 Canvas 手绘,V/I/P 三通道叠加、十个时间窗、暂停、拖动回看、十字光标、量程锁定、CSV 导出都有。
- 设置页打开就从设备回读当前值,不会显示前端默认值;标定参数(电压 / 电流的增益和零偏)网页上能直接读写。
- API 页是编号卡片式文档,每张卡带一个「▶ Test」,点了就地发真实请求,显示状态码、耗时和响应正文。
主要接口:/api/state、/api/config(GET/POST)、/api/info、/api/wifi/scan、/api/export.csv、/ws。
工程化
- 双 OTA 分区 + 启动回滚:
ota_update_start(url)拉取式升级写备用分区,启动失败自动退回旧版本。网页控制台目前还没做固件上传入口,救砖还是以 USB / 串口烧录为准。 - coredump:崩溃现场写到独立分区,方便事后导出分析。
- PC 端 UI 模拟器:
tools/ui_sim用同一份界面源码在 Windows 上渲染并批量截图,烧录前先跑一遍布局回归。 - 主机端单元测试:纯逻辑部分(补码扩展、标定换算、电能积分、按键状态机、AHT20 CRC)不依赖硬件就能测。
- 字库子集化:主界面用 GB2312 一级+二级 6763 字,两个字重约 4.2MB,放独立的 storage 分区;启动页另用一套约 197 字的极小子集直接编进 app,首帧就是完整中文。
顺带说个踩坑记录:启动页以前要等文件系统挂载、全量字库加载完才显示,屏幕点亮要 1.42s。把显示链路(LCD / 触摸 / LVGL / IMU / 方向)前移到第 9~13 步、fs_storage 后移之后,现在大约 1.09s 就亮屏了。
使用说明
- 接线:XT60 输入端接电源或电池,输出端接负载,注意正负极。输入输出方向可以对调,反向电流会显示成负数。
- 开机:开关拨到 USB / 电池这档就能开机。要是切在 XT60 取电档,输入得给到 5V 以上才起得来。
- 测量:主界面看电压、电流、功率、电能。点一下底部电能行可以在 Wh 和 Ah 之间切。
- 波形:滑到波形页,上滑呼出快捷菜单,切时间窗和 V/I/P 模式。
- 快速菜单:测量页上滑或者长按 K2,能调刷新率、清电能统计(清之前会二次确认)。
- 配网:设置 → WiFi 与热点 → 搜索 WiFi → 输密码。也可以让它开热点,手机连上设备热点再进网页配网。
- 网页:配网成功后,同一局域网的手机或电脑访问设备 IP 就行。
- 充电:USB-C 接 5V,TP4057 以 400mA 充,状态栏能看到电量。
功耗与测试
整机自身功耗实测大约 0.7W。这是设备自己吃掉的功率,测量的时候会叠加在被测回路上,低功耗待测设备的测试要留意这个本底。
采样链路的验证集中在两件事上:一是连续采样的帧完整性,二是 DRDY 到 SPI 启动的时序稳定性。4kHz 档 250µs 的周期窗口很紧,一旦读帧跨越转换完成时刻,DRDY 就会被硬件抑制、频率直接掉下来。最后的做法是 20MHz SPI 缩短读窗,加 DRDY 中断里直启 GDMA 锁住相位,实测连续跑下来帧率稳定。
精度方面目前的校准手段是:空载时做电流零点自动归零,再用已知电压和标准表修正增益 / 零偏。没有做多点标定和长期漂移测试。所以本机定位是"调试工具",不是"计量仪器"。想要更高精度的可以自己补标定点,设备端设置页和网页都能改增益和零偏。
复刻说明
-
资料是一整套,别只下固件目录。 原理图、立创 EDA 工程、Gerber、BOM、钢网、SolidWorks 外壳、3MF 都在同一个仓库里。
-
打板建议板厚 1.2mm,阻抗和层压按默认工艺就行。Gerber 在
05-生产文件/01-PCB/,钢网文件是顶层底层拼在一片上的,淘宝下单激光钢网就行。 -
焊接走"钢网 + 加热台"路线:钢网对位固定 → 刷锡膏 → 照交互式 BOM 放器件 → 加热台或热风枪回流 → 最后焊直插件。交互式 BOM 在浏览器里打开,点位号会高亮,找元件很省事。
-
烧录有两种方式。装了 ESP-IDF v6.1 就用脚本:
cd 02-Software/XT60-Power-Meter-Firmware .\build_fw.bat .\flash_fw.bat COM3不想装环境就用 Chrome / Edge 打开 ESPConnect,走 Web Serial 烧完整固件。
-
固件是 5 个镜像,别只烧 app。
idf.py flash会按flash_args自动处理;手工烧的话注意storage.bin在0x830000,里面是全量中文字体。改字库必须全量烧,只走 OTA 会出现"升级成功但中文变方框"。 -
校准顺序别搞反:先空载做电流零点校准(设备端采样 3 秒块均值),再校准电压增益和零偏,最后串标准表校准电流。参数写 NVS,掉电和升级都保留。
-
外壳建议用半透明材料打印,屏幕和状态灯能透出光来,比实色好看不少。
待实现功能
- 完整的 OTA 升级流程。底子已经有了:双 OTA 分区、拉取式升级中间件、启动回滚校验都能跑;缺的是网页端的固件上传入口和升级后的自检门控。
- USB 串口上位机功能 + 配套上位机软件。现在只有 WiFi 网页这一条路,插线看数据的需求还没做。
这两个功能有空我会补,你们也可以自己做了提 PR。
目前存在的问题
USB / 电池供电时,3.3V 会倒灌到 XT60 接口。
具体路径是:3.3V 经 XT60 取电那路 Buck 芯片内部 MOS 的体二极管,再经供电控制 MOS(Q4)的体二极管,倒灌到 XT60 端子。所以即使 XT60 没接任何输入,测量界面也会显示 2.45V 左右(3.3V 减去两级体二极管压降)。
三个解法,按改动量从小到大:
- 不改电路,也不用 XT60 取电:直接不焊 XT60 取电那部分 Buck,只用电池供电。
- 只改一个器件:在 Q4 后面再串一颗背对背 MOS,把体二极管通路断掉。这是下一版要改的地方。
- 干脆不用电池 / USB:开关切到 XT60 供电档,就没有倒灌路径了,但必须接着 XT60 才能开机。
另外几条已知限制:
- 切到 XT60 供电时,输入最低 5V 才能启动。
- 电流 |I| < 2mA 按 0 处理,这是设计行为不是故障。
- 网页控制台没有 OTA 上传入口,升级还得插线。
- 测量结果是直流口径的块均值,不是真有效值(RMS)。要测交流或纹波得另做。
原理图
完整的原理图 PDF(上板 V1 / V2、下板)和立创 EDA 工程在仓库 01-Hardware/ 下。
资料下载地址
提供的资料有 立创 EDA 工程文件、上板/下板原理图 PDF、Gerber 制板文件、钢网文件、BOM 表、位号图、交互式焊接辅助 HTML、SolidWorks 外壳源文件、3MF 打印文件、全部器件数据手册、ESP-IDF 固件完整工程(含架构文档、烧录指南、引脚表、PC 端 UI 模拟器)。
仓库目录结构:
XT60-Power-Meter/
├── 01-Hardware/ 硬件设计
│ ├── 01-XT60功率计-立创EDA工程.epro2
│ ├── 02-上板原理图_V1.pdf / V2.pdf
│ └── 02-下板原理图.pdf
├── 02-Software/
│ └── XT60-Power-Meter-Firmware/ ESP-IDF 固件工程
│ ├── main/ 启动与任务编排
│ ├── components/ 驱动 / 中间件 / 服务
│ ├── docs/ 架构、烧录、引脚文档
│ └── tools/ 字体工具、UI 模拟器
├── 03-Datasheet/ 器件数据手册与屏幕资料
├── 04-外壳设计/ SolidWorks 源文件与 PCB 模型
├── 05-生产文件/
│ ├── 01-PCB/ Gerber 与手工焊接钢网
│ ├── 02-贴片/ BOM、位号图、交互式焊接辅助
│ └── 03-外壳3D打印文件/ 3MF 打印文件
├── LICENSE 硬件 CERN OHL-S v2
├── README.md
└── README.en.md
- Gitee 开源地址:https://gitee.com/zeruns/xt60-power-meter(开发用
develop分支) - GitHub 仓库地址:https://github.com/zeruns/xt60-power-meter
- 立创开源平台地址:https://oshwhub.com/zeruns/xt60-power-meter-esp32
- 演示视频:https://www.bilibili.com/video/BV1pNWU6qE3P/
许可证方面,硬件(原理图、PCB、外壳、生产文件)用 CERN OHL-S v2,强互惠开源硬件许可,衍生硬件要用同样的许可证开源;固件用 MIT。LVGL、esp_lvgl_port、Noto Sans SC 等第三方组件各自保留原许可,明细在 THIRD_PARTY.md。
免责声明
- 本设备测量结果不作为计量认证依据。
- 90V / ±75A 峰值属于危险电压电流,接线、焊接、测试请防短路、防触电、防反接,大电流测试用合适线径和接头。
- 使用本项目硬件或固件造成的任何直接或间接损失,作者不承担责任。
- 欢迎在评论区或 Gitee Issue 反馈问题与改进建议。
开源项目推荐
- 做了个三相电量采集器开源出来,可以方便监测家里用电情况: https://blog.zeruns.com/archives/771.html
- 基于STM32的同步整流Buck-Boost数字电源 开源: https://blog.zeruns.com/archives/791.html
- 基于CH32V307的智能电子负载开源,嵌入式大赛作品开源: https://blog.zeruns.com/archives/785.html
- 【开源】基于SC8703的升降压DCDC可调电源(Buck-Boost),电压电流可调,支持PD快充输入:https://blog.zeruns.com/archives/929.html
- 开源 140W+65W升降压PD3.1快充模块(2C+1A口),IP6557+IP6538,205W桌面充电器:https://blog.zeruns.com/archives/801.html
- 【开源】24V3A反激式开关电源(基于UC3842,含电路和变压器参数计算过程):https://blog.zeruns.com/archives/910.html
- 开源TypeC拓展坞,4个10Gbps的USBA口+2.5G网卡+读卡器: https://blog.zeruns.com/archives/868.html
推荐阅读
- 高性价比和便宜的VPS/云服务器推荐: https://blog.zeruns.com/archives/383.html
- 我的世界开服教程:https://blog.zeruns.com/tag/mc/
- 跨境电商独立站搭建教程,WordPress外贸建站指南:https://blog.zeruns.com/archives/889.html
- Hermes Agent 部署全指南,手把手教你搭建你的第一个AI助手:https://blog.zeruns.com/archives/939.html
- 绿联(Ugreen)DXP4800Pro NAS 开箱评测与拆解:https://blog.zeruns.com/archives/949.html
- Discourse论坛搭建教程,零基础部署Discourse开源社区论坛网站:https://blog.zeruns.com/archives/919.html
English Version of the Article: https://blog.zeruns.top/archives/107.html
Translated by AI from 简体中文Original (简体中文)
可以共享、可以push的免费邮箱,更可使用自定义域名,完美契合您的各项需求。
6 replies
Sort order