Skip to main content
Version: FILS English

Smart Clock

A smart clock with an alarm, display, temperature/humidity monitoring and a web interface.

info

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

schema

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.

progress1

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).

hw1

Schematics

KiCAD schematic

kicad

Bill of Materials

DeviceUsagePrice
Raspberry Pi Pico 2WThe microcontroller40 RON
DHT22 SensorTemp & humidity monitoring23 RON
ST7735 LCDColor display 160x128 1.8'29 RON
Passive BuzzerAlarm feedback2 RON
Kit Breadboard + wires + HW131 power supplyPrototyping setup and 3.3/5V PSU22 RON
SSD1306 OLEDSecondary text display for clock and alarms24 RON

Software

LibraryDescriptionUsage
ssd1306Crate to interface with SSD1306 OLED displayControl the display
st7735Display driver for ST7735 LCDControl the display
embedded_graphics2D graphics library that is minimal in used resourcesUsed for writing and drawing to the display
embedded_halAbstraction layer for MCU driversInterfaces for all peripherals
embedded_dht_rsTemperature/humidity sensor crateFor controlling and reading data from the DHT22 sensor
embassy_rpAccess to the pheripheralsInitializing and talking to peripherals
embassy_executorProvides an executor for running asynchronous tasks concurrentlyExecute asynchronous tasks concurrently
embassy_timeTimekeeping, delays and timeoutsSchedule tasks to run at specific times
defmtA highly efficient logging framework that targets resource-constrained devices, like microcontrollersPrints out messages in the terminal(debugging)
  1. SSD 1306 setup with SPI
  2. Pico 2W in kicad
  3. DHT22 data sheet and crate usage
  4. Embedded-graphics examples
  5. Simple rust examples with pico