This repository contains firmware, data, and processing scripts for the Okto (ESP32-based) driveshaft strain measurement project used by McMaster Baja Racing. The project captures torsion and axial strain from an instrumented driveshaft and provides a lightweight Python pipeline to correct timestamps, filter / detrend signals, and save normalized outputs for analysis.
Contents:
firmware/— ESP32 code and calibration filesdata/— raw and processed CSV exports from the devicescripts/— Python scripts to correct timestamps, filter signals, and save normalized data
Quick summary:
- The ESP32 firmware records sensor data to an SD card. Two firmware variants are included:
millis_code/: samples at ~2 kHz but timestamps are written with a millisecond resolution (so consecutive samples can share the same millisecond value). The data files contain aTimestamp [ms]column.nanos_code/: samples at ~5 kHz and records timestamps in nanoseconds (Timestamp [ns]).
firmware/calibration/includes an Excel calibration sheet and example csv used to compute zero-offsets and linear multipliers for converting raw sensor counts to physical units (measured in a pure torsion setup).
Data layout:
data/0_raw/— CSV files straight from the ESP32 (filename prefixokto25_). These are unmodified exports.data/1_time_corrected/— CSV files produced by the time-correction step. All timestamp columns are converted to seconds, the first timestamp is zeroed, and known SD-flush/noise discontinuities are smoothed.data/2_normalized/— Final processed CSVs after filtering and EMD detrending. Signals are saved with the sameokto25_prefix and contain aTimestamp [s]column and processed measurement columns (e.g.,Torque [Nm]).
Notes:
- The
millis_codefirmware records timestamps inTimestamp [ms]. Because the sample rate (~2 kHz) is higher than millisecond resolution, there can be duplicate ms values._correct_time_msadjusts duplicates and fixes single-sample discontinuities (like SD flush artifacts) by interpolating a local mean and applying an offset to subsequent samples. - The
nanos_codefirmware recordsTimestamp [ns]._correct_time_nslooks for periodic flush boundaries (1 second) and corrects large jumps near those boundaries. - The EMD-based detrending (PyEMD) in
remove_slow_wave_emddecomposes the signal into intrinsic mode functions (IMFs). The code currently reconstructs the baseline as the difference between the original and the summed IMFs in the specifiedkeep_imfsrange — review thekeep_imfstuple to control which IMFs are treated as baseline vs signal. - Plots are generated when functions are called with
debug=Truewhich helps visualize filtering and detrending steps.