This repo captures analog samples on the Arduino UNO Q MCU (STM32U585) and streams them to the UNO Q Linux side, where a Python script feeds the samples into the Edge Impulse Linux runner using a .eim model.
⚠️ UNO Q plumbing note: the Linux processor and the MCU are connected internally. The Arduino router/bridge services commonly claim the UART by default, so you may need to stop them to use the raw serial link.Common mapping:
- Linux side:
/dev/ttyHS1- MCU side:
Serial1Stopping
arduino-routercan free the UART but may conflict with App Lab / Bridge workflows.
arduino/uno_q_adc_streamer/uno_q_adc_streamer.ino- Samples A0 at ~44.1 kHz (fixed-point
micros()scheduler) - Streams framed int16 samples over
Serial1(binary protocol)
- Samples A0 at ~44.1 kHz (fixed-point
linux/unoq_adc_infer.py- Reads frames from a serial device (default
/dev/ttyHS1) - Reassembles a window (e.g. 11025 samples = 250 ms @ 44.1 kHz)
- Runs inference via
edge_impulse_linux.runner.ImpulseRunneron a.eim
- Reads frames from a serial device (default
scripts/stop-router.sh/scripts/start-router.sh- Convenience scripts to stop/start
arduino-router
- Convenience scripts to stop/start
LICENSE,.gitignore
- Sensor output >
A0 - Sensor GND >
GND - Sensor VCC >
3.3V
Keep the analog voltage within 0–3.3V. If your signal is audio-like, you typically need a DC bias and an anti-alias filter.
Stream raw ADC samples MCU > Linux and run inference in Python on Linux.
- Pros: fast iteration, easy logging, simple model swaps (
.eim) - Cons: continuous streaming can be brittle if the UART is shared or baud is too low
- Open Arduino IDE
- Select Arduino UNO Q
- Open
arduino/uno_q_adc_streamer/uno_q_adc_streamer.ino - Upload
Defaults in the sketch:
analogReadResolution(12)Serial1at 2,000,000 baudFRAME_SAMPLES = 512
Tip: avoid
Serial.print()inside the sampling loop; printing will break timing.
python3 -m pip install --upgrade pip
python3 -m pip install edge_impulse_linux pyserial numpy
sudo apt install build-essential
sudo apt install portaudio19-dev python3-dev
git clone https://github.com/edgeimpulse/linux-sdk-python/cd linux-python-sdk/
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
sudo apt install build-essential
sudo apt install portaudio19-dev python3-dev
sudo apt install build-essential
sudo apt install portaudio19-dev python3-devFrom your Edge Impulse project on the UNO Q Linux side:
edge-impulse-linux-runner --download modelfile.eimOr copy an existing .eim into the repo.
If /dev/ttyHS1 is busy:
sudo ./scripts/stop-router.shTo restore later:
sudo ./scripts/start-router.shExample for a 250 ms window (11025 samples @ 44.1 kHz):
python3 linux/unoq_adc_infer.py \
--model modelfile.eim \
--port /dev/ttyHS1 \
--baud 2000000 \
--frame-samples 512 \
--window-samples 11025 \
--adc-bits 12 \
--centerEach frame sent by the MCU is little-endian and formatted as:
uint16MAGIC =0xA55Auint32seq (frame sequence number)uint16nsamp (number ofint16samples)int16[nsamp]samples (raw ADC codes fromanalogRead)uint16crc16_ccitt (CRC over header + payload)
- Resynchronizes by scanning for
MAGIC - Validates
CRC16-CCITT - Prints a warning if
seqjumps (drops/resync events)
--window-samples must match the model input length. Common values at 44.1 kHz:
- 250 ms > 11025
- 500 ms > 22050
- 1000 ms > 44100
--center: maps ADC codes to[-1..1](typical for audio-like raw signals)- without
--center: maps ADC codes to[0..1]
If you change analogReadResolution() in the sketch, update --adc-bits in the Python script.
If you see CRC mismatches or frequent seq jumps:
- Increase baud rate (or reduce
FRAME_SAMPLES) - Ensure
arduino-routerisn’t sharing the UART - Reduce Linux load while testing