跳到主要内容
极客日志极客日志面向AI+效率的开发者社区
首页博客GitHub 精选镜像AI 生图工具UI配色美学隐私政策关于联系
搜索内容 / 工具 / 仓库 / 镜像...⌘K搜索
注册
博客列表
编程语言

ESP32 ESPectre 结合 Grafana 实现专业级 CSI 运动监控

ESP32 ESPectre 配合 Home Assistant、InfluxDB 及 Grafana 搭建 Wi-Fi CSI 运动监测方案。通过采集信道状态信息生成波形图与强度曲线,实现多房间实时监控。配置涵盖硬件环境、数据流链路、数据库集成及可视化仪表板导入,支持跌倒检测等场景应用。

Eee_123发布于 2026/4/11更新于 2026/7/2030 浏览
ESP32 ESPectre 结合 Grafana 实现专业级 CSI 运动监控

本方案基于 ESP32 ESPectre 与 Grafana 构建专业级 CSI 监控面板,输出波形图、运动强度曲线及多房间监控视图。

一、整体数据流

1. 硬件环境

ESP32S3 Dev Module 开发板(主要是国内兼容版本的 ESP32S3-N16R8 开发板)

2. 软件环境

  • ESPectre(ESP32)
  • Home Assistant
  • InfluxDB 数据库(存历史数据)
  • Grafana(可视化面板)

建议使用 Linux 服务器部署,可通过 1Panel 等面板工具简化 InfluxDB 等服务组件的安装。

3. 整体数据流

ESP32 ESPectre → ESPHome → Home Assistant → InfluxDB 2.8 → Grafana 专业面板

ESP32 (ESPectre) ↓(ESPHome 本地直连) Home Assistant(已实现) ↓(HA 自带集成:自动转发) InfluxDB(存历史数据) ↓ Grafana(专业可视化)

二、HA 配置 InfluxDB 集成

1. 安装 InfluxDB

你可以用 1Panel / 群晖 / Docker 安装。

创建数据库名:homeassistant

2. HA 里添加 InfluxDB 集成

  1. 打开 Home Assistant
  2. 设置 → 设备与服务 → 添加集成
  3. 搜索 InfluxDB
  4. 输入以下信息:
    • URL:http://IP:8086(不能漏 http://,不能加 https)
    • 组织:你的 InfluxDB 组织名
    • 数据库:homeassistant
    • API 令牌:InfluxDB 管理员全局 Token

配置完成后,HA 会自动将实体数据写入 InfluxDB,包括:

  • sensor.movement_score
  • binary_sensor.motion_detected
  • 所有 ESPHome 设备数据

在 HA 的 configuration.yaml 文件中添加 influxdb 的序列化数据条目:

# INFLUXDB 2.x 写入配置(直接复制)
influxdb:
  include:
    entities:
      - sensor.espectre_movement_score
      - binary_sensor.espectre_motion_detected

三、InfluxDB 测试数据源

1. Home Assistant 端验证

HA 里应能看到:

  • 运动强度 Movement Score
  • 运动检测
  • 校准开关
  • 2. InfluxDB 端验证

    1. 打开 InfluxDB 2.8 → Data Explorer
    2. 选择 Bucket:homeassistant
    3. 筛选 measurement:sensor.movement_score

    只要出现数据即表示成功。

    四、Grafana 配置 InfluxDB 数据源

    1. 数据源配置

    1. 打开 Grafana → 左侧边栏 ⚙️ Configuration → Data sources
    2. 点击 Add data source,选择 InfluxDB

    2. 关键参数填写

    配置项填写内容注意事项
    Query LanguageFlux必须选 Flux!InfluxDB 2.x 不支持 InfluxQL
    URLhttp://你的 InfluxDB 服务器 IP:8086必须加 http://,不能漏端口 8086
    Organization你的 InfluxDB 组织名和 InfluxDB 网页里的组织名完全一致(大小写敏感)
    TokenInfluxDB 管理员全局 Token复制 InfluxDB → Load Data → API Tokens 里的 All Access Token
    Default Buckethomeassistant你提前建好的桶名,大小写一致
    Min time interval5s匹配 ESPectre 数据上报频率,保证曲线流畅

    3. 测试连通性

    拉到页面最底部,点击 Save & test。

    • 显示 Data source is working:配置成功
    • 报错:检查 Token 权限、Bucket 名、IP 端口、防火墙

    五、Grafana 查询 ESPectre 数据

    1. 测试 Flux 语句

    from(bucket: "homeassistant") |> range(start: -1h) |> filter(fn: (r) => r["_measurement"] == "sensor.espectre_movement_score") |> filter(fn: (r) => r["_field"] == "value") |> yield()
    

    2. 查询内容

    • 查 最近 1 小时
    • 查你的实体 sensor.espectre_movement_score
    • 最简单、最快、不报错

    六、导入仪表板

    1. 操作步骤

    1. 点击「导入仪表板」按钮。
    2. 选择 JSON 文件,弹出窗口后点击'从文件上传',找到下载的 JSON 文件选中。
    3. 下方会出现一个'导入'按钮,点击它,仪表盘就会自动生成。

    仪表盘 JSON 文件:

    {
      "annotations": {
        "list": [
          {
            "builtIn": 1,
            "datasource": {
              "type": "grafana",
              "uid": "-- Grafana --"
            },
            "enable": true,
            "hide": true,
            "iconColor": "rgba(0, 211, 255, 1)",
            "name": "Annotations & Alerts",
            "type": "dashboard"
          }
        ]
      },
      "editable": true,
      "fiscalYearStartMonth": 0,
      "graphTooltip": 0,
      "links": [],
      "panels": [
        {
          "datasource": {
            "type": "influxdb",
            "uid": "influxdb"
          },
          "description": "ESPectre Wi-Fi CSI 实时运动强度曲线",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "palette-classic"
              },
              "custom": {
                "axisBorderShow": false,
                "axisCenteredZero": false,
                "axisColorMode": "text",
                "axisLabel": "活动强度 Movement Score",
                "axisPlacement": "auto",
                "barAlignment": 0,
                "barWidthFactor": 0.6,
                "drawStyle": "line",
                "fillOpacity": 30,
                "gradientMode": "none",
                "hideFrom": {
                  "legend": false,
                  "tooltip": false,
                  "viz": false
                },
                "insertNulls": false,
                "lineInterpolation": "linear",
                "lineWidth": 2,
                "pointSize": 5,
                "scaleDistribution": {
                  "type": "linear"
                },
                "showPoints": "never",
                "showValues": false,
                "spanNulls": true,
                "stacking": {
                  "group": "A",
                  "mode": "none"
                },
                "thresholdsStyle": {
                  "mode": "area"
                }
              },
              "mappings": [],
              "max": 0.001,
              "min": 0,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "red",
                    "value": 0
                  },
                  {
                    "color": "yellow",
                    "value": 0.0001
                  },
                  {
                    "color": "green",
                    "value": 0.0002
                  }
                ]
              },
              "unit": "short"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 10,
            "w": 24,
            "x": 0,
            "y": 0
          },
          "id": 1,
          "options": {
            "legend": {
              "calcs": [
                "mean",
                "max",
                "min",
                "last"
              ],
              "displayMode": "table",
              "placement": "bottom",
              "showLegend": true
            },
            "tooltip": {
              "hideZeros": false,
              "max": true,
              "mode": "single",
              "sort": "none"
            }
          },
          "pluginVersion": "12.4.2",
          "targets": [
            {
              "datasource": {
                "type": "influxdb",
                "uid": "influxdb"
              },
              "query": "from(bucket: \"homeassistant\")\n |> range(start: -24h)\n |> filter(fn: (r) => r[\"_measurement\"] == \"sensor.espectre_movement_score\")\n |> filter(fn: (r) => r[\"_field\"] == \"value\")\n |> aggregateWindow(every: 30s, fn: mean)\n |> yield()",
              "refId": "A",
              "type": "flux"
            }
          ],
          "title": "ESPectre 实时 Movement Score 曲线(养老看护)",
          "type": "timeseries"
        },
        {
          "datasource": {
            "type": "influxdb",
            "uid": "influxdb"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "max": 0.001,
              "min": 0,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "red",
                    "value": 0
                  },
                  {
                    "color": "yellow",
                    "value": 0.0001
                  },
                  {
                    "color": "green",
                    "value": 0.0002
                  }
                ]
              },
              "unit": "short"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 8,
            "x": 0,
            "y": 10
          },
          "id": 2,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "auto",
            "percentChangeColorMode": "standard",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "showPercentChange": false,
            "textMode": "auto",
            "wideLayout": true
          },
          "pluginVersion": "12.4.2",
          "targets": [
            {
              "datasource": {
                "type": "influxdb",
                "uid": "influxdb"
              },
              "query": "from(bucket: \"homeassistant\")\n |> range(start: -5m)\n |> filter(fn: (r) => r[\"_measurement\"] == \"sensor.espectre_movement_score\")\n |> filter(fn: (r) => r[\"_field\"] == \"value\")\n |> last()\n |> yield()",
              "refId": "A",
              "type": "flux"
            }
          ],
          "title": "当前实时 Movement Score",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "influxdb",
            "uid": "influxdb"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [
                {
                  "options": {
                    "0": {
                      "color": "green",
                      "index": 1,
                      "text": "静默"
                    },
                    "1": {
                      "color": "red",
                      "index": 0,
                      "text": "活动"
                    }
                  },
                  "type": "value"
                }
              ],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": 0
                  },
                  {
                    "color": "red",
                    "value": "on"
                  }
                ]
              },
              "unit": "none"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 8,
            "x": 8,
            "y": 10
          },
          "id": 3,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "auto",
            "percentChangeColorMode": "standard",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "showPercentChange": false,
            "textMode": "auto",
            "wideLayout": true
          },
          "pluginVersion": "12.4.2",
          "targets": [
            {
              "datasource": {
                "type": "influxdb",
                "uid": "influxdb"
              },
              "query": "from(bucket: \"homeassistant\")\n |> range(start: -5m)\n |> filter(fn: (r) => r[\"_measurement\"] == \"binary_sensor.espectre_motion_detected\")\n |> filter(fn: (r) => r[\"_field\"] == \"value\")\n |> last()\n |> yield()",
              "refId": "A",
              "type": "flux"
            }
          ],
          "title": "当前检测状态",
          "type": "stat"
        },
        {
          "datasource": {
            "type": "influxdb",
            "uid": "influxdb"
          },
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "max": 0.001,
              "min": 0,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "red",
                    "value": 0
                  },
                  {
                    "color": "yellow",
                    "value": 0.0001
                  },
                  {
                    "color": "green",
                    "value": 0.0002
                  }
                ]
              },
              "unit": "short"
            },
            "overrides": []
          },
          "gridPos": {
            "h": 4,
            "w": 8,
            "x": 16,
            "y": 10
          },
          "id": 4,
          "options": {
            "colorMode": "value",
            "graphMode": "none",
            "justifyMode": "auto",
            "orientation": "auto",
            "percentChangeColorMode": "standard",
            "reduceOptions": {
              "calcs": [
                "min"
              ],
              "fields": "",
              "values": false
            },
            "showPercentChange": false,
            "textMode": "auto",
            "wideLayout": true
          },
          "pluginVersion": "12.4.2",
          "targets": [
            {
              "datasource": {
                "type": "influxdb",
                "uid": "influxdb"
              },
              "query": "from(bucket: \"homeassistant\")\n |> range(start: -24h)\n |> filter(fn: (r) => r[\"_measurement\"] == \"sensor.espectre_movement_score\")\n |> filter(fn: (r) => r[\"_field\"] == \"value\")\n |> filter(fn: (r) => r[\"_value\"] > 0)\n |> min()\n |> yield()",
              "refId": "A",
              "type": "flux"
            }
          ],
          "title": "24 小时最低分值",
          "type": "stat"
        }
      ],
      "preload": false,
      "refresh": "5s",
      "schemaVersion": 42,
      "tags": [
        "ESPectre",
        "Wi-Fi CSI",
        "养老看护",
        "监控大屏"
      ],
      "templating": {
        "list": []
      },
      "time": {
        "from": "now-24h",
        "to": "now"
      },
      "timepicker": {},
      "timezone": "Asia/Shanghai",
      "title": "ESPectre 养老看护 Wi-Fi CSI 专业监控大屏",
      "uid": "espectre-elderly-final-final",
      "version": 3,
      "weekStart": ""
    }
    

    2. 曲线解读

    • 红色区域(<0.0001):长期静默,老人躺卧 / 不动,属于正常状态,可作为跌倒 / 异常告警的触发阈值
    • 黄色区域(0.0001~0.0002):低活动,老人轻微动作
    • 绿色区域(>0.0002):正常活动,老人走动 / 起身,20:20 后的峰值就是典型的活动信号
    • 统计值:Mean (均值 0.000106)、Max (峰值 0.000461)、Min (最低 0.000181,修复后显示真实值)、Last (当前 0.0000636,静默状态)

    目录

    1. 一、整体数据流
    2. 1. 硬件环境
    3. 2. 软件环境
    4. 3. 整体数据流
    5. 二、HA 配置 InfluxDB 集成
    6. 1. 安装 InfluxDB
    7. 2. HA 里添加 InfluxDB 集成
    8. INFLUXDB 2.x 写入配置(直接复制)
    9. 三、InfluxDB 测试数据源
    10. 1. Home Assistant 端验证
    11. 2. InfluxDB 端验证
    12. 四、Grafana 配置 InfluxDB 数据源
    13. 1. 数据源配置
    14. 2. 关键参数填写
    15. 3. 测试连通性
    16. 五、Grafana 查询 ESPectre 数据
    17. 1. 测试 Flux 语句
    18. 2. 查询内容
    19. 六、导入仪表板
    20. 1. 操作步骤
    21. 2. 曲线解读
    • 免费图片AI生成工具免费生成了解详情
    • Magick API 一键接入全球大模型注册送1000万token查看
    • 免费图片视频在线生成30秒,将你的创意变成现实开始设计
    • X/Twitter免费视频下载器免登陆无限额度免费视频解析下载了解详情
    • 100+免费在线小游戏爽一把
    极客日志微信公众号二维码

    微信扫一扫,关注极客日志

    微信公众号「极客日志V2」,在微信中扫描左侧二维码关注。展示文案:极客日志V2 zeeklog

    更多推荐文章

    查看全部
    • 10 个实用且有趣的 Linux 命令行工具介绍
    • defer 学习指南
    • PostgreSQL 与 StackBuilder 安装配置指南
    • Vue3 环境下 vue-simple-uploader 进度条异常修复与源码适配
    • Generative UI 如何重塑 AI 时代的前端交互
    Flutter 三方库 webdriver 的鸿蒙化适配指南
  • 利用 OpenClaw 与 Claude 构建自动化写作工作流
  • Vue 基础入门教程(一)
  • 开源低代码平台 Microi 吾码:架构、部署与核心功能解析
  • JDK 17 安装与环境配置实战指南
  • Ubuntu 下 llama.cpp 编译与性能调优实战
  • 大模型算法岗常见面试题及核心技术解析
  • 昇腾 Ops-CV 库:AIGC 多模态视觉生成加速方案
  • Python 字典 dict 的常用用法与底层原理
  • Docker 安装 OpenClaw 常见报错排查:配对、权限及镜像拉取问题
  • Linux 进程间通信:匿名管道原理与实现
  • LangChain 实战:基于网页数据的 RAG 问答及来源溯源
  • 产品经理的多维度划分与进阶路径
  • SpringCloud 微服务支付全链路生产级实践:接口对接与状态闭环
  • Web 自动化测试入门:从概念到百度搜索实战
  • 相关免费在线工具

    • Base64 字符串编码/解码

      将字符串编码和解码为其 Base64 格式表示形式即可。 在线工具,Base64 字符串编码/解码在线工具,online

    • Base64 文件转换器

      将字符串、文件或图像转换为其 Base64 表示形式。 在线工具,Base64 文件转换器在线工具,online

    • Markdown转HTML

      将 Markdown(GFM)转为 HTML 片段,浏览器内 marked 解析;与 HTML转Markdown 互为补充。 在线工具,Markdown转HTML在线工具,online

    • HTML转Markdown

      将 HTML 片段转为 GitHub Flavored Markdown,支持标题、列表、链接、代码块与表格等;浏览器内处理,可链接预填。 在线工具,HTML转Markdown在线工具,online

    • JSON 压缩

      通过删除不必要的空白来缩小和压缩JSON。 在线工具,JSON 压缩在线工具,online

    • JSON美化和格式化

      将JSON字符串修饰为友好的可读格式。 在线工具,JSON美化和格式化在线工具,online