Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiBand Heart Rate Monitor

For miband 4~7, checkout miband-4-to-7 tag

对于小米手环 4~7,请切换到 miband-4-to-7 标签

Real-time heart rate monitoring for Xiaomi Smart Bands via BLE, with a web dashboard, persistent history, and automatic reconnection.

通过 BLE 接收小米手环心率广播数据,提供 Web 仪表盘实时显示、历史记录查询和断线自动重连。

✨ Features

  • 实时心率监控 — 通过 BLE 接收手环”运动心率广播”数据
  • Web 仪表盘http://127.0.0.1:8765 实时动态心率 + 心跳动画
  • 历史分析面板/history 查看趋势图、心率区间分布、应用窗口统计
  • SQLite 持久化 — 心率数据自动存入数据库,支持按天/周/月查询
  • 窗口追踪 — 记录每个心率值对应的前台窗口和进程名称
  • SSE 实时推送 — Server-Sent Events 推送到前端,无需轮询
  • 断线自动重连 — 15s 超时检测静默断连 + 指数退避重连(2s→60s)
  • 补偿式退避 — 重连失败后间隔逐步增大,成功后立即重置

Supported Platform

基于 bluest 跨平台 BLE 库:

Bluest is a cross-platform Bluetooth Low Energy (BLE) library for Rust. It currently supports Windows (version 10 and later), MacOS/iOS, and Linux. Android support is planned.

  • Windows 10/11
  • MacOS/iOS
  • Linux

Supported MiBands

型号 状态
Xiaomi Smart Band 9 Pro ✅ 已测试
MiBand 10 / NFC ✅ 已测试
MiBand 4~7 切换到 miband-4-to-7 标签

Quick Start

前置条件

  1. 在手环设置中开启心率广播功能
  2. 电脑支持 BLE(蓝牙低功耗)

运行

cargo run --release

打开浏览器访问:

  • 实时仪表盘:http://127.0.0.1:8765
  • 历史分析:http://127.0.0.1:8765/history

API

端点 说明
/ 实时心率仪表盘
/history 历史数据分析面板
/events SSE 事件流(实时心率推送)
/api/records?range=today|7d|30d JSON 心率记录
/api/stats?range=today|7d|30d JSON 统计摘要
/api/recent?limit=50 JSON 最近记录

Screenshot

Alt text

About

OBS直播显示小米手环 “运动心率广播” Demo

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages