u/Aziz_2002

STM32H7 Fatigue Detection: 1M Rows → 85k Rows, 512KB RAM, <100ms Inference — Is 4Hz Resampling the Right Move?

Building a real-time fatigue detection system for STM32H7 deployment.

Constraints:

  • 512KB RAM
  • <100ms inference
  • preprocessing on laptop
  • inference on-device only

Dataset:
~1M rows from asynchronous wearable sensors.

Sensor Native Frequency Notes
ACC 32 Hz wrist accelerometer
EDA 4 Hz electrodermal activity
Temp 4 Hz skin temperature
HR 1 Hz heart rate
Breathing 1 Hz respiration
IBI ~0.59 Hz irregular inter-beat interval

Labels:

  • fatigue
  • activity
  • baseline

Current preprocessing strategy:
Resample everything to 4Hz.

Signal Strategy
ACC 32→4Hz mean over 8 samples
EDA/Temp native 4Hz
HR 1→4Hz linear interpolation
Breathing 1→4Hz linear interpolation
IBI ~0.59→4Hz forward-fill

Result:
~1M rows → ~85k synchronized rows.

Current doubts:

  1. ACC u/4Hz: Using only the mean feels too lossy. Should I also include:
  • std
  • max/min
  • magnitude
  • energy

per 250ms window?

  1. IBI: Forward-fill feels mathematically dirty for HRV-related information. Would it be better to:
  • keep IBI irregular
  • compute RMSSD/SDNN at native timing
  • feed only HRV features downstream?
  1. HR/Breathing: Does interpolating 1Hz → 4Hz introduce fake temporal resolution? Would keeping them at 1Hz be cleaner?

Considering switching to a multi-rate pipeline:

Signal Group Frequency
ACC 8 Hz
EDA/Temp 4 Hz
HR/IBI/Breathing 1 Hz

Question:
For embedded ML / TinyML deployment, is multi-rate worth the added pipeline complexity, or is synchronized 4Hz generally the better engineering tradeoff?

Would appreciate advice from anyone working with:

  • wearable signals
  • HRV
  • TinyML
  • embedded inference
  • multimodal physiological data
reddit.com
u/Aziz_2002 — 16 hours ago

STM32H7 Fatigue Detection: 1M Rows → 85k Rows, 512KB RAM, &lt;100ms Inference — Is 4Hz Resampling the Right Move?

Building a real-time fatigue detection system for STM32H7 deployment.

Constraints:

  • 512KB RAM
  • <100ms inference
  • preprocessing on laptop
  • inference on-device only

Dataset:
~1M rows from asynchronous wearable sensors.

Sensor Native Frequency Notes
ACC 32 Hz wrist accelerometer
EDA 4 Hz electrodermal activity
Temp 4 Hz skin temperature
HR 1 Hz heart rate
Breathing 1 Hz respiration
IBI ~0.59 Hz irregular inter-beat interval

Labels:

  • fatigue
  • activity
  • baseline

Current preprocessing strategy:
Resample everything to 4Hz.

Signal Strategy
ACC 32→4Hz mean over 8 samples
EDA/Temp native 4Hz
HR 1→4Hz linear interpolation
Breathing 1→4Hz linear interpolation
IBI ~0.59→4Hz forward-fill

Result:
~1M rows → ~85k synchronized rows.

Current doubts:

  1. ACC to 4Hz: Using only the mean feels too lossy. Should I also include:
  • std
  • max/min
  • magnitude
  • energy

per 250ms window?

  1. IBI: Forward-fill feels mathematically dirty for HRV-related information. Would it be better to:
  • keep IBI irregular
  • compute RMSSD/SDNN at native timing
  • feed only HRV features downstream?
  1. HR/Breathing: Does interpolating 1Hz → 4Hz introduce fake temporal resolution? Would keeping them at 1Hz be cleaner?

Considering switching to a multi-rate pipeline:

Signal Group Frequency
ACC 8 Hz
EDA/Temp 4 Hz
HR/IBI/Breathing 1 Hz

Question:
For embedded ML / TinyML deployment, is multi-rate worth the added pipeline complexity, or is synchronized 4Hz generally the better engineering tradeoff?

Would appreciate advice from anyone working with:

  • wearable signals
  • HRV
  • TinyML
  • embedded inference
  • multimodal physiological data
reddit.com
u/Aziz_2002 — 16 hours ago

[Project Help] 1M rows → 85k after 4Hz resampling. Too aggressive for fatigue detection on STM32H7?

Hi r/learnmachinelearning

I'm building a **fatigue detection system** for **STM32H7** deployment and need sanity-check on my resampling strategy. Real data, real constraints.

---

## The Data (1M rows, multi-sensor wearable)

| Sensor File | Native Freq | Columns |

|-------------|-------------|---------|

| chest_physiology_summary.csv | **1 Hz** | breathing_rpm, heart-related |

| wrist_acc.csv | **32 Hz** | acc_x, acc_y, acc_z |

| wrist_eda.csv | **4 Hz** | eda |

| wrist_hr.csv | **1 Hz** | wrist_hr |

| wrist_ibi.csv | **~0.59 Hz** (irregular) | ibi |

| wrist_skin_temperature.csv | **4 Hz** | temp |

**Labels**: 3 classes — `fatigue` | `activity` | `baseline`

---

## My Resampling Strategy (4 Hz target)

I force everything to **4 Hz (1 sample every 250ms)** with sensor-specific tactics:

| Sensor | Native Freq | Strategy at 4 Hz | Rationale |

|--------|-------------|------------------|-----------|

| **ACC** (x,y,z) | 32 Hz | **Downsampling** — mean of 8 samples per 250ms window | Reduces noise, keeps motion intensity |

| **EDA** | 4 Hz | **Direct** — already native | No transformation needed |

| **HR** | 1 Hz | **Upsampling** — linear interpolation | Smooth cardiac trend between beats |

| **IBI** | ~0.59 Hz (irregular) | **Forward-fill** — hold last known value until next event | Physiologically honest for beat-to-beat intervals |

| **Temp** | 4 Hz | **Direct** — already native | No transformation needed |

| **Breathing** | 1 Hz | **Upsampling** — linear interpolation | Slow signal, interpolation safe |

**Result**: 1,000,000 rows → **~85,000 rows**

NaN reduced by ~90%, but **is this too much compression?**

---

## The Core Tension

| Argument FOR 4 Hz | Argument AGAINST 4 Hz |

|-------------------|----------------------|

| STM32H7 has ~512KB RAM — can't buffer 32Hz streams | ACC at 32Hz captures micro-movements relevant to fatigue? |

| 85k rows is manageable for training | Lost 91.5% of raw data — am I throwing away signal? |

| Fatigue is slow (minutes-scale) | EDA peaks might need >4Hz resolution? |

| Deterministic preprocessing for edge | IBI forward-fill at 4Hz = last value held for ~1.7s (since native is 0.59Hz) |

---

## Specific Doubts

**1. ACC downsampling 32→4 Hz**

- I take `mean` of 8 samples per 250ms window

- Should I add `std`, `max`, `min` to preserve variance?

- Is `magnitude = sqrt(x²+y²+z²)` at 4Hz enough for fatigue detection?

**2. HR upsampling 1→4 Hz**

- Linear interpolation between heartbeats — creates smooth but artificial curve

- Alternative: keep HR at 1Hz, accept misaligned timestamps?

**3. IBI forward-fill at 4 Hz**

- Native ~0.59Hz → one real value every ~1.7 seconds

- At 4Hz, I repeat that value 6-7 times before next real measurement

- This feels wrong for HRV analysis. Better to compute RMSSD at native 0.59Hz then upsample the *feature*?

**4. EDA at 4 Hz**

- Native frequency — but should I extract `phasic` (peaks) vs `tonic` (baseline) components before resampling?

- Anyone used `cvxEDA` or similar at edge scale?

---

## What I Need From You

  1. **Is 4 Hz defensible?** For fatigue detection (not micro-sleep), do I need ACC at 32Hz or is magnitude/std at 4Hz sufficient?

  2. **Multi-rate alternative?** Keep ACC at 8-16Hz, rest at 1-4Hz? Anyone done this for edge AI with aligned inference?

  3. **IBI handling** — forward-fill feels dirty for HRV. Compute features (RMSSD, pNN50) at native frequency, then resample *features*?

  4. **Feature sanity check** — my planned features:

    - ACC: `mean`, `std`, `max`, `min`, `magnitude`

    - EDA: `mean`, `std`, `slope`, `peak_count`, `tonic`, `phasic`

    - HR/IBI: `mean`, `std`, `rmssd`, `pnn50`

    - Temp: `mean`, `slope`

    - Breathing: `mean`, `dominant_freq`

    Missing anything critical for fatigue?

  5. **Class imbalance** — expecting ~70% baseline, 20% activity, 10% fatigue. SMOTE before edge? Or class-weighted loss only?

---

## Hard Constraints (non-negotiable)

- **Target**: STM32H7 @ 480MHz, ~512KB RAM

- **Inference**: < 100ms

- **Model**: quantized small MLP or Random Forest (TFLite Micro / ONNX)

- **Preprocessing**: must run on device — no pandas at inference time!

---

## My Current Lean

**Keep 4 Hz for EDA/Temp (native), but reconsider others:**

- ACC: **8 Hz** (mean + std + magnitude) — compromise between signal and size

- HR: **1 Hz** (no interpolation, last known value) — honest but misaligned

- IBI: **compute HRV features at native 0.59Hz**, then forward-fill *features* to 4Hz

- Breathing: **1 Hz** (native from chest sensor)

But this creates **multi-rate features** that need alignment logic. Worth the complexity?

---

## What I Can Share

- NaN heatmap before/after resampling (visual)

- Pandas resampling code snippet

- Per-participant class distribution

- Early baseline model results (if any)

**Has anyone prepped async physiological sensors for edge AI at this scale? What would you do differently?**

Papers, repos, or "I tried this and it failed" all welcome. Thanks!

reddit.com
u/Aziz_2002 — 17 hours ago