Smart Clock
A smart clock with an alarm, display, temperature/humidity monitoring and a web interface.
Author: Dumitrescu Andrei-Bogdan
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-Andreid04
Description
This project is built using the Raspberry Pi Pico 2W, capable of displaying the current time and date on a small OLED display, and live temperature/humidity data on another small LCD display that also shows a real-time graph of both temperature and humidity. The current temperature and humidity also change color depending on their value. The device fetches accurate time from the internet every 3 to 6 hours, and offers a web interface for setting alarms. Alarms can be heard through a passive buzzer placed on the breadboard.
Motivation
I always wanted a machine that sits on my desk and keeps track of time and schedule related stuff while also offering information about what is happening in the air of my room(humidity and temperature). I wanted a fully customizable clock that is also "smart" but i could not find anything that i like in a store. So i decided to take this opportunity and create the smart clock that i wanted with full customizability and pleasent looking OLED and LCD displays for a fraction of the price of a similar clock bought from the internet.
Architecture
General Schematic
Components overview
- Microcontroller
- The Raspberry Pi Pico 2W microcontroller handles the data from the sensor and the web interface in order to active an alarm, show and update information on the screens;
- Sensor service
- polls DHT22 for temperature & humidity every 2 seconds and writes the data to the LCD display, updating the graphs in real time;
- Clock Service
- fetches the exact time from the internet every 6h and keeps local RTC synced;
- Alarm Handler
- creates and triggers the alarm created by the user;
- Display units
- The OLED display shows the clock, alarms and the date;
- The LCD display is used for temperature and humidity monitoring and their respective graphs.
Log
Week 5 - 11 May
- Set up ST7735 lcd and SSD1306 oled displays with embedded-graphics.
- Drew dynamic temperature/humidity graphs and live colored changes if values are between a known good range.
Week 12 - 18 May
Week 19 - 25 May
Hardware
- 2x Raspberry Pi Pico 2W (one acts as a debugger): The brains of the smart clock. It supports the wi-fi interface for sending and receiving data from an external device;
- Breadboard + jumper wires: for connecting the peripherals to the pico and to power;
- ST7735 TFT LCD display (SPI): acts as a colored screen for displaying the temperature and humidity info, their graphs and color mapping if the paramters are healthy or not(green, yellow and red);
- SSD1306 OLED (secondary SPI display): used for displaying the clock, the date and the alarms;
- DHT22 (temperature + humidity sensor): used for monitoring the temperature and humidity of the air with the help;
- Passive buzzer + resistor (GPIO controlled): a buzzer that is controlled through PWM on a PWM capable GPIO pin(15);
- 12V power supply terminated to a barrel jack feeding the HW131 power supply that outputs regulated 3.3V and 5V DC. (I only use 3.3V for this project).
Schematics
KiCAD schematic
Bill of Materials
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico 2W | The microcontroller | 40 RON |
DHT22 Sensor | Temp & humidity monitoring | 23 RON |
ST7735 LCD | Color display 160x128 1.8' | 29 RON |
Passive Buzzer | Alarm feedback | 2 RON |
Kit Breadboard + wires + HW131 power supply | Prototyping setup and 3.3/5V PSU | 22 RON |
SSD1306 OLED | Secondary text display for clock and alarms | 24 RON |
Software
Library | Description | Usage |
---|---|---|
ssd1306 | Crate to interface with SSD1306 OLED display | Control the display |
st7735 | Display driver for ST7735 LCD | Control the display |
embedded_graphics | 2D graphics library that is minimal in used resources | Used for writing and drawing to the display |
embedded_hal | Abstraction layer for MCU drivers | Interfaces for all peripherals |
embedded_dht_rs | Temperature/humidity sensor crate | For controlling and reading data from the DHT22 sensor |
embassy_rp | Access to the pheripherals | Initializing and talking to peripherals |
embassy_executor | Provides an executor for running asynchronous tasks concurrently | Execute asynchronous tasks concurrently |
embassy_time | Timekeeping, delays and timeouts | Schedule tasks to run at specific times |
defmt | A highly efficient logging framework that targets resource-constrained devices, like microcontrollers | Prints out messages in the terminal(debugging) |