Sensor Data Acquisition¶
Current API call sequence¶
Pass configuration to *_init(&config), bind the sensor with *_set_sensor_handle(sensor), then call *_start() without arguments. This online example assumes that MQTT and the sensor are already initialized.
#include "tiny_measurement.h"
#include "esp_err.h"
// sensor must point to an initialized ADXL355 handle.
esp_err_t start_online_example(adxl355_handle_t *sensor)
{
online_sensing_config_t config = {
.sampling_frequency_hz = 20.0f,
.enable_mqtt = true,
.enable_serial = true,
};
esp_err_t err = online_sensing_init(&config);
if (err != ESP_OK) return err;
err = online_sensing_set_sensor_handle(sensor);
if (err != ESP_OK) return err;
return online_sensing_start();
}
Offline uses offline_sensing_init, offline_sensing_set_sensor_handle and offline_sensing_start(); start blocks until that acquisition completes. Real-time uses rt_process_init, rt_process_set_sensor_handle and rt_process_start(). Run the modes separately rather than competing for the same sensor.
Frequency ranges below describe scenarios, not verified throughput or accuracy. Online initialization currently checks 0 < sampling_frequency_hz <= 300; sustained operation depends on sensor configuration, read time, transmission and buffering. Microsecond timestamp units do not establish response latency measured under load or synchronization error.
TinyMeasurement — The Data Acquisition Pipeline for SHM Nodes
From ADXL355 accelerometer readings to MQTT remote transmission. Covers three acquisition modes and three real-time processing architectures. Fully command-driven via MQTT.
Architecture¶
-
Online Acquisition
Continuous timer-based streaming (1~20 Hz)
MQTT / serial real-time output
Long-term structural monitoring -
Offline Acquisition
High-rate batch acquisition (100~4000 Hz)
Memory / SD card storage
MQTT report on completion
Modal analysis, impact testing -
RT Processing
Three compile-time architectures:
Ring buffer / DMA double buffer / Dual-core
Real-time threshold-triggered detection
Online damage detection -
Command Handler
MQTT remote commands → control acquisition
SENSE,ONLINE/OFFLINE/RT
Scheduled and delayed triggering -
WSN Time Sync (FTSP)
Flooding Time Synchronization Protocol over ESP-NOW
Gateway broadcasts periodic beacons + NTP world time
Leaf nodes run linear regression for clock skew correction
Sync visualization via RGB LED (marquee color cycling)
Microsecond timestamps · Drift estimation
Use Case Index¶
-
Long-term SHM monitoring
→ Online Acquisition, low rate (1~20 Hz), continuous MQTT upload
-
Impact testing / modal analysis
→ Offline Acquisition, high rate (100~4000 Hz), SD card storage
-
Real-time impact / damage detection
→ RT Processing + threshold trigger, response latency measured under load
-
Remote command & control
→ Command Handler, start/stop acquisition remotely via MQTT
Historical call example (retained for comparison)¶
The old start(&config) calls below do not match current headers. Use the initialize, bind, start sequence above.
Expand historical example
#include "tiny_measurement.h"
// === Online (long-term monitoring) ===
online_sensing_config_t online_cfg = {
.sampling_frequency_hz = 20.0f,
.enable_mqtt = true,
.enable_serial = true,
};
online_sensing_start(&online_cfg); // start 20 Hz streaming
// === Offline (modal test) ===
offline_sensing_config_t offline_cfg = {
.sampling_frequency_hz = 100.0f,
.sampling_duration_sec = 30.0f,
.enable_memory = true,
.enable_sd = true,
.enable_mqtt_report = true,
};
offline_sensing_start(&offline_cfg);
// === RT Processing (impact detection) ===
rt_process_config_t rt_cfg = {
.sampling_frequency_hz = 100.0f,
.enable_accel_detection = true,
};
rt_process_init(&rt_cfg);
rt_process_start();
Mode Comparison¶
| Online | Offline | RT Processing | |
|---|---|---|---|
| Rate | 1~20 Hz | 100~4000 Hz | 20~1000 Hz |
| Duration | Continuous | Bounded (seconds) | Continuous |
| Output | MQTT stream / serial | Memory / SD / MQTT report | Processed results |
| Use case | Long-term monitoring | Modal analysis | Impact/damage detection |
| Trigger | MQTT command | MQTT (supports delay) | MQTT + auto-threshold |
Dependency Chain¶
ADXL355 sensor → tiny_measurement → MQTT / SD card / serial
↑
tiny_ai (signal processing)
WSN time sync (FTSP):
Gateway: NTP (Internet) → tiny_toolbox/tiny_time → FTSP beacon (ESP-NOW)
Leaf: FTSP beacon → linear regression → world time @ µs precision
Code Structure¶
include/ tiny_measurement.h · tiny_measurement_config.h
online-sensing/ online acquisition
offline-sensing/ offline acquisition
command/ MQTT command parser
real-time-process-arch/ RT architectures (3 types)
wsn/ WSN utilities
time_sync/ FTSP time synchronization module
ftsp.h Unified entry header
ftsp_config.h Compile-time tuning (beacon interval, table size, ...)
ftsp_types.h Beacon packet layout (16 B basic / 26 B extended)
ftsp_gateway.h/.c Gateway periodic beacon broadcast
ftsp_leafnode.h/.c Leaf beacon sniffer + linear regression
ftsp_ntp.h/.c NTP sync recording & world-time anchor
ftsp_precision.h/.c Clock drift estimation & compensation (ppm)
ftsp_sync_viz.h/.c RGB LED sync status visualization
app/ application examples