Skip to content

Commit 44a638d

Browse files
authored
Project/alexandra.ciupitu (#1272)
* initial * initial * initial * initial * initial * initial * arhitectura * arhitectura2 * incercare noua * hardware * documentation update * dimensiune fisier hardware 1,2k->354 * m * software * update link
1 parent 57eba0c commit 44a638d

1 file changed

Lines changed: 44 additions & 12 deletions

File tree

  • website/versioned_docs/version-acs_cc/project/2026/alexandra.ciupitu

website/versioned_docs/version-acs_cc/project/2026/alexandra.ciupitu/index.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ An embedded fairy companion that reacts to light, sound, touch, and color with a
1212

1313
## Description
1414

15-
The Digital Fairy Companion functions as a reactive embedded system that translates environmental data into interactive emotional responses to simulate a sentient digital presence. By continuously monitoring real-time inputs from light, motion, sound, color sensors and by capacitive touch interaction, the system utilizes a complex Finite State Machine to manage over seventeen distinct behavioral states. These inputs are processed by an STM32 Nucleo microcontroller which autonomously coordinates visual animations on a 2.4-inch LCD, synchronized audio responses stored on a microSD card, and dynamic ambient lighting via RGB LEDs. In practice, the system adapts its persona based on environmental triggers, such as entering a sleep state in low light or initiating a productivity timer when specific colors are detected, providing a comprehensive multi-sensory user experience.
15+
The Digital Fairy Companion functions as a reactive embedded system that translates environmental data into interactive emotional responses to simulate a sentient digital presence. By continuously monitoring real-time inputs from light, motion, sound, color sensors and by capacitive touch interaction, the system utilizes a complex Finite State Machine to manage over seventeen distinct behavioral states. These inputs are processed by an STM32 Nucleo microcontroller which autonomously coordinates visual animations on a 2.4-inch LCD, synchronized audio responses stored on a microSD card, and dynamic ambient lighting via RGB LEDs. In practice, the system adapts its persona based on environmental triggers, such as entering a sleep state in low light, providing a comprehensive multi-sensory user experience.
1616

1717
## Motivation
1818

@@ -33,7 +33,7 @@ The Digital Fairy Companion is structured into three primary functional modules
3333

3434
* **Processing & Logic Module**
3535

36-
At the core of the system sits the NUCLEO-U545RE-Q microcontroller, which implements a Finite State Machine (FSM) to manage over 17 distinct emotional states. It evaluates incoming sensor data to determine the appropriate behavior, such as switching from "Sleepy" to "Scared" based on sudden light and sound changes.
36+
At the core of the system sits the NUCLEO-U545RE-Q microcontroller, which implements a Finite State Machine (FSM) to manage over 10 distinct emotional states. It evaluates incoming sensor data to determine the appropriate behavior, such as switching from "Sleepy" to "Scared" based on sudden light and sound changes.
3737

3838
* **Feedback & Enclosure Module**
3939

@@ -57,12 +57,12 @@ This week, I focused on the hardware assembly of the project. I successfully sol
5757

5858
### Week 12 - 18 May
5959

60+
This week, I finalized the remaining minor hardware details and adjustments to ensure all connections were perfectly secure. Additionally, I focused on implementing the software architecture, successfully writing the asynchronous code that integrates all sensors and brings my digital fairy companion to life.
61+
6062
### Week 19 - 25 May
6163

6264
## Hardware
6365

64-
![SchemaHardware](./Digital_Fairy_Hardware.svg)
65-
6666
Each component was selected to balance high performance with the low-power requirements of an always-on companion device:
6767
* **Microcontroller (MCU)**
6868

@@ -87,6 +87,7 @@ Each component was selected to balance high performance with the low-power requi
8787
### Schematics
8888

8989
<!--Place your KiCAD or similar schematics here in SVG format.-->
90+
![SchemaHardware](./Digital_Fairy_Hardware.svg)
9091

9192
### Bill of Materials
9293

@@ -108,6 +109,7 @@ The format is
108109
| [PAM8403 Class D Audio Amplifier Module](https://www.bitmi.ro/modul-amplificator-audio-clasa-d-2x3w-dc-5v-pam8403-10764.html) | Drives the speaker for audio feedback | [5,99 RON](https://www.bitmi.ro) |
109110
| [High Sensitivity Microphone Sound Sensor Module](https://www.bitmi.ro/modul-senzor-sunet-cu-microfon-sensibilitate-ridicata-iesire-analogica-11248.html?gad_source=1&gad_campaignid=21312430054&gclid=Cj0KCQjwm6POBhCrARIsAIG58CKOXY7KbNqWNDGkSCjvKiWgJLeFwFiP5H9MZ4EDyVmPl2ZfKPiSrCIaAh34EALw_wcB) | Detects ambient sound levels | [13,92 RON](https://www.bitmi.ro) |
110111
| [WS2812 RGB5050 LED Module](https://www.bitmi.ro/modul-led-rgb5050-ws2812-10402.html) | Status-based ambient lighting | [3,99 RON](https://www.bitmi.ro) |
112+
| [CJMCU RGB LED Module](https://www.optimusdigital.ro/en/others/13627-cjmcu-rgb-led-module.html?search_query=modul+led+rgb&results=34) | Status-based ambient lighting | [4,99 RON](https://www.optimusdigital.ro) |
111113
| [LM393 Photodiode Sensor Module](https://www.bitmi.ro/senzori-electronici/modul-senzor-cu-fotodioda-lm393-10524.html) | Detects ambient light intensity | [3,65 RON](https://www.bitmi.ro) |
112114
| [TTP223 Capacitive Touch Sensor](https://www.bitmi.ro/senzor-touch-capacitiv-ttp223-10993.html?gad_source=1&gad_campaignid=22991722025&gclid=Cj0KCQjwm6POBhCrARIsAIG58CJL3fHTJQgAh4WWhmBka0jOd8Hln5wbZWOXjDbRidbKQH-Fw2FF9ZcaAlqQEALw_wcB) | Touch/petting interaction interface | [1,98 RON](https://www.bitmi.ro) |
113115
| [MB102 830-Point Breadboard](https://www.bitmi.ro/componente-electronice/breadboard-830-puncte-mb-102-10500.html) | Prototyping platform | [13,99 RON](https://www.bitmi.ro) |
@@ -116,24 +118,54 @@ The format is
116118
| [40x Dupont Wires Male-Male 20cm](https://www.bitmi.ro/electronica/40-x-fire-dupont-tata-tata-20cm-10511.html) | Breadboard connections | [8,99 RON](https://www.bitmi.ro) |
117119
| [40x Dupont Wires Female-Female 30cm](https://www.bitmi.ro/electronica/40-fire-dupont-mama-mama-30cm-10503.html) | Breadboard connections | [6,99 RON](https://www.bitmi.ro) |
118120
| Mini Speaker 1W 8Ω | Audio output | 18 RON |
119-
| MicroSD Card | Storing graphical frames and audio clips | ? RON |
121+
| MicroSD Card | Storing graphical frames and audio clips | 39.99 RON |
120122
| Tactile Push Button 6x6mm | Reset and color detection triggers | 0.65 RON x 3 |
121123
| 1x40 Pin Header 2.54mm | Connecting PAM8403 to breadboard | 2 RON |
122124
| NUCLEO-U545RE-Q | Main microcontroller running the FSM logic | - RON |
123125

124126

125127
## Software
126-
<!--
127128
| Library | Description | Usage |
128129
|---------|-------------|-------|
129-
| [st7789](https://github.com/almindor/st7789) | Display driver for ST7789 | Used for the display for the Pico Explorer Base |
130-
| [embedded-graphics](https://github.com/embedded-graphics/embedded-graphics) | 2D graphics library | Used for drawing to the display |
131-
-->
130+
| [embassy-stm32](https://crates.io/crates/embassy-stm32) | Hardware Abstraction Layer (HAL) asynchronous dedicated to STM32 microcontrollers. | Initialization of system clocks and direct control of hardware peripherals: GPIO pins (Input, Output), asynchronous interruptions on pins (ExtiInput), communication bus (SPI, I2C), sound generator (DAC) and LED timers (SimplePwm). |
131+
| [embassy-executor](https://crates.io/crates/embassy-executor) | High-efficiency asynchronous cooperative runtime for embedded systems. | Manage priorities and run parallel to the 9 competing tasks (tasks) of the fairy, alternating processing time without preemptive bottlenecks. |
132+
| [embassy-time](https://crates.io/crates/embassy-time) | Asynchronous utilities for time management and timers. | Allows executing asynchronous breaks (Timer::after_millis), measuring the duration of events and releasing the processor during expectations. |
133+
| [embassy-sync](https://crates.io/crates/embassy-sync) | Primitive thread-safe synchronization (channels, mutexes) for asynchronous environments. | It implements the inter-task message queue (Channel) used by sensors to send commands to the FSM brain, as well as providing support for safe atomic blockages. |
134+
| [embassy-embedded-hal](https://crates.io/crates/embassy-embedded-hal) | Implementations of shared busses. | Allows safe sharing of the same physical SPI1 bus between the TFT screen and the MicroSD card reader, avoiding data collisions. |
135+
| [embedded-graphics](https://crates.io/crates/embedded-graphics) | Optimised 2D graphics library for small integrated screens. | Define color models (Rgb565), coordinate points, and draw decoded pixel packets from the card directly on the screen. |
136+
| [mipidsi](https://crates.io/crates/mipidsi) | High-level universal driver for screens based on SPI controllers. | Manages boot sequence, 240x320 resolution, and hardware control for ILI9341 chip color screen. |
137+
| [display-interface-spi](https://crates.io/crates/display-interface-spi) | Transport software interface dedicated to SPI bus screens. | Translates drawing logic commands from the graphics driver into raw bit packs sent to the Data/Command (DC) and Clock physical pins. |
138+
| [embedded-sdmmc](https://crates.io/crates/embedded-sdmmc) | High-efficiency asynchronous cooperative runtime for embedded systems. | Allows directory opening, real-time fragmented navigation and reading of animation files (.RAW) and audio (.WAV) stored on the MicroSD card. |
139+
| [mpu6050](https://crates.io/crates/mpu6050) | Driver for inertial sensor (IMU) with 6 axes MPU6050. | Interfaces the sensor on the I2C bus and extracts the raw accelerations on the X, Y and Z axes to detect when the fairy is slightly moved or shaken. |
140+
| [tcs3472](https://crates.io/crates/tcs3472) | Driver for optical color sensor and ambient light TCS34725. | Activates the RGB and Clear photodiodes of the sensor, allowing to read the colors from reality and send them to the normalization algorithm. |
141+
| [embedded-hal](https://crates.io/crates/embedded-hal) | Traits (traits) and standard abstractions for embedded hardware in Rust. | Provides a common language between the sensor drivers and the physical pins of the microcontroller, mapping the software functionalities on the PWM channels. |
142+
| [defmt](https://crates.io/crates/defmt) & [defmt-rtt](https://crates.io/crates/defmt-rtt)| Ultra-fast and efficient space logging framework for microcontrollers. | Sends diagnostic text messages and telemetry data from the board directly to the computer console via the Segger RTT protocol without consuming unnecessary Flash memory. |
143+
| [panic-probe](https://crates.io/crates/panic-probe/) | Handler for critical errors (panic) integrated directly with defmt. | If the code encounters a fatal error, it stops execution safely and prints the exact code line and backtrace into the terminal for debugging. |
144+
| [static_cell](https://crates.io/crates/static_cell) | Mechanism for the safe creation of static references to runtimes without allocation on heap. | It allows the transformation of communication buses (SPI and I2C) into global static resources, so that they can be shared and accessed by all tasks started in the main. |
145+
| [cortex-m](https://crates.io/crates/cortex-m) | Functii de nivel scazut arhitectura de procesoare ARM Cortex-M. | Used for the execution of the microsecond loop at the assembly instruction level (cortex_m::asm::delay), ensuring the synchronization of the audio tact for DAC. |
146+
147+
### Description software
148+
Loop states:
149+
- STATE_NEUTRAL: The default companion state. The fairy loops an idle animation with occasional eye-blinking and soft audio. It actively listens to all environmental sensors.
150+
- STATE_SLEEPY: Triggered when the photodiode detects sustained darkness (sleeping animation and plays a continuous lullaby).
151+
- STATE_HAPPY: Triggered when the TTP223 touch sensor is actively held. The fairy loops a happy animation and playful sounds. It features a short grace period to prevent accidental interruption from touch bouncing.
152+
- STATE_DANCE: Triggered by gentle movements from the MPU6050 accelerometer. The fairy loops a dancing animation while the RGB LED runs a high-speed disco stroboscope cycle.
153+
154+
Reaction states:
155+
- STATE_HELLO: The initial hardware-protected introduction state at startup. It plays an introductory animation and audio clip before automatically transitioning to NEUTRAL.
156+
- STATE_WAKING_UP: Executes only if the fairy is in SLEEPY mode and light returns.
157+
- STATE_FEAR: Triggered by a sudden noise spike (NoiseBurst) or an ultra-fast light flash (blitz effect).
158+
- STATE_ANGRY: Triggered by sustained loud noise or when the fairy is shaken/disturbed while trying to sleep. When the anger animation finishes, it dynamically checks the room: transitioning directly back to SLEEPY if it is dark, or to NEUTRAL if it is bright.
159+
- STATE_DIZZY: Triggered by sudden, violent shaking detected by the gyroscope. It locks the fairy into a dizzy state for exactly 5 seconds before returning to normal.
160+
161+
EXTI BUTTONS:
162+
- STATE_COLOR_DETECT: ctivated by pressing the dedicated color button. This state bypasses all background sensors. It polls the TCS34725 sensor, runs a custom saturation-boosting math algorithm, and streams live, vibrant BGR colors onto the TFT screen. A second press toggles the fairy back to her previous stable state.
163+
- Emergency Reset: Pressing the hardware reset button instantly overrides any current state (including protected loops) and forces the system back to STATE_HELLO.
132164

133165
## Links
134166

135167
<!-- Add a few links that inspired you and that you think you will use for your project -->
136168

137-
<!--1. [link](https://example.com)
138-
2. [link](https://example3.com)
139-
...-->
169+
1. [Nucleo STM32F401RE with CC3000 and ILI9341 LCD](https://youtu.be/UnLNsv0Yht0?si=uK1fpNcbcgJiIeQF)
170+
171+

0 commit comments

Comments
 (0)