Lab: Sensor Streams and AI-Ready Windows
Course 1 · Module 5 Type: Hands-on lab (read sensors → filter/window → optional host view) Suggested time: 2.5–3.5 hours
Read first: Lesson · Cheatsheet · ← Table of Contents · ← M04 · M06 →
Note: the snippets in this lab use the API of the TESAIoT Bitstream firmware, which is not yet open source. See detail and equivalent examples in the public SDK in the note at the top of the lesson AI-ready Sensor Streams
Useful references during the lab
Section titled “Useful references during the lab”| Document | Use when |
|---|---|
| Lesson | sensor_*, fusion, SENSOR_CFG |
| TESAIoT Developer Hub | The Sensors domain |
| Hackathon web-app | ex01–ex06 to see values on the host |
| Bitstream Studio | The Sensor Telemetry deck |
Lab Goals
Section titled “Lab Goals”- Call
sensor_*_startup/readfor at least two kinds (e.g. SHT40 + BMI270) - Build a fixed-rate reading task with FreeRTOS
- Apply a filter or normalisation in at least one form in the lab code
- Build a data window from the IMU or a temperature series
- (Recommended) watch the stream in Bitstream Studio or the Hackathon web-app
- (Recommended) read a fusion result, or fire an event on a condition
Prerequisites
Section titled “Prerequisites”- Have passed M03 (UART) and M04 (can create tasks)
- The board has sensors matching the kit used
- Know which sensors are enabled in your firmware/project
Lab A — Bring-up two sensors (required)
Section titled “Lab A — Bring-up two sensors (required)”- Call
sensor_sht40_startup, then readtemperature/humidityand print to UART - Call
sensor_bmi270_startup(if not already started at boot), then readacc_* - Check
sensor_*_is_readybefore reading
Pass when: you get reasonable-looking values for both kinds on the terminal
Lab B — Fixed-rate sample task (required)
Section titled “Lab B — Fixed-rate sample task (required)”- Create a task that reads a sensor with
vTaskDelayUntil(e.g. SHT40 every 500–1000 ms, or BMI270 every 40 ms) - Record which period you chose and why
TickType_t last = xTaskGetTickCount();const TickType_t period = pdMS_TO_TICKS(40);for (;;) { (void)sensor_bmi270_read(&imu); vTaskDelayUntil(&last, period);}Pass when: the reading period is consistent, with no busy-waiting
Lab C — Filter + normalize (required)
Section titled “Lab C — Filter + normalize (required)”- Apply an EMA (or a short-window median) to temperature, or an acceleration axis
- Normalise at least one channel’s value into a given range (such as roughly [-1, 1], or 0..1)
- Print both the raw and the processed value
Pass when: you can explain how the filter reduces noise, from what you observe on the terminal
Lab D — Feature window (required)
Section titled “Lab D — Feature window (required)”- Build a ring buffer / window of at least 16–32 samples from BMI270 or a temperature series
- Once the window is full, compute at least one feature (such as mean, variance, max−min)
- Print the feature over UART periodically
Pass when: you get a summary vector from a full window at least once per second (or at a reasonable period)
Lab E — Choose one (recommended)
Section titled “Lab E — Choose one (recommended)”E1 Fusion orientation
Section titled “E1 Fusion orientation”cm55_imu_fusion_bridge_push_raw_components+get_latest_result- Print pitch/roll or
orientation
E2 Host telemetry
Section titled “E2 Host telemetry”- Flash/connect per your kit → open Bitstream Studio or the Hackathon
web-app - Confirm the sensor value on the host moves in step with the board
E3 Condition event
Section titled “E3 Condition event”- When the feature or the EMA exceeds a threshold → turn on the LED + print
EVENT ...
Pass when: you have completed one option with evidence (terminal / UI / LED)
Short report (8–12 lines)
Section titled “Short report (8–12 lines)”- The sensors used + the sampling period
- The filter / normalisation method
- The window size + the feature(s) computed
- (If any) the fusion result, or a host screenshot
- What you plan to send on to the cloud in M06 (a conceptual payload)
Troubleshooting
Section titled “Troubleshooting”| Symptom | Approach |
|---|---|
is_ready is false |
Not started up yet · the sensor isn’t built into the project · a bus problem |
| Reading works only sometimes | The period is too fast · the bus is contended with another task · try try_read / reduce the rate |
| The magnetometer won’t read through the I2C lock | The BMM350 is I3C — use sensor_bmm350_* per the SDK |
| Fusion doesn’t update | Raw data hasn’t been pushed yet · CM33 fusion isn’t running in the config you’re using |
| The host shows no value | Bitstream not Linked yet · the HEX/VSIX are mismatched versions · SENSOR_CFG disabled |
Submit checklist
Section titled “Submit checklist”- Labs A–D passed
- At least 1 item from Lab E
- The table in sensor-ai-prep.md filled in
- The short report completed
Lesson · Cheatsheet · Table of Contents · M06 →
Cite this lesson
If you teach from this lesson or reuse it in slides or documents, credit it with the text below. If you changed it, add (adapted) after the title.
"Lab: Sensor Streams and AI-Ready Windows" from TESA Open Knowledge by the Thai Embedded Systems Association (TESA), https://github.com/tesaiot/tesa-qualification-program, licensed under CC BY-NC 4.0
Thai attribution: "แล็บ: สตรีมเซ็นเซอร์และหน้าต่างข้อมูลพร้อม AI" จาก TESA Open Knowledge โดยสมาคมสมองกลฝังตัวไทย (Thai Embedded Systems Association: TESA) https://github.com/tesaiot/tesa-qualification-program สัญญาอนุญาต CC BY-NC 4.0
Lesson link: https://tesaiot.github.io/tesa-qualification-program/en/courses/firmware-sdk-edge-ai/m05-sensor-data/l02-lab/
This lesson adapts the source below; keep its credit too.
https://github.com/drsanti/TESAIoT-Courses/blob/287c21814ba8c75f693136616dcd270349a15966/C1/M05/lab.md · Original content by Asst. Prof. Dr. Santi Nuratch (ผศ.ดร.สันติ นุราช), KMUTT. Course 1 (C1/) of drsanti/TESAIoT-Courses. TESA funded the work and holds the rights; published here under CC BY-NC 4.0. The upstream repository carries no licence file. Text kept faithful; structure, front matter, quizzes and notes added by TESA Open Knowledge.
TESA Open Knowledge · © 2026 สมาคมสมองกลฝังตัวไทย (TESA) · CC BY-NC 4.0
Content is licensed CC BY-NC 4.0. Reuse it non-commercially and credit the Thai Embedded Systems Association (TESA) every time. · How to cite TESA