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

by ouassimboutalliss in Circuits > Raspberry Pi

3154 Views, 8 Favorites, 0 Comments

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

104102413_2678506905768335_1991263196254045322_n.jpg

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

Components and Materials

104224824_558924618107128_5345640715951739691_n.jpg
82949592_1605879952912653_6296791538519340312_n.jpg
104115902_984518318656389_6091484835040579890_n.jpg

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.

Components:

  • 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

Materials:

  • Wood 7mm
  • Wood 2cm
  • Cling film

Tools:

  • Soldering
  • Super glue
  • Saw
  • Screwdrivers
  • Drill

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

Putting the Hardware Together

Fritzing.JPG
104298783_3049500015158253_2303215899850167094_n.jpg

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

Database Model (mySQL)

EER.JPG

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.

Connection With the Raspberry Pi

putty.JPG

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.

Software on the Raspberry Pi

Classes.JPG

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
  • RPI.GPIO
  • datetime
  • threading
  • time
  • subprocess
  • mysq
  • lSocketIO

Setting Up a Webserver on Raspberry Pi

Webserver.JPG

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.

Software: Python

app.JPG

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 app.py. 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.

Software: Website

page1.JPG
page2.JPG
page3.JPG
Page4.JPG

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.

Building the Case

104102413_2678506905768335_1991263196254045322_n (1).jpg
104096172_778023772733359_2076043074376400872_n.jpg
103954983_306683897398441_902688646019211389_n.jpg
103101959_923616988102255_364633857864119136_n.jpg
104058616_2712366712368362_5659513200901008673_n.jpg
82949592_1605879952912653_6296791538519340312_n.jpg
83214337_1176054072731171_7307719687591135673_n (1).jpg
83214337_1176054072731171_7307719687591135673_n.jpg
103826580_660414584512022_8448333282758938861_n.jpg
103847836_706955446785971_2905545133135180698_n.jpg
103931085_3221561697902296_2344368652107847176_n.jpg
103975730_264569458097592_7711607669709679946_n.jpg
103986481_616353519231364_1752628469102548708_n.jpg
103992906_2605399243055225_7928619361780604967_n.jpg
104004101_295298581625090_882864255083777296_n.jpg
104017723_829500234125322_1990295432012535630_n.jpg
104077006_793168594421644_5226508919383620960_n.jpg
104111667_3268173149862305_2384837989022604972_n.jpg

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.

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.

Downloads