A Pomodoro Timer application built for the STM32F407 microcontroller with a 2.4" ILI9341 TFT LCD display and LVGL graphics library. This project demonstrates embedded GUI development, SPI communication, and real-time timer functionality.
- ๐
STM32F407 Pomodoro Timer with ILI9341 LCD
- ๐ Table of Contents
- โจ Features
- ๐ฏ Project Overview
- ๐ฅ๏ธ Try Before You Build - Windows Simulator
- ๐ ๏ธ Hardware Requirements
- ๐ Hardware Connections
- โ๏ธ Software Requirements
- ๐ Getting Started
- ๐ Usage
- ๐๏ธ Project Structure
- ๐ง Configuration
- ๐ Technical Notes
- ๐ค Contributing
- ๐ Acknowledgments
- ๐ฌ Contact
- ๐ Full Pomodoro Timer functionality (25min work, 5min break cycles (Configurable) )
- ๐ฑ Touch-enabled GUI with LVGL graphics library
- ๐ฅ๏ธ 2.4" ILI9341 LCD display (240x320 resolution)
- ๐ง Modular code structure with separated concerns
- ๐ UART debugging support with formatted logging
- โก Multiple clock configurations (16MHz HSI, 84MHz, 168MHz)
- ๐จ Beautiful UI with progress indicators and animations
- ๐ Touch cursor debugging for input validation
- ๐ Statistics tracking for completed sessions
This project was built for learning purposes, focusing on:
- Embedded GUI development with LVGL
- SPI communication with LCD displays
- Real-time timer applications
- STM32 HAL library usage and best practices
- Modular embedded software architecture
The Pomodoro Technique is a time management method that uses 25-minute work intervals followed by short breaks, helping improve focus and productivity.
Want to experience the Pomodoro app before building the hardware?
Check out MicroPomo - a Windows simulator that runs the exact same Pomodoro application with identical UI and functionality. This allows you to:
- ๐ฎ Test the complete user interface and timer functionality
- ๐ Explore all features without any hardware setup
- ๐ฑ Experience the touch interactions using mouse input
- โก Quick evaluation before investing in STM32 hardware
- ๐ฏ Perfect for demonstrations and proof-of-concept
The simulator uses the same LVGL code base, providing an authentic preview of what you'll get on the actual STM32 hardware.
๐ Try MicroPomo Simulator Now
| Component | Specification | Notes |
|---|---|---|
| Microcontroller | STM32F407VGT6 | ARM Cortex-M4, 168MHz |
| Display | 2.4" ILI9341 LCD | 240x320, SPI interface |
| Touch Controller | XPT2046 | SPI touch controller |
| Development Board | STM32F4 Discovery | Or compatible STM32F407 board |
| Power Supply | 5V | For LCD backlight |
| Debugger | ST-Link/V2 | For programming and debugging |
| LCD Pin | STM32F407 Pin | Function | Notes |
|---|---|---|---|
| VCC | 5V | Power Supply | External 5V required |
| GND | GND | Ground | Common ground |
| CS | PB9 | Chip Select | Active low |
| RESX | PD10 | Reset | Active low |
| DCX | PD9 | Data/Command | Data=1, Command=0 |
| SDI/MOSI | PB15 | SPI MOSI | SPI2 data out |
| SDO/MISO | PC2 | SPI MISO | Optional for reading |
| SCK | PB13 | SPI Clock | SPI2 clock |
| LED | 5V | Backlight | Always on |
| Touch Pin | STM32F407 Pin | Function | Notes |
|---|---|---|---|
| T_CLK | PA5 | Touch SPI Clock | SPI1_SCK |
| T_CS | PA15 | Touch Chip Select | Manual GPIO control |
| T_DIN | PA7 | Touch Data In | SPI1_MOSI |
| T_DO | PA6 | Touch Data Out | SPI1_MISO |
| T_IRQ | PA8 | Touch Interrupt | GPIO input |
| UART Pin | STM32F407 Pin | Function | Notes |
|---|---|---|---|
| TX | PA2 | Debug output | USART2_TX (AF7) |
| RX | PA3 | Debug input | USART2_RX (AF7) |
- STM32CubeIDE Version: 1.17.0
- STM32CubeMX (for configuration)
- STM32 HAL Library (included)
- LVGL v9.4.0 (included as submodule)
- Git (for cloning repository)
- Install STM32CubeIDE from STMicroelectronics website
- Install Git for version control
- Have your STM32F407 board and ILI9341 LCD ready
-
Clone the repository:
git clone https://github.com/dchithinh/stm32f407xx_pomodoro.git cd stm32f407xx_pomodoro -
Initialize LVGL submodule:
git submodule update --init --recursive
-
Open in STM32CubeIDE:
- File โ Import โ Existing Projects into Workspace
- Select the project folder
-
Configure build:
- Right-click project โ Properties โ C/C++ Build
- Select your preferred configuration (Debug/Release)
-
Build the project:
- Press
Ctrl+Bor use Project โ Build Project
- Press
- Connect ST-Link debugger to your STM32F407 board
- Flash the firmware:
- Right-click project โ Run As โ STM32 C/C++ Application
- Or use the debug configuration for development
- Power on the system
- Touch the screen to interact with the Pomodoro timer
- Start a session by tapping the start button
- Monitor progress through the circular progress indicator
- Take breaks when prompted between work sessions
- View statistics to track your productivity
Connect a USB-to-TTL adapter to UART2 pins (PA2/PA3) to see debug output:
- Baud rate: 115200
- Data bits: 8
- Stop bits: 1
- Parity: None
stm32f407xx_pomodoro/
โโโ ๐ Core/
โ โโโ ๐ Inc/ # Header files
โ โ โโโ main.h
โ โ โโโ clock_config.h
โ โ โโโ debug_utils.h
โ โโโ ๐ Src/ # Source files
โ โโโ main.c
โ โโโ clock_config.c
โ โโโ debug_utils.c
โโโ ๐ bsp/ # Board Support Package
โ โโโ ๐ lcd/ # LCD driver
โ โโโ ๐ lvgl/ # LVGL port
โโโ ๐ lvgl/ # LVGL library (submodule)
โโโ ๐ Drivers/ # STM32 HAL drivers
โโโ ๐ Doc/ # Documentation and images
โโโ ๐ README.md # This file
The project supports multiple clock configurations in clock_config.h:
// Uncomment one of the following:
// #define USE_HSI_16MHZ 1 // 16MHz HSI
// #define USE_HSI_84MHZ 1 // 84MHz PLL
// Default: 168MHz HSE PLLDisplay settings are configured in bsp/lcd/config.h:
- Resolution: 240x320
- Color depth: 16-bit RGB565
- Orientation: Portrait/Landscape
Debug features can be enabled/disabled in debug_utils.h:
- UART logging: Enable/disable debug output
- Touch cursor: Visual touch point indicator
The project uses SPI2 for LCD communication with the following settings:
- Mode: Full-duplex master
- Clock polarity: Low (CPOL=0)
- Clock phase: 1st edge (CPHA=0)
- Data size: 8-bit
- MSB first
- Version: LVGL v9.4.0
- Color depth: 16-bit (RGB565)
- Memory: Static allocation
- Input: Touch controller integration
- SPI Read Operations: Unable to read LCD ID/status registers reliably
- 16-bit HAL SPI: Issues with 16-bit transfers using HAL API
- Touch Input Lag: On first touch at a new position, the system may respond to the previous touch location. A second touch is required to register the correct position.
- System Stability at 168MHz: When using 168MHz system clock configuration, the system occasionally hangs or generates hard faults. Consider using 84MHz configuration for more stable operation.
I'm an embedded developer, not a UI/UX designer - so the UI in this app may not be that great! ๐ Feel free to improve the user interface and make it more beautiful. The original purpose of this project was to learn LVGL, STM32 HAL, and SPI communication - and I'm always excited to see how the community can enhance it further!
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style
- Add comments for complex functions
- Test your changes thoroughly
- Update documentation as needed
- niekiran/EmbeddedGraphicsLVGL-MCU3 - Original inspiration
- LVGL Team - Amazing graphics library
- STMicroelectronics - STM32 ecosystem and HAL library
- MicroPomo - Windows simulator for testing the Pomodoro app
- Embedded systems community - For knowledge sharing and support
- GitHub: @dchithinh
- Project Link: https://github.com/dchithinh/stm32f407xx_pomodoro
โญ Star this repository if you found it helpful!
