Skip to content

Commit 2f1b367

Browse files
Project/leyla kubra.sahin (#1401)
* project: Lie Detector documentation * project: Lie Detector documentation update * project: Lie Detector documentation 2nd update * Lie Detector KiCAD scheme * Final Update: Lie Detector * Final Update: Lie Detector. * Delete website/versioned_docs/version-fils_en/project/2026/leyla_kubra.sahin/lie_detector_diagram.svg * Final pull req : Lie Detector
1 parent fff58bb commit 2f1b367

4 files changed

Lines changed: 54 additions & 18 deletions

File tree

49.7 KB
Loading

website/versioned_docs/version-fils_en/project/2026/leyla_kubra.sahin/index.md

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A biometric analyzer powered by an STM32 that correlates real-time heart rate an
99

1010
## Description
1111

12-
The Lie Detector is an asynchronous embedded system designed to monitor physiological stress indicators often associated with deception. Using an STM32 Nucleo-U545RE-Q microcontroller, the device establishes a physiological baseline for a subject's heart rate and skin conductivity (GSR). During active questioning, the system uses its ADC to monitor real-time sensor data, triggering visual PWM-controlled RGB LED transitions and audible buzzer alarms if simultaneous spikes above the baseline thresholds are detected.
12+
The Lie Detector is an asynchronous embedded system designed to monitor physiological stress indicators often associated with deception. Using an STM32 Nucleo-U545RE-Q microcontroller, the device establishes a physiological baseline for a subject's heart rate and skin conductivity (GSR). During active questioning, the system uses its ADC to monitor real-time sensor data, triggering visual PWM-controlled RGB LED transitions and audible buzzer alarms if simultaneous spikes above the baseline thresholds are detected. The system also features a dynamic baseline engine, sensor stabilization logic, and two physical push buttons for start and reset control.
1313

1414
## Motivation
1515

@@ -19,14 +19,15 @@ I was inspired by the modern criminal investigation tool, the "Polygraph", as I
1919

2020
Main software and system components:
2121

22-
* **Physiological Data Acquisition Module**: Reads skin conductance from the Grove GSR sensor and heart rate from the Pulse sensor via ADC channels.
23-
* **Stress Analysis Module**: Processes the physiological baseline and current readings using an asynchronous logic brain to detect deception spikes.
24-
* **Shared State Module**: Manages safe data access between concurrent tasks using an `embassy-sync` Mutex.
25-
* **Visual Feedback Module**: Controls the RGB LED via PWM to transition colors from Green to Red based on stress intensity.
26-
* **Audible Alert Module**: Drives the passive buzzer using PWM to emit alarms that vary in pitch as deception scores rise.
27-
* **Logging and Debug Module**: Sends real-time sensor data and system status to a PC via USB for graphing and monitoring.
22+
* **Physiological Data Acquisition Module**: Reads skin conductance from the Grove GSR sensor and heart rate from the Pulse sensor via ADC channels. Includes sensor attachment detection and a stabilization countdown before calibration begins.
23+
* **Stress Analysis Module**: Processes the physiological baseline and current readings using an asynchronous logic brain to detect deception spikes. Uses a dynamic rolling baseline and a sustained-count mechanism to avoid false positives.
24+
* **Shared State Module**: Manages safe data access between all concurrent tasks using an `embassy-sync` Mutex protecting a central `BaselineData` struct.
25+
* **Visual Feedback Module**: Controls the RGB LED via PWM to smoothly transition colors from green to red based on the current deception score.
26+
* **Audible Alert Module**: Drives the passive buzzer to emit rapid pulses when the deception score exceeds a set threshold.
27+
* **Button Handler Module**: Monitors two physical push buttons — one to start the session (triggering the stabilization phase) and one to fully reset the system back to its idle state.
28+
* **Logging and Debug Module**: Sends real-time sensor data and system status to a PC via UART/USB for graphing and monitoring using the companion Python script.
2829

29-
![Architecture Diagram](./lie_detector.svg)
30+
![Architecture Diagram](./lie_detector_drawio.svg)
3031

3132
## Log
3233

@@ -37,44 +38,74 @@ Main software and system components:
3738

3839
### Week 8
3940
* Focused on sourcing the specific hardware required for the project.
40-
* Obtained the necessary components like the Pulse sensor, RGB LEDs, and an active buzzer.
41+
* Obtained the necessary components like the GSR sensor, Pulse sensor, RGB LEDs, and an active buzzer.
4142

4243
### Week 9
4344
* Completed the gathering of all secondary hardware, including the USB debugging cables and safety resistors.
4445
* Completed the project documentation milestone.
4546

47+
### Week 10
48+
* Tested the Grove GSR sensor in multiple different ways to make sure it's actually reading properly and gives consistent values.
49+
* Started working on the KiCad schematic for the project.
50+
* Also started writing the project code to get a feel for the structure before flashing anything onto the actual hardware.
51+
52+
### Week 11
53+
* Finished the KiCad schematic and added it to the documentation.
54+
* Soldered the analog pulse sensor and ran some tests to confirm it's fully functional and reading as expected.
55+
56+
### Week 12
57+
* Started properly working on the full codebase and added several new features including sensor stabilization, dynamic rolling baseline, and sustained-count deception scoring.
58+
* Flashed the code onto the hardware and did initial testing but couldn't get the buzzer to behave correctly, so that's still a work in progress.
59+
60+
### Week 13-14
61+
* Finally got everything working, I completed the code and all the bugs that were piling up are now fixed.
62+
* The full project is functional on the hardware.
63+
* Added the two physical push buttons (start and reset) to the breadboard setup and integrated them into the system logic.
64+
4665
## Hardware
4766

48-
The project uses a mix of analog physiological sensors and asynchronous digital processing to achieve real-time deception detection. The hardware setup is centered around the STM32 Nucleo-U545RE-Q, which acts as the high-speed data aggregator.
67+
The project uses a mix of analog physiological sensors and asynchronous digital processing to achieve real time deception detection. The hardware setup is centered around the STM32 Nucleo-U545RE-Q, which acts as the high-speed data aggregator and main controller.
68+
69+
The Grove GSR sensor is connected to ADC channel PA0 and measures skin conductance by detecting changes in electrical resistance across the fingertips. The Analog Pulse Sensor is connected to ADC channel PA1 and captures heart rate fluctuations. Both sensors feed into the ADC and are sampled every 500ms during the monitoring phase.
70+
71+
An RGB LED is driven via three PWM channels (PA6, PA7, PB0 on TIM3) to visually represent the deception score, transitioning from green at baseline to red as stress indicators rise. A passive buzzer on PB6 emits rapid pulses when the score exceeds 50. Two tactile push buttons (connected to PB5 and PB4 with internal pull-ups) allow the user to start a session or reset the system at any point.
72+
73+
![Hardware Setup](./hardware.webp)
4974

5075
### Schematics
5176

52-
![Project Schematic](./kicad_lie_detector_schematic.svg)
77+
![Project Schematic](./schematic_lie_detector.svg)
5378

5479
### Bill of Materials
5580

5681
| Device | Usage | Price |
5782
| :--- | :--- | :--- |
5883
| [STM32 NUCLEO-U545RE-Q](https://www.st.com/en/evaluation-tools/nucleo-u545re-q.html) | Central Controller | 128 RON |
59-
| [Grove GSR Sensor](https://wiki.seeedstudio.com/Grove-GSR_Sensor/) | Stress Monitor | 40.18 RON |
84+
| [Grove GSR Sensor](https://wiki.seeedstudio.com/Grove-GSR_Sensor/) | Stress Monitor | 40.00 RON |
6085
| [Analog Pulse Sensor](https://robocraze.com/blogs/post/what-is-pulse-sensor) | Heart Rate Monitor | 15.4 RON |
6186
| [RGB LED](https://www.elprocus.com/what-is-three-rgb-led-and-its-working/) | Visual Indicator | 0.92 RON |
6287
| [Passive Buzzer](https://www.circuitbasics.com/what-is-a-buzzer/) | Audible Alarm | 1 RON |
88+
| [Push Buttons x2](https://www.optimusdigital.ro) | Start & Reset Control | 2 RON |
6389
| Resistors (220Ω) | Safety | 2 RON |
6490
| Breadboard & Wires | Connection | 30 RON |
6591

6692
## Software
6793

6894
| Library | Description | Usage |
6995
| :--- | :--- | :--- |
70-
| [embassy-stm32](https://github.com/embassy-rs/embassy) | STM32 Hardware Abstraction Layer | Controls the ADC for sensors and PWM for indicators. |
71-
| [embassy-time](https://github.com/embassy-rs/embassy/tree/main/embassy-time) | Timekeeping library | Manages the baseline calibration timing. |
72-
| [embassy-executor](https://github.com/embassy-rs/embassy) | Async task manager | Allows simultaneous monitoring of multiple sensors. |
73-
| [fixed](https://github.com/tomhoule/fixed) | Fixed-point math | Calculates percentage spikes without floating-point overhead. |
74-
| [defmt](https://github.com/knurling-rs/defmt) | Efficient logging | Sends real-time sensor data to the PC via RTT. |
96+
| [embassy-stm32](https://github.com/embassy-rs/embassy) | STM32 Hardware Abstraction Layer | Controls ADC for sensor sampling, PWM for the RGB LED, GPIO for buttons and buzzer, and USART for serial output. |
97+
| [embassy-executor](https://github.com/embassy-rs/embassy) | Async task manager | Spawns and runs all concurrent tasks (acquisition, analysis, feedback, button handler). |
98+
| [embassy-time](https://github.com/embassy-rs/embassy/tree/main/embassy-time) | Timekeeping library | Manages stabilization countdowns, calibration timing, and polling intervals. |
99+
| [embassy-sync](https://github.com/embassy-rs/embassy) | Synchronization primitives | Provides the `Mutex` used to safely share `BaselineData` between all async tasks. |
100+
| [embedded-hal](https://github.com/rust-embedded/embedded-hal) | Hardware abstraction traits | Used for the `Pwm` trait to set duty cycles on the RGB LED PWM channels. |
101+
| [heapless](https://github.com/japaric/heapless) | `no_std` data structures | Provides a stack-allocated `String` for formatting UART serial output without heap allocation. |
102+
| [defmt](https://github.com/knurling-rs/defmt) | Efficient logging | Sends real-time sensor data and state transitions to the PC via RTT for debugging. |
103+
| [panic-probe](https://github.com/knurling-rs/panic-probe) | Panic handler | Handles panics in the embedded environment and reports them via `defmt`. |
75104

76105
## Links
77106

78107
1. [Embassy-rs Documentation](https://embassy.dev/book/index.html)
79108
2. [Rust Embedded Book](https://docs.rust-embedded.org/book/)
80-
3. [GSR Sensor Guide](https://wiki.seeedstudio.com/Grove-GSR_Sensor/)
109+
3. [GSR Sensor Guide](https://wiki.seeedstudio.com/Grove-GSR_Sensor/)
110+
4. [STM32 Nucleo-U545RE-Q Reference Manual](https://www.st.com/en/evaluation-tools/nucleo-u545re-q.html)
111+
5. [defmt Logging Framework](https://defmt.ferrous-systems.com/)

website/versioned_docs/version-fils_en/project/2026/leyla_kubra.sahin/lie_detector_drawio.svg

Lines changed: 4 additions & 0 deletions
Loading

website/versioned_docs/version-fils_en/project/2026/leyla_kubra.sahin/schematic_lie_detector.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)