Skip to content

Commit ead3f22

Browse files
Project/ana sorina.ciurea (#1333)
* added for the first time as a test * updated project with architecture and schematic * added link * changes * moved the folder with pictures * update * changed index * changed images * img * changed the schemat image format * modified index.md --------- Co-authored-by: Irina Bradu <72762129+irina-b-dev@users.noreply.github.com>
1 parent 279e193 commit ead3f22

1 file changed

Lines changed: 81 additions & 34 deletions

File tree

  • website/versioned_docs/version-acs_cc/project/2026/ana_sorina.ciurea

website/versioned_docs/version-acs_cc/project/2026/ana_sorina.ciurea/index.md

Lines changed: 81 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,68 @@ An intelligent trash bin that encourages recycling through automation and reward
1010

1111
## Description
1212

13-
This project consists of building a smart recycling bin using an STM32 microcontroller programmed in Rust. The system improves user interaction by automatically opening the lid and rewarding users for recycling using NFC technology.
13+
This project consists of building a smart recycling bin using an STM32 microcontroller
14+
programmed in Rust with the Embassy async framework. The system automates lid control
15+
and rewards users for recycling via RFID card scanning.
1416

15-
The bin detects hand movement to open automatically and allows users to scan an NFC card to receive rewards. Additionally, recyclable items can be identified using NFC tags attached to packaging.
17+
An HC-SR04 ultrasonic sensor continuously measures the distance in front of the bin.
18+
When a hand is detected closer than 30 cm, a servo motor (SG90) opens the lid and a
19+
passive buzzer emits a short confirmation beep. When no obstacle is detected, the lid
20+
closes automatically.
21+
22+
Users can scan an RFID card using the RC522 module to receive 200 recycling points per
23+
scan. Points accumulate across reboots, as they are stored persistently in the STM32's
24+
internal Flash memory using a magic-number validation scheme to ensure data integrity.
25+
26+
The system runs two concurrent async tasks: one handling the ultrasonic sensor, servo,
27+
and buzzer logic, and one dedicated to RFID scanning and Flash storage — both managed
28+
by the Embassy executor.
1629

1730
## Motivation
1831

1932
I chose this project to explore embedded systems programming in Rust and to build a real-world application that promotes recycling. The combination of low-level programming and hardware interaction makes this project both challenging and practical.
2033

2134
## Architecture
2235

23-
The system consists of the following main components:
24-
25-
- **STM32 microcontroller** – central unit running Rust code
26-
- **Proximity sensor (IR/ultrasonic)** – detects when a user approaches
27-
- **Servo motor** – controls lid opening and closing
28-
- **NFC module (RC522)** – reads user cards and product tags
36+
- **STM32 Nucleo (STM32F411RE)** – central unit running Rust code
37+
with the Embassy async framework
38+
- **HC-SR04 ultrasonic sensor** – detects hand proximity (threshold: 30 cm)
39+
- **Servo motor (SG90)** – controls lid opening (90°) and closing (0°)
40+
via PWM on TIM3 at 50 Hz
41+
- **RC522 RFID module** – reads ISO 14443A cards via SPI1,
42+
awards 200 points per scan
43+
- **KY-006 passive buzzer** – emits a confirmation beep (2 kHz)
44+
when the lid opens
45+
- **Internal Flash memory** – persistent storage for RFID points
46+
across reboots (offset 504 KB, magic-number validated)
2947

3048

3149
### System Flow
3250

33-
1. **Proximity Sensor detects hand** → Lid opens automatically
34-
2. **NFC Card is scanned** → System registers and you receive bonuses
35-
3. **When lid opens** → Speaker beeps and servo motor
51+
The system runs two independent async tasks concurrently:
52+
53+
#### Task 1: Ultrasonic + Servo + Buzzer (every 500 ms)
54+
1. HC-SR04 sends a 10 µs trigger pulse and measures ECHO duration
55+
2. Calculates distance: `distance_cm = duration_µs / 58`
56+
3. **distance < 30 cm** → servo opens lid (90°) + buzzer beeps 200 ms
57+
4. **distance ≥ 30 cm or timeout** → servo closes lid (0°)
58+
59+
#### Task 2: RFID + Flash
60+
61+
1. **On boot** → restores points from Flash (validated via magic number);
62+
if no previous data, starts from 0
63+
2. User can optionally scan an RFID card **at any time** to collect +200 bonus points,
64+
saved persistently to Flash with a 2s cooldown between scans
65+
3. Points accumulate independently of the lid mechanism — scanning
66+
and recycling are two separate interactions
3667

3768
### Architecture Diagram
3869

3970
![Architecture](smart_bin_block.svg)
4071

41-
The STM32 microcontroller acts as the central controller, receiving input from sensors and the NFC module, and controlling the servo motor and LEDs accordingly.
72+
The STM32 microcontroller acts as the central controller, receiving input
73+
from the HC-SR04 sensor and RC522 RFID module, and controlling the servo
74+
motor and buzzer accordingly.
4275

4376
## Log
4477

@@ -51,27 +84,35 @@ The STM32 microcontroller acts as the central controller, receiving input from s
5184
- Tested GPIO and basic components
5285

5386
### Week 19 - 25 May
54-
- Integrated sensors and servo motor
55-
- Began NFC integration
87+
- Integrated HC-SR04 ultrasonic sensor with servo and buzzer logic
88+
- Integrated RC522 RFID module via SPI1
89+
- Implemented persistent point storage in internal Flash
90+
- Finalized two-task async architecture with Embassy
5691

5792
## Hardware
5893

5994
The system is built around an STM32 Nucleo board and integrates multiple sensors and actuators.
6095

6196
### Components Overview
6297

63-
- STM32 Nucleo board
64-
- Ultrasonic or IR proximity sensor
65-
- Servo motor
66-
- RC522 NFC module
67-
- LEDs + resistors
98+
- STM32 Nucleo (STM32F411RE)
99+
- HC-SR04 ultrasonic sensor
100+
- Servo motor (SG90)
101+
- RC522 RFID module
102+
- KY-006 passive buzzer
103+
- Breadboard + resistors
68104

69105
### Connections
70106

71-
- Proximity sensor → GPIO pins
72-
- Servo motor → PWM pin
73-
- NFC module → SPI interface (MOSI, MISO, SCK, CS)
74-
- LEDs → GPIO pins (with resistors)
107+
- HC-SR04 TRIG → PC7
108+
- HC-SR04 ECHO → PC8
109+
- Servo SG90 → PB5
110+
- Buzzer KY-006 → PB10
111+
- RC522 SCK → PA5
112+
- RC522 MOSI → PA7
113+
- RC522 MISO → PA6
114+
- RC522 CS → PA8
115+
- RC522 RST → PA3
75116

76117
### Schematics
77118

@@ -81,29 +122,35 @@ The system is built around an STM32 Nucleo board and integrates multiple sensors
81122

82123
| Device | Usage | Price |
83124
|--------|--------|-------|
84-
| STM32 Nucleo board | Main controller | ~200 RON |
85-
| Ultrasonic/IR sensor | Detects hand | 10 RON |
125+
| STM32 Nucleo board | Main controller | 200 RON |
126+
| HC-SR04 | Detects hand | 10 RON |
86127
| Servo motor (SG90) | Opens lid | 15 RON |
87-
| NFC module (RC522) | Reads cards/tags | 20 RON |
88-
| LEDs + resistors | Feedback | 5 RON |
128+
| RFID module RC522 | Reads cards/tags | 15 RON |
129+
| Breadboard | Connecting components | 14 RON |
130+
| KY-006 Buzzer pasiv | Confirms that the sensor is working | 3 RON |
131+
| Resistors | | 1 RON |
89132

90133
## Software
91134

92135
The software is written in Rust using embedded development frameworks.
93136

94137
| Library | Description | Usage |
95138
|---------|-------------|-------|
96-
| embedded-hal | Hardware abstraction layer | GPIO, PWM control |
97-
| stm32 HAL crate | STM32 support | Peripheral access |
98-
| NFC crate | NFC communication | Reading tags/cards |
139+
| embassy-executor | Async task executor | Spawner, concurrent tasks |
140+
| embassy-stm32 | STM32 HAL for Embassy| GPIO, SPI, PWM, Flash, Timer |
141+
| embassy-time | Async timers | Timer, Instant, Delay |
142+
| mfrc522 | RC522 RFID driver | Reading card UIDs |
143+
| embedded-hal-bus | SPI bus management | ExclusiveDevice for CS |
144+
| defmt + defmt-rtt| RTT logging | Debug output |
145+
| panic-probe | Panic handler | Error handling |
99146

100-
The system uses a simple state-based logic to control interactions between sensors, actuators, and user input.
147+
The system uses an async, event-driven architecture managed by the Embassy executor.
101148

102149
## Future Improvements
103150

104-
- Mobile app for tracking recycling points
105-
- Cloud integration for user accounts
106-
- More advanced object recognition
151+
- Mobile app for tracking recycling points
152+
- Cloud integration for user accounts
153+
- Support for multiple RFID cards with individual point balances
107154

108155
## Links
109156

0 commit comments

Comments
 (0)