← Back to the chapter · Previous detail · Next detail →

Technical detail · Edge Data: Semantic Compression and Pipelines

Factory FFT implementation

# Pseudocode for an edge processing pipeline (runs on ESP32 every 10 seconds)
def vibration_pipeline():
    # 1. Collect 10 seconds of data
    samples = collect_samples(rate=500, duration=10)  # 5000 samples

    # 2. Apply FFT (frequency-domain analysis)
    fft_result = numpy.fft.rfft(samples)  # -> 2501 nonnegative-frequency bins

    # 3. Extract critical frequency bins
    #    Bin width = 500 Hz / 5000 samples = 0.1 Hz per bin
    #    Bin index = frequency / bin_width
    bin_width = 500.0 / 5000  # 0.1 Hz per bin
    target_freqs = [50, 65, 80, 95, 110, 125, 140, 155, 170, 200]  # Hz
    bins = [fft_result[int(f / bin_width)] for f in target_freqs]
    # Ten complex FFT coefficients; select frequencies against fault traces.

    # 4. Quantize calibrated magnitudes to uint16 before transmission.
    # Pseudocode: calibrated_range defines magnitude units; saturate out-of-range values
    # and send scale/units metadata so the receiver can interpret each magnitude.
    magnitudes_u16 = quantize_to_uint16([abs(v) for v in bins], calibrated_range)
    transmit_to_cloud(magnitudes_u16)  # 10 x 2 bytes = 20 bytes vs 10,000 bytes

    return magnitudes_u16

# Data reduction: 5000 int16 samples -> ten uint16 magnitudes = 500x by payload bytes

← Back to the chapter · Previous detail · Next detail →