Skip to content

Latest commit

 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stm32-edge-pdm

STM32F407 edge-AI node for industrial motor predictive maintenance: vibration/sound sensing, on-device anomaly detection (X-CUBE-AI), local alarm, and WiFi data upload.

Edge-AI Predictive Maintenance Node for Industrial Equipment

A compact, attachable monitoring node for industrial equipment (motors, pumps) built on the STM32F407. It acquires vibration (MPU6050) and acoustic (MAX9814) signals, performs on-device signal processing and AI inference (X-CUBE-AI / CMSIS-NN) to classify equipment health, raises local alerts via OLED + buzzer, and streams data to a Python host dashboard over WiFi (ESP8266).

Features (three-tier roadmap)

  • P0 (basic): vibration acquisition + FFT spectrum + threshold alarm + OLED display
  • P1 (core): AI anomaly detection + on-device inference + upload to host PC
  • P2 (bonus): multi-node networking + history trend + low-power sleep

Repository structure

Path Contents
hardware/ Schematic (立创 EDA), Gerber, BOM.csv, pin map
firmware/ STM32CubeMX .ioc, Core/Src+Core/Inc (app), hardware/ (BSP 初始化), FreeRTOS 配置
algorithm/ Python training scripts, feature extraction, X-CUBE-AI model
host/ Python PyQt/Tkinter dashboard
docs/ Communication protocol, architecture, reports

Hardware (overview)

  • MCU: STM32F407ZGT6
  • Vibration: MPU6050 (×2)
  • Acoustic: MAX9814
  • Display: 0.96" I2C SSD1306 OLED
  • Wireless: ESP-01S (ESP8266)
  • Alarm: active buzzer + OLED
  • Power: 3.7V Li-ion + TP4056 + AMS1117-3.3V

See hardware/BOM.csv for the full list.

Status

Project start: 2026-07-20. Currently in remote-collaboration phase (Week 1). 环境已搭好(2026-07-23):

  • host/:Python 隔离 venv + 全套依赖(numpy/scipy/pyserial/matplotlib/PyQt6/scikit-learn/pandas);protocol_parser(CRC 与固件逐位一致,已自测)、serial_monitordashboard(PyQt6)、traincwru_prepare 均已跑通
  • firmware/:应用层骨架完整(config + 4 驱动桩 + 通信协议 + FreeRTOS 任务框架),引脚对齐 hardware/pin_map.csv
  • CubeMX .ioc 底座(2026-07-28):FreeRTOS(CMSIS_V2) + 4 任务(Acquire/Process/Display/Comms)、时钟树 168MHz、TIM4_CH3 PWM 输出、ADC1 DMA Circular、PC0/PC1/PC2/PA0 上拉 —— 已直接写入 .ioc 文本(非 GUI 点击)。待 master 双击 .ioc 用 CubeMX 打开确认无误 → 点 Generate Code → Keil 中 build 验证。
  • 固件结构优化(2026-07-28)main.c 精简为入口(HAL_Init → Hardware_Init → APP_Init),所有外设初始化(时钟 / ADC+DMA / I2C / TIM4 PWM / TIM5 时基 / UART / GPIO)迁入新 firmware/hardware/ BSP 模块(hardware.c / hardware.h),已接入 Keil Hardware/BSP 分组与 ../hardware 包含路径,armcc 独立编译验证通过。
  • 待完成:频域特征 CMSIS-DSP 实现、X-CUBE-AI 推理、Keil build 验证、真实硬件移植(9 月集中期)

各子目录 README 有详细状态与用法。

Firmware module switches(模块开关)

固件代码通过集中式功能开关统筹,方便三人分工时各自剔除不负责的模块、缩小编译体积、或隔离调试。所有开关集中在 firmware/Core/Inc/config.h 顶部的 MODULE ENABLE SWITCHES 段,默认全部开启(编译结果与原先一致):

#define USE_MPU6050       1   /* 振动传感器 MPU6050 驱动 + 任务采集 */
#define USE_MAX9814       1   /* 麦克风 MAX9814 驱动 */
#define USE_SSD1306       1   /* OLED 显示 SSD1306 驱动 + 任务显示 */
#define USE_ESP8266       1   /* WiFi ESP8266 AT 驱动 + 任务通信 */
#define USE_PROTOCOL      1   /* 通信帧 protocol(CRC 与 host 逐位一致) */
#define USE_FEATURES_MCU  1   /* 边缘特征提取 features_mcu(CMSIS-DSP 待补) */
#define USE_TASKS         1   /* FreeRTOS 任务编排 tasks(APP_Init 启动 4 任务) */

关闭某个模块:把对应的 1 改成 0 即可,无需删代码——该模块的 .c 实现体与 .h 声明均被 #ifdef USE_<模块> 包裹整体排除,tasks.c 中的对应初始化/调用也受同开关保护。例如只做算法验证、不想编 WiFi:

#define USE_ESP8266       0

此时 ESP8266_* 函数与 Comms 任务内的 WiFi 调用都不会进入编译。已用 armcc 验证两条路径均零错误:默认全开(9 个 .c 全部通过)与 6 个业务模块全关(仅留 USE_TASKS=1

几个约定(避免踩坑):

  • main.h 已瘦成纯函数引用枢纽——只 #include 各模块头 + 声明 Hardware_Init / APP_Init / Error_Handler。外设句柄(hadc1/hi2c1/...)的 extern 已移到 firmware/hardware/hardware.h,改硬件时认准这里。
  • 若用 CubeMX GUI 重新 Generate Code,它会在 main.c 重新塞入 MX_*_Init(),与 hardware.c 中的同名函数重复 → 链接报错。处理法见 firmware/CUBEMX_FIXES.md 末尾:Generate 后删掉 main.c 里自动生成的那几个函数体、保留 Hardware_Init() 调用即可。
  • USE_TASKS=0APP_Init() 不创建任何任务,main() 仅空转——适合裸机调 BSP 初始化。

Quick start (software lead)

cd host && .venv\Scripts\activate
python protocol_parser.py          # 协议自测
python serial_monitor.py --list    # 看串口
python train.py --samples 400      # 训练阈值/质心 -> models/

Team & Roles

  • Hardware lead — schematic / PCB / soldering / power
  • Software lead (captain) — STM32 firmware / FreeRTOS / protocol
  • Algorithm lead — ML model / signal processing / host GUI

License

See LICENSE.

About

STM32F407 edge-AI node for industrial motor predictive maintenance: vibration/sound sensing, on-device anomaly detection (X-CUBE-AI), local alarm, and WiFi data upload.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages