{"id":47686893,"url":"https://github.com/exomind-team/wattson","last_synced_at":"2026-04-02T14:53:53.427Z","repository":{"id":346993941,"uuid":"1192424603","full_name":"exomind-team/wattson","owner":"exomind-team","description":"⚡ Wattson — Universal digital PSU monitoring library. Real-time power consumption via serial protocols. Rust.","archived":false,"fork":false,"pushed_at":"2026-03-27T03:02:22.000Z","size":1051,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-27T03:07:22.585Z","etag":null,"topics":["digital-psu","energy","hardware","iot","monitoring","power-supply","psu","rust","serial","wattson"],"latest_commit_sha":null,"homepage":"https://github.com/exomind-team/wattson","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exomind-team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-26T07:48:05.000Z","updated_at":"2026-03-26T14:46:39.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/exomind-team/wattson","commit_stats":null,"previous_names":["exomind-team/wattson"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/exomind-team/wattson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exomind-team%2Fwattson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exomind-team%2Fwattson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exomind-team%2Fwattson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exomind-team%2Fwattson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exomind-team","download_url":"https://codeload.github.com/exomind-team/wattson/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exomind-team%2Fwattson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31308447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["digital-psu","energy","hardware","iot","monitoring","power-supply","psu","rust","serial","wattson"],"created_at":"2026-04-02T14:53:52.727Z","updated_at":"2026-04-02T14:53:53.420Z","avatar_url":"https://github.com/exomind-team.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# ⚡ Wattson\n\n**Universal Digital PSU Monitoring Library**\n\n**Universal Digital PSU Monitoring Library — Energy Sensing Layer of the [ExoMind](https://github.com/exomind-team/exomind) Ecosystem**\n\n通用数字电源监控库 — [ExoMind](https://github.com/exomind-team/exomind) 生态的能量感知层\n\n[![License: CCOPL-1.0](https://img.shields.io/badge/License-CCOPL--1.0-blue.svg)](LICENSE)\n[![Rust](https://img.shields.io/badge/Rust-1.75%2B-orange.svg)](https://www.rust-lang.org/)\n[![CI](https://github.com/exomind-team/wattson/actions/workflows/ci.yml/badge.svg)](https://github.com/exomind-team/wattson/actions)\n\n\u003c/div\u003e\n\n---\n\n## 💡 Why Wattson? / 为什么做这个？\n\nDigital PSUs (数字电源) expose real-time telemetry over USB — voltages, currents, temperatures, fan speed — but the vendor software (e.g., HiMOS) typically only refreshes once every 1–2 seconds, with no data export or cost tracking. For anyone who wants to:\n\n- **Monitor electricity costs** — know exactly how much it costs to run your PC per day/week/month\n- **Integrate power data** into research workflows, home automation, or dashboards\n- **Push the sampling rate** — Wattson queries at 300ms (3.3 Hz), 3–6× faster than vendor tools\n- **Understand the protocol** — reverse-engineer and document the binary serial protocol for future hardware\n\nWe built Wattson. It started with a Segotep DM-1000G and curiosity about what's actually on the wire. The protocol turned out to be straightforward (header + big/little-endian uint16 arrays + checksum), and the result is a general-purpose library that could support any digital PSU with similar serial protocols.\n\n数字电源通过 USB 暴露实时遥测数据，但厂商软件（如 HiMOS）刷新慢（1–2秒）、不能导出数据、没有电费统计。我们想知道开一天电脑到底花多少钱，想把功率数据接入自己的研究流程，想把采样率推到极限。于是从逆向鑫谷 DM-1000G 的串口协议开始，写了这个通用数字电源监控库。\n\n---\n\n## 📊 Real-time Monitoring / 实时监控\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"docs/screenshots/native-gui-live-dm1000g.png\" alt=\"Wattson Native GUI Dashboard — DM-1000G Live Monitoring\" width=\"820\"\u003e\n\n*Native GUI dashboard: `egui` + `wgpu`, exported from the app itself with live DM-1000G data*\n\n*原生 GUI 仪表盘：`egui` + `wgpu`，由应用内原生导出，展示 DM-1000G 实时数据*\n\n\u003c/div\u003e\n\n### Legacy TUI / 传统 TUI\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"docs/screenshots/legacy-tui-dashboard.png\" alt=\"Wattson TUI Dashboard — DM-1000G Real-time Monitoring\" width=\"680\"\u003e\n\n*TUI dashboard: power trend chart, DC rails, thermal \u0026 fan, cost tracking*\n\n*TUI 面板：功率趋势、DC 电压、温度风扇和电费统计*\n\n\u003c/div\u003e\n\n| Metric | Min | Max | Avg |\n|--------|-----|-----|-----|\n| AC Input Power | 133W | 236W | **162W** |\n| DC Output Power | 117W | 193W | 137W |\n| Efficiency | 82% | 91% | 86% |\n\n---\n\n## ✨ Features / 功能特点\n\n- **🖼️ Native GUI dashboard (`egui` + `wgpu`)** — GPU-backed desktop UI with live charts, theme switching, and control-side settings\n  原生桌面界面（`egui` + `wgpu`）— GPU 渲染实时图表、主题切换和图形控制设置\n- **📸 Native screenshot export** — export the complete GUI window from inside the app without depending on OS-level window capture\n  原生截图导出 — 由应用内部直接导出完整 GUI，不依赖操作系统层面的窗口抓屏\n- **🌀 Fan write control (`0x13` / `0x1B`)** — set fan mode, flat PWM, or custom curve through the same background serial session\n  风扇写入控制（`0x13` / `0x1B`）— 通过同一个后台串口会话设置风扇模式、固定占空比或自定义曲线\n- **🔌 Real-time power monitoring** — AC input (EMA-smoothed), DC output, conversion efficiency\n  实时功率监控 — AC 输入（EMA 平滑）、DC 输出、转换效率\n- **📈 TUI dashboard with live chart** — Dual-line power trend (AC red / DC cyan), auto-zoom Y-axis, Braille markers\n  TUI 面板 + 实时图表 — 双线功率趋势、自动缩放 Y 轴\n- **💰 Electricity cost tracking** — Session-wide average power → day/week/month projections. Energy accumulated via numerical integration (left Riemann sum, f64 precision — safe for years of continuous operation)\n  电费追踪 — 全程平均功率推算日/周/月费用，数值积分累加能量（f64 精度，可连续运行数年无溢出）\n- **📊 Chart generation** — Power/efficiency/temperature curves as PNG\n  图表生成 — 功率/效率/温度曲线\n- **🖥️ Three modes** — CLI (one-shot), TUI (dashboard), API (HTTP server)\n  三种传统模式仍保留 — 命令行、终端面板、HTTP API\n- **🌗 Theme support** — Light / Dark / System modes with persisted GUI settings\n  主题支持 — 浅色 / 深色 / 跟随系统，并持久化图形设置\n- **⚙️ Independent rate control** — TUI refresh (200ms–2s) and serial poll (200ms–5s) independently adjustable at runtime\n  独立速率控制 — TUI 刷新率和串口发包率运行时独立可调\n- **🔄 Active query by default** — 300ms poll interval, 3.3× faster than vendor software (HiMOS)\n  默认主动查询 — 300ms 轮询，比厂商软件快 3.3 倍\n\n### GUI Controls / 图形控制项\n\n| Control 控制 | Description 说明 |\n|--------------|------------------|\n| Theme 主题 | `System / Light / Dark` |\n| Chart Window 图表窗口 | 30–600 seconds |\n| UI Refresh 刷新率 | 16–1000 ms |\n| Serial Poll 轮询间隔 | 200–5000 ms |\n| Series 曲线显隐 | AC / DC independently toggleable |\n| Scale 缩放 | Auto / Zero Based |\n| Serial Visibility 序列号显示 | masked by default, optional full reveal 默认脱敏，可手动显示完整值 |\n| Screenshot Export 截图导出 | export the current GUI as PNG from inside the app 应用内直接导出当前 GUI 为 PNG |\n| Fan Mode 风扇模式 | `Auto / Silent / Performance / Custom / Clean` |\n| Manual PWM 固定占空比 | 0–100%, sends a flat custom curve |\n| Custom Curve 自定义曲线 | 3 editable control points + fixed `0C/100C` endpoints |\n\n### TUI Hotkeys / TUI 快捷键\n\n| Key 按键 | Action 功能 |\n|----------|------------|\n| `q` | Quit 退出 |\n| `a` / `s` / `p` / `u` / `c` | Set fan mode: auto / silent / performance / custom / clean 切换风扇模式 |\n| `h` / `l` | Decrease / increase manual PWM target by 5% 调整手动占空比目标 |\n| `m` | Apply current manual PWM target 应用当前手动占空比 |\n| `z` | Toggle chart scale: auto-zoom / zero-based 切换图表缩放模式 |\n| `+` / `-` | Adjust TUI refresh rate (200ms–2000ms) 调节画面刷新率 |\n| `]` / `[` | Adjust serial poll rate (200ms–5000ms) 调节串口发包率 |\n\n### Algorithm / 算法说明\n\n```\nAC Input    = EMA-smoothed instantaneous power (α=0.5)\n              EMA 平滑后的瞬时功率\n\nAC Average  = total_wh / duration_h  (session-wide, stabilizes over time)\n              全程累计能量 ÷ 运行时长 = 真实平均功率\n\nEnergy (Wh) = Σ P(tᵢ) × Δtᵢ  (numerical integration, f64 accumulator)\n              数值积分，每个 tick 累加 功率×时间间隔\n\nCost        = energy_kwh × price_per_kwh\nDaily est.  = session_avg_w × 24h / 1000 × price\n```\n\n---\n\n## 🔧 Supported Hardware / 支持的硬件\n\n| Brand 品牌 | Series 系列 | Interface 接口 | Status 状态 |\n|------------|-------------|---------------|-------------|\n| Segotep 鑫谷 | DM series (DM-850G, **DM-1000G**, ...) | CH340 UART 115200-8N1 | ✅ Tested 已验证 |\n| Segotep 鑫谷 | KE series (KE-1300P) | CH340 UART 115200-8N1 | 🔧 Compatible 兼容 |\n| *Others 其他* | *Contributions welcome 欢迎贡献* | — | — |\n\n---\n\n## 🚀 Quick Start / 快速开始\n\n### Install / 安装\n\n```bash\n# From source\ngit clone https://github.com/exomind-team/wattson.git\ncd wattson\ncargo build --release\n```\n\n### Initialize / 初始化\n\n```bash\n# Generate config file\nwattson config init\n\n# Check available ports\nwattson ports\n```\n\n### Usage / 使用\n\n```bash\n# Default desktop launch (GUI-first)  默认启动原生 GUI\nwattson\n\n# Native GUI with live PSU data  用真实电源数据启动 GUI\nwattson gui\n\n# Native GUI with deterministic demo data  用演示数据启动 GUI\nwattson gui --demo\n\n# One-shot read (JSON output)  一次读取\nwattson read\n\n# Read for 60 seconds  读取 60 秒\nwattson read --duration 60\n\n# Continuous JSON stream  持续输出\nwattson watch\n\n# Interactive TUI dashboard  交互式面板\nwattson tui\n\n# HTTP API server  API 服务器\nwattson serve\n\n# Set manual fan PWM (flat custom curve)  设置固定风扇占空比\nwattson fan set 55\n\n# Set fan mode  设置风扇模式\nwattson fan mode custom\n\n# Apply a custom curve  应用自定义风扇曲线\nwattson fan curve \"[[30,40],[50,55],[70,75]]\"\n\n# Generate chart  生成图表\nwattson chart --last 60\n```\n\n### Screenshot Export / 截图导出\n\n```bash\n# Launch the native GUI with live data  启动真实数据 GUI\nwattson gui\n\n# Launch the TUI dashboard  启动 TUI 面板\nwattson tui\n```\n\n- In the GUI, click `Export Screenshot 导出截图` to save a PNG into `docs/screenshots/`\n- GUI 导出走应用内原生渲染路径，不依赖外部窗口位置、焦点或整屏截图\n- TUI 截图当前作为文档资产维护在 `docs/screenshots/legacy-tui-dashboard.png`\n\n### Configuration / 配置管理\n\n```bash\n# View config  查看配置\nwattson config show\n\n# Set serial port  设置串口\nwattson config set port COM4\n\n# Set electricity price (CNY/kWh)  设置电价\nwattson config set price 0.56\n\n# Set communication mode  设置通信模式\nwattson config set mode passive\n```\n\n### API Endpoints / API 接口\n\nWhen running `wattson serve`:\n\n| Endpoint | Description |\n|----------|-------------|\n| `GET /api/status` | Full PSU snapshot 完整快照 |\n| `GET /api/power` | Power data only (AC/DC/efficiency) 功率数据 |\n| `GET /api/voltage` | DC voltage readings 电压 |\n| `GET /api/temperature` | Temperature sensors 温度 |\n| `GET /api/device` | Device info 设备信息 |\n| `GET /api/cost` | Electricity cost 电费 |\n| `POST /api/fan/speed` | Set flat PWM / 设置固定占空比 |\n| `POST /api/fan/curve` | Apply custom curve / 应用自定义曲线 |\n| `POST /api/fan/mode` | Set fan mode / 设置风扇模式 |\n| `GET /health` | Health check 健康检查 |\n\nExample requests / 请求示例：\n\n```bash\ncurl -X POST http://127.0.0.1:8066/api/fan/speed \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"pwm\":55}'\n\ncurl -X POST http://127.0.0.1:8066/api/fan/mode \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"mode\":\"custom\"}'\n\ncurl -X POST http://127.0.0.1:8066/api/fan/curve \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"points\":[[30,40],[50,55],[70,75]]}'\n```\n\n---\n\n## 🧪 Testing / 测试\n\n```bash\n# Full test suite  全量测试\ncargo test\n\n# GUI snapshot/e2e coverage  GUI 快照与端到端覆盖\ncargo test --test gui_e2e -- --nocapture\n```\n\n---\n\n## 📐 Configuration File / 配置文件\n\n`wattson.toml`:\n\n```toml\n[serial]\nport = \"COM4\"          # Serial port 串口\nbaud = 115200          # Baud rate 波特率\nmode = \"passive\"       # passive | active 被动|主动\n\n[device]\nprofile = \"segotep_dm\" # Device calibration profile 设备校准\n\n[cost]\nprice_per_kwh = 0.56   # Electricity price 电价 (CNY/kWh)\ncurrency = \"CNY\"       # Currency 货币\n\n[chart]\noutput_dir = \"./charts\"\nwatermark = \"Wattson | exomind-team/wattson\"\n\n[api]\nport = 8066            # HTTP API port\n```\n\n---\n\n## 🔬 Protocol Details / 协议细节\n\nWattson communicates with digital PSUs via USB serial (CH340/CH341 UART). The protocol uses a custom binary frame format:\n\n```\n[0x55][0x7E][LEN][CMD][DATA...][CHECKSUM][0xAE]\n```\n\n| Packet | Content | Byte Order |\n|--------|---------|------------|\n| `0x02` | Voltages, currents, AC input, fan RPM | Little-endian |\n| `0x03` | Device model string | ASCII |\n| `0x04` | Temperature, fan mode, AC power | Big-endian |\n| `0x05` | Serial number | ASCII |\n\nWrite support currently covers:\n\n- `0x13` fan mode\n- `0x1B` custom fan curve with `CRC-8 (poly=0x07, init=0x00)`\n\nSee [docs/protocol.md](docs/protocol.md) for reverse-engineering notes, frame samples, and current unknowns.\n\n---\n\n## 🙏 Acknowledgments / 致谢\n\nProtocol reverse engineering based on:\n- [YveMU/segotepk-psu-communication-protocol-driver](https://github.com/YveMU/segotepk-psu-communication-protocol-driver) — DM series protocol\n- [SaltyFishOnTheSea/Segotep-PSU-Toolbox](https://github.com/SaltyFishOnTheSea/Segotep-PSU-Toolbox) — KE-1300P protocol\n\n---\n\n## 📄 License / 许可证\n\n[CCOPL-1.0](LICENSE) — Contributors' Collective Ownership Public License\n\nCopyright (c) 2026 ExoMind Collective\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Part of the [ExoMind](https://github.com/exomind-team/exomind) ecosystem**\n\n[ExoMind](https://github.com/exomind-team/exomind) · [ExoMind Cell](https://github.com/exomind-team/exomind-cell) · [CCOPL License](https://github.com/exomind-team/ccopl)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexomind-team%2Fwattson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexomind-team%2Fwattson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexomind-team%2Fwattson/lists"}