← Back to the chapter · Previous detail · Next detail →
Technical detail · Edge Acquisition: Power Budgets and Pipelines
Exercise the factory motor example
The example adds noise around small accelerations, with 1g gravity on Z, then prints the summary and bandwidth estimate. The displayed values illustrate one run.
# Simulate: factory motor vibration monitoring
agg = IMUEdgeAggregator(sample_rate_hz=100, window_sec=1)
# Feed 100 simulated samples (1 second of data)
import random
for i in range(100):
# Normal vibration: small accelerations around 0g with noise
agg.add_sample(
ax=random.gauss(0, 0.05), ay=random.gauss(0, 0.05),
az=random.gauss(1.0, 0.03), # 1g gravity on Z
gx=random.gauss(0, 2), gy=random.gauss(0, 2),
gz=random.gauss(0, 1)
)
if agg.window_ready():
summary = agg.compute_summary()
print("1-second summary (transmitted via LoRa):")
for key, val in summary.items():
print(f" {key}: {val}")
bw = agg.estimate_bandwidth()
print(f"\nBandwidth: {bw['raw_bytes_per_sec']} B/s raw -> "
f"{bw['summary_bytes_per_sec']} B/s summary = "
f"{bw['reduction_ratio']} reduction")
# Output:
# 1-second summary (transmitted via LoRa):
# timestamp: 1738900000
# samples: 100
# accel_x_rms: 0.0498
# accel_x_peak: 0.1523
# accel_y_rms: 0.0512
# accel_y_peak: 0.1389
# accel_z_rms: 1.0004
# accel_z_peak: 1.0891
# gyro_x_rms: 1.98
# gyro_y_rms: 2.05
# gyro_z_rms: 0.99
#
# Bandwidth: 1200 B/s raw -> 18 B/s summary = 67x reduction