Demonstration
This project implements a real-time Electrical Impedance Tomography (EIT) system on the STM32F769I Discovery kit. EIT is a non-invasive imaging technique that reconstructs the internal conductivity distribution of an object from boundary voltage measurements obtained by injecting small AC currents through surface electrodes.
Key features:
- 16-electrode adjacent-drive measurement protocol
- Linear Back-Projection (LBP) reconstruction algorithm running entirely on the MCU
- Reconstruction grid configurable at 16×16, 32×32 (default), or 64×64 pixels
- Real-time colormap display on the board's 4-inch capacitive touch LCD (LVGL UI)
- Simulated acquisition mode for offline testing without hardware electrodes
- Dataset recording to SD card in JSON format
- WiFi streaming of live frames and full exam sessions to the companion Flask server
- Sensitivity matrix pre-computed offline (MATLAB/EIDORS) and stored on the SD card
| Folder | Description |
|---|---|
Firmware/ |
C firmware for the STM32F769I-DISCO (STM32CubeIDE project) |
Validation/ |
MATLAB scripts for batch validation of reconstruction quality (EIDORS) |
FIPS Data/ |
Python utilities for converting and processing raw measurement datasets |
The STM32F769I Discovery kit provides:
- STM32F769NIH6 microcontroller — 2 MB Flash, 512 KB RAM (BGA216)
- 4-inch capacitive touch LCD display (MIPI-DSI, 800×480)
- 128-Mbit SDRAM
- 512-Mbit Quad-SPI Flash
- microSD card connector
- USB OTG HS, Ethernet, Arduino Uno V3 connectors
- On-board ST-LINK/V2-1
-
Clone the repository (including submodules):
git clone github.com/guikoller/EIT
-
Open STM32CubeIDE and import the firmware project:
- Go to File → Import → General → Existing Projects into Workspace
- Set the root directory to
Firmware/ - Make sure the project is checked and click Finish
-
Build the project:
- Select the
DebugorReleasebuild configuration from the toolbar - Press Ctrl+B (or Project → Build Project)
- Select the
-
Flash and debug:
- Connect the STM32F769I-DISCO board via USB (ST-LINK port)
- Press F11 (or Run → Debug) using the provided launch configuration
TIME_Firmware Debug.launch - The firmware starts automatically after flashing
The MCU loads datasets and the sensitivity matrix from the SD card root. Follow the steps below to prepare it before first use.
The firmware reads datasets in a packed binary format (.bin). The conversion script reads MATLAB .mat files from FIPS Data/data_mat_files/ and writes .bin files to FIPS Data/data_bin_files/.
cd "FIPS Data"
pip install numpy scipy # one-time
python convert_eit_to_bin.pyThe script converts all .mat files found in data_mat_files/. The reference file (datamat_1_0.mat) must be present — it is used as the reference (homogeneous) measurement for calibration.
Alternative: If you already have pre-converted
.binfiles, skip this step and go directly to Step 2.
Copy the entire contents of FIPS Data/data_bin_files/ to the root of the microSD card:
SD:/
├── datamat_1_0.bin ← reference dataset (required for calibration)
├── datamat_1_1.bin
├── datamat_1_2.bin
└── ...
Insert the SD card into the STM32F769I-DISCO before powering on.
The sensitivity matrix is computed on the MCU from the reference dataset and saved back to the SD card as sensitivity_matrix.bin. This only needs to be done once (or whenever the electrode geometry changes).
- Boot the board and wait for the Home screen to appear.
- Tap Settings (bottom-right of the navigation bar, or the Settings button on the Home screen).
- On the Settings screen, tap Generate Sens. Matrix (Calibrate button).
- The status label updates in real time:
SENS OPENING→SENS READING→SENS PATTERNS→SENS GENERATING→SENS WRITING→SENS DONE
- When
SENS DONEis shown,sensitivity_matrix.binhas been written to the SD card root. The button re-enables and the system is ready for reconstruction.
If the status shows
SENS ERR NO SD, the SD card was not detected. Eject, re-insert, and retry.
Once the SD card is prepared and the sensitivity matrix exists, follow these steps to produce a live EIT image:
- Home screen — Tap Start (or the EIT icon in the nav bar). The SD file browser opens.
- Browser — A list of
.bindataset files on the SD card is shown. Tap a file to select it (e.g.datamat_2_1.bin). - Reconstruction viewer — The selected dataset is loaded and reconstruction runs automatically:
- The LBP algorithm reconstructs a conductivity image from the voltage measurements relative to the reference frame.
- The result is displayed as a colormapped square image on the LCD.
- Use the Play / Pause controls to step through frames if the dataset has multiple injections.
- Tap Save BMP to write the current frame as a bitmap to the SD card (e.g.
datamat_2_1_LBP.bmp).
- Back — Returns to the file browser to select another dataset.
On the Settings screen you can adjust:
| Setting | Options | Notes |
|---|---|---|
| Algorithm | LBP | Linear Back-Projection (only option currently) |
| Image size | 16 / 32 / 64 | Grid side-length in pixels; affects accuracy and speed |
| Show data table | On / Off | Overlays raw measurement values on the viewer screen |
Requires EIDORS and MATLAB R2021b+.
% Set EIDORS path, then run:
run_batch_validateOr use the VS Code task MATLAB: batch_validate.