PiBuzz
A multifunctional device which serves as a custom alarm clock, equipped with environmental sensors.
Author: Samson Alexandru-Valentin
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-sammsonn
Description
A device that has the main functionality of a digital clock displayed on a screen with an alarm function, operated by physical buttons. The alarm is manually set by the user and would emit sound via the buzzer. The product is also equipped with a pressure and temperature sensor to observe the environmental conditions surrounding it. Aditionally, a photoresistor is used in order to automatically adjust the brightness of the display.
Motivation
This project is inspired by a real world problem of mine, and it probably affects a lot of the current population, especially teenagers and young adults. When going to bed, I always take my phone with me and end up scrolling mindlessly for 1-2 hours. This has a very negative impact on my sleep, which is way more important than most think. But the main reason why I have my phone next to me in bed is because I use it as an alarm in order to wake up. This is also bad because the phone can overheat under the pillow, causing potential damage, and there is also the concern of EMF radiation exposure when keeping your cell phone close to the head for extended periods of time. So, building this clock by hand I can get rid of all these problems, removing the need of my smartphone at night.
Architecture
Log
Week 5 - 11 May
Soldered the pins to the microcontrollers and the sensors, reviewed all of the laboratories and inspected the data sheets of the hardware components used.
Week 12 - 18 May
Wired the pieces to the raspberry pi pico, started working on the software, wrote code in order to test each component individually, then succesfully confirmed that all of them work together.
Week 19 - 25 May
Completed the code, soldered all of the hardware on a perfo board and built the case for the clock.
Hardware
The main hardware is the Raspberry Pi Pico 2W microcontroller, which provides processing and Wi-Fi connectivity. A DS3231 RTC module is used for precise timekeeping. Environmental sensors include a BMP280 (temperature, pressure) and a photoresistor (ambient light, for automatic display adjustment). The user interface consists of an ILI9341 (2.4 inch) color LCD for display and touch buttons for control. The audio alarm is handled by a buzzer. The components are interconnected on a perfo board using jumper wires and well powered.
Schematics
Bill of Materials
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico 2W | The microcontroller | 40 RON x 2 |
ILI9341 | Display | 67 RON |
DS3231 | RTC module | 19 RON |
BMP280 | Pressure and temperature sensor | 8.5 RON |
Photoresistor | Photoresistor (type 5528) | 1.49 RON |
Buzzer | Active buzzer | 1 RON |
Button | 12x12x7.3 button | 1.31 RON x 4 |
Button Cap | 12x12x7.3 button cap, multiple colors | 0.4 RON x 4 |
Breadboard HQ | Breadboard with 830 slots | 10 RON |
Pin Header | 2.54mm (40p) pin header | 1 RON x 3 |
Male-Male Wire Set | 10p, 10cm male-male wires | 2.85 RON |
Male-Male Wire Set | 10p, 30cm male-male wires | 5 RON |
Female-Male Wire Set | 40p, 10cm female-male wires | 6 RON |
Female-Male Wire Set | 40p, 15cm female-male wires | 8 RON |
Software
Library (Crate) | Description | Usage in Project |
---|---|---|
Core Embassy & HAL | ||
embassy-rp | Asynchronous Hardware Abstraction Layer (HAL) for the RP2350 microcontroller (Pico W). | Provides fundamental access to peripherals: GPIO (Buttons, Buzzer, Display Control), I2C (RTC, BMP280), SPI (Display), ADC (LDR), DMA, Timers. |
embassy-executor | Asynchronous runtime executor for the Embassy framework. | Managing and running concurrent asynchronous tasks (main task, button_and_buzzer_task ). |
embassy-time | Timekeeping utilities, timers, and delays for asynchronous tasks within the Embassy framework. | Used for Timer::after() for periodic operations, and EmbassyDelay for blocking delays needed by display initialization. |
embassy-sync | Synchronization primitives (like Mutex) for safe concurrent access to shared data in async environments. | Used for Mutex<NoopRawMutex, _> to share the SPI bus for the display and potentially other SPI devices (though IMU part was commented out). |
embassy-embedded-hal | Provides adapter types to use embedded-hal blocking traits with Embassy's async SPI/I2C. | Used for SpiDevice to wrap the shared SPI bus for the display, providing a blocking-like interface. |
Low-Level & Panic Handling | ||
cortex-m | Low-level access to ARM Cortex-M processor core peripherals and intrinsics. | (Often used indirectly by HALs and runtime, e.g., for critical sections). Not explicitly used for peripherals in your main but foundational. |
cortex-m-rt | Minimal runtime for Cortex-M microcontrollers, handles startup and interrupt vector setup. | Provides the #[entry] macro for the main function (though #[embassy_executor::main] is used now). Foundational. |
panic-probe | A panic handler that prints panic messages via a debug probe (e.g., RTT using probe-rs ). | Defines the behavior when the program panics, sending details to the debugger. |
Logging | ||
defmt | Highly efficient deferred formatting logger for embedded systems. | Used for all logging output (info! , error! , warn! ). |
defmt-rtt | Implements a defmt global logger that sends log data over RTT (Real-Time Transfer) to a debug probe. | Enables viewing defmt logs via probe-rs . |
Display & Graphics | ||
mipidsi | Generic driver for MIPI Display Serial Interface (DSI) compatible displays, including ILI9341. | Used to initialize and control the ILI9341 display (clear, set orientation). |
display-interface-spi | Provides an SPI-based communication interface for display drivers like mipidsi . | Bridges the mipidsi driver with the underlying SPI HAL. |
display-interface | Defines traits for display communication interfaces. | (Dependency of display-interface-spi ). |
embedded-graphics | A 2D graphics library for drawing shapes, text, and images on embedded displays. | Used for defining text styles, drawing text (Text ), and shapes (Rectangle ) on the ILI9341 display. |
Utilities | ||
heapless | Provides data structures (like String ) that do not require dynamic memory allocation (std 's alloc ). | Used for HString to create fixed-size string buffers for formatting text to be shown on the display. |
embedded-hal-async | Asynchronous hardware abstraction traits for embedded systems (e.g., async I2C). | The I2c trait from this is used to enable methods like .read() , .write() , .write_read() on embassy_rp::i2c::I2c . |
core::fmt::Write | Standard library trait for formatting into a writer (available in no_std through core ). | Used with heapless::String and the write! macro to format variables into displayable strings. |