Introduction: Smart Alarm Clock: a Smart Alarm Clock Made With Raspberry Pi

About: student MCT at Howest (Kortrijk Belgium)

Have you ever wanted a smart clock? If so, this is the solution for you!

I made Smart Alarm Clock, this is a clock that you can change the alarm time according to the website. When the alarm goes off, there will be a sound (buzzer) and 2 lights will be lit (2 LEDs). The LEDs will only light up when it's dark (light sensor). The LEDs ensure that the room is brightened up so that you can stand up naturally. To disable the alarm, press the button. When you want to use the snooze function(+5min), you have to hold your hand in front of the ultrasonic sensor. If motion is detected (ultrasonic sensor), the status of the LCD will change.

Status of LCD:

  1. Ip-adress of the website
  2. Clock / date
  3. Next alarm time
  4. Temperature and humidity

This is my first project in my field of study: Multimedia and communication Technology (MCT) at Howest (Kortrijk belgium).

Step 1: Components and Materials

For my project i used multiple parts that i will be listing below, I'll also add the excel file with all the corresponding prices of the components as also the websites from which I ordered them.


  • Raspberry Pi 3 model B+
  • Raspberry Pi power supply
  • Lcd display
  • Buzzer
  • LDR
  • 2 Led's
  • DHT-11
  • HC-SR04 Ultrasonic distance sensor
  • Button
  • Trimmer


  • Wood 7mm
  • Wood 2cm
  • Cling film


  • Soldering
  • Super glue
  • Saw
  • Screwdrivers
  • Drill

In the PDF file below you can see the complete price list.

Step 2: Putting the Hardware Together

I have build my circuit by following my Fritzing scheme that I made, I uploaded the scheme below. The circuit has multiple sensors and an actuator that works together as one. I will list which different circuits there are, how you will need to connect these u can find in the scheme.

  1. There is a ultrasonic distance sensor that detect motion at a distance of 15 cm(self coded distance) and it change the status of the lcd but if the alarm is on, it snooze the alarm for 5 min.
  2. There is a LCD screen which displays 4 statuses (ip-address, date/time, next alarm, temp/hum)
  3. A dht11 that measure the temperature and the humidity of the air
  4. A button to disable the alarm or if u press longer then 3 seconds the rpi will shut down
  5. A buzzer to make noice if the setted alarmtime is matched the current time
  6. A LDR sensor to measure the light in the room
  7. 2 Led's to bright up the room if it's dark -> LDR

Step 3: Database Model (mySQL)

You can see my ERD diagram above, I will also link a dump file so you can import the database for yourself.

With this database you will be able to show multiple things like:

  • The temperature
  • Humidity
  • Light value
  • Setted/disabled/snoozed alarmtime
  • If buzzer works
  • If the lights are on

If you want to recreate this database you will need to make a new user so you can connect to your Raspberry Pi.

Step 4: Connection With the Raspberry Pi

First of all you will need to download Putty, there is a free version available on their website. You'll also need Raspbian which you can download here.

When you open Putty you'll need to click on 'session'. When you have done that you'll need to fill in the IP address of the Pi under 'Remote Host'. Then you can enter a username which you can choose. then click on 'OK'.

Normally after all these steps it will automatically startup a connection. Then you'll need to enter your password, and you're connected.

Step 5: Software on the Raspberry Pi

For my code to work (which I will link below) you'll need to install some packages and libraries. First thing that is needed is for you to update your Pi.

First, update your system's package list by entering the following command: sudo apt-get update Next, upgrade all your installed packages to their latest versions with the following command: sudo apt-get dist-upgrade After you have installed the packages you'll need to install some libraries:

  • Flaskflask_cors
  • datetime
  • threading
  • time
  • subprocess
  • mysq
  • lSocketIO

Step 6: Setting Up a Webserver on Raspberry Pi

Go to your Putty console.

we're going to install Apache webserver. By doing so you will be able to open the website on any device connected to your network. Type the following command and press enter: sudo apt-get install apache2

Now go to the folder: /var/www/html/ Here can you place all your files from your website and the index.html page will be opened whenever you browse to the IP of your Pi. be careful not to type a capital I in index.html otherwise it will not automatically open the index page.

Step 7: Software: Python

I made multiple python scripts, I will link my githubhere so you can view the code for yourself. But I'll explain it a little bit already.

I coded some classes for the Ultrasonic sensor, lights, LDR and LCD. I used libraries for the DHT11-sensor. (import Adafruit_DHT) Eventually I use only one file to make the full project work, this is named Also in this file i coded some routes so I could read data from my database and sent in to a json object which I then used in my javascript files.

Step 8: Software: Website

Because I made an opportunitie that u can set an alarm on the website. So I made a website to let me do this. Through the website you can also watch the humidity, temperature and the history.

While the Pi is booting up, it will start running my python script. This will be taking care of getting the data to show on the website and making it possible to set an alarm. The site is also responsive so it could be opened on mobile without losing features or otherwise.

My code can be found on github right here.

Step 9: Building the Case

For my case, I build a box to mimic a clock.

I also put pictures where you can see the process of building the case. For the measurments I'll also uploaded a file below where you can see my schematic of how you could recreate it.

Step 10: User Manuel

Here you can find a quick manual of how the project works. Hopefully your day will be better if u made thiss smart alarm clock at the end of this tutorial!

Thank you for reading.