2019 Fall Embedded System Lab Final Project - Awesome Alarm

Author:

Department: 4-th year, Electrical Engineering Department, National Taiwan University
Advisor: Professor Sheng-De Wang
Github repo: https://github.com/NTUEE-ESLab/2019-AwesomeAlarm
Mbed repo: https://os.mbed.com/users/yungsung/code/AwesomeAlarm_BLE/
Slide: https://docs.google.com/presentation/d/1IQKsBf2jPfg-3wsu4O3Ukr4jt6mabXckDCMN17Xowb4
Report: https://github.com/NTUEE-ESLab/2019-AwesomeAlarm/raw/master/report.pdf
Demo video:

Project date: January 2020

Content

Abstract

In this project, we have successfully developed a creative alarm called “Awesome Alarm”. By using Awesome Alarm, the user can wake up easier and with more fun! We integrated several sensors for STM-32 to enable the user to be waked up by light, instead of disturbing ringing which may annoy your roommates. The alarm can be easily set by Android App. Awesome Alarm is made up by an STM32 Discovery IOT board.

Motivation

To some of us, sleep is a luxury, a hobby or a favorite pastime. A common problem for almost everyone would probably be to wake up in time! Be it for work, class, meetings, or the day’s activities, the alarm clock is a must-have item in the bedroom. However, we are bored with the mundane ringing, hand-sized clocks that we can easily throw out the window to shut up, we decided to develope a innovative and effective alarm full of funs.

Implementation

I. System Diagram

As the below figure shows, the Awesome Alarm can be highed above the bed and let the ultrasonic sensor point the region around the head. Set the alarm by the app, and it will wake you up then with light point emitting to your face. You can turn off the alarm by getting up and using the laser gun to shoot the light sensor at the center of the target circle pad.

II. System Structure

The below shows the flowchart of Awesome Alarm. An ultrasonic sensor connected to the STM32L475 board (Discovery kit IoT node, called STM32 thereafter) are used to detect the position of the head. Then STM32 controls the steering engine (and the flashlight equipeed on it) to point to the head. STM32 is connected to the cellphone through BLE, and the user can set the alarm time. When the time is up, the alarm rings. Once the light sensor connected to STM32 receives the light emitted from the laser gun.

III. HardWare Assembling

1. Modules

Ultrasound Sensor HC-SR04 Servo motors (MG996r) x2 Digits Display (TM1637)
Light Sensor (PhotoResistor) Buzzer Big LED x9

2. Appearance

We used 3D printer to make out the outer casing of the alarm, and fixed the steering engine to the case, as shown below.

Front view Side view

3. Ultrasound Head Position Detection

We use the ultrasound distance sensor HC-SR04 to scan the distance to the bed in every angle before the user go to bed. When the user needs to wake up, it scans again to find the position where the distance decreases the most. The distance decreases means the user’s head is there. A flashlight and buzzer sound appear directly to user’s head. If the returned value is too short (sensor is not stable in sometimes), we detect the distance again.

4. Software Architecture & Thread design

In our program, the STM32 board needs to do many things at the same time, so we use threading to handle all the timing overlapping in differenct functions. For example, the BLE boardcast and timer are running in all time, which use two threads to run. The same situation happened among buzzer and light sensor and the ultrasound sensor. When the user sets a wake up time, the digits display, driven by a semaphore, will stop display time. And the countdown time (in seconds) will get the semaphore to display itself on the digits display.

5. Laser Gun Target Detection

We use a light sensor, which have a photoresister on it, to detect the laser emitted by the user’s laser gun. Under normal light, the sensor would return values ranging from 200 to 500. When a powerful laser is emitted to it, the return value would drop to <100. We sets the threshold to 100 to distinguish whether the user successfully shots the target.

IV. App Interface

The below figure shows the designed app interface. The user can click “BT List” button to scan and connect the alarm. Click “Disconnect” to disconnect the alarm. Click “Select Time” to set the alarm time. Click “CountDown” to use countdown function. When the alarm rings, click “TurnOff” to turn off the alarm.

Setup & Usage

Board side

  1. Go to mbed online compiler https://os.mbed.com/ide/
  2. Import our code at https://os.mbed.com/users/yungsung/code/AwesomeAlarm_BLE/
  3. Compile! Burn the binary into STM32.

Client side

  1. install the Android app with the APK file /android_app/ES_Final.apk

Challenge

Achievement

To sum up, we solved lots of problems, including integrating several sensors and mortors, head position detection, and APP-STM32 communication. And we not only test developed the code theoretically but also made a prototype of Awesome Alarm.

Reference