This project is about a device that can be use as a bedtime alarm and counting time spent in studying. The user must first set the bedtime alarm with an infrared remote and it will be saved in the device. The alarm will rang at the bedtime, and the user will be able to stop it. It is assumed that the time the user stops the alarm is the time the user start sleeping, so the device will calculate the interval between the bedtime alarm and the time the user stop the alarm in order to find how late the user sleep. In addition, the device will also be able to count the time user spent in studying by detecting the presence of user in their study table and counting the time user sit there assuming sitting there means studying. Those data will be sent into Thingspeak.com and will be displayed as a graph and the user will be able to evaluate their sleep lateness and study time by seeing it in the app.
The component used in the circuit will be divided into three category, namely the microcontroller, sensor, and actuator:
- ESP32
- Ultrasonic sensor
- Real Time Clock (RTC module)
- Infrared receiver and infrared remote
- Liquid Crystal Display I2C(16x4)
- Red LED
- Buzzer
ESP32 | Ultrasonic Sensor |
---|---|
D35 | ECHO |
D32 | TRIG |
GND | GND |
VCC | 5V |
ESP32 | Red LED |
---|---|
D33 | Anode |
GND | Cathode |
ESP32 | IR Receiver |
---|---|
D12 | DAT |
GND | GND |
VCC | 3.3V |
ESP32 | Buzzer |
---|---|
D18 | 2 |
GND | GND |
ESP32 | LCD I2C |
---|---|
D21 (SDA) | SDA |
D22 (SCL) | SCL |
VCC | 5V |
GND | GND |
ESP32 | RTC Module |
---|---|
D21 (SDA) | SDA |
D22 (SCL) | SCL |
VCC | 5V |
GND | GND |
- | SQW |
First, the microcontroller, which is ESP32, will setup and initiate all components, such as sensors and actuators, connected to it. Using LCD, it will prompt user to input their bedtime alarm in the format of hour and minute, check the validity of time, and saves it in a variable. The input will be done with IR remote and the IR receiver, which will detect the button pressed by the user. After that, the ESP32 will constantly compare the current time supplied by RTC module with the bedtime alarm. If the current time is the same as the bedtime alarm, the ESP32 will ring the buzzer and start counting time interval. The user will be able to stop the buzzer by pressing the power off button and then the ESP32 will stop counting time and it will send that time to ThingSpeak using HTTP. The ThingSpeak will display that data as a graph. At the same time, ESP32 will constantly check the presence of user at their study table with the ultrasonic sensor. If there is an object within the 30 centimeter, the ESP32 will turn on the study light and start to count time. If the object move away from the study table, the ESP32 will stop recording time and send it to ThingSpeak to be displayed as graph. The user will finally be able to check those data from the application that embed those graph.
Create android app version