For this project, I chose a clock that displays time, temperature, and humidity. It uses low power mode to save power and maximize battery life. The clock can also be used to set an alarm and the time can be adjusted. This clock requires a battery or a micro-USB cable to power on. The alarm clock comes with a snooze function and the alarm can be turned on/off whenever the user pleases. The top line of the LCD displays the time in hh:mm format and the symbol (ö) which indicates the alarm is on. The bottom line of the LCD shows the temperature (°C) and humidity (%), or the clock state.
General view |
For this project, I used a Freescale MKL05Z32VFK4 kinetis microcontroller from the KL05 Kinetis family series because of it is efficient, and it has good low power mode capability. For the display, I used a 2x8 character Newhaven LCD display with backlight. The time is updated by the DS3231MZ real-time clock. The DS3231MZ real-time clock is powered by a CR2032 battery when the alarm clock is not powered on to keep the time updated. The temperature and humidity is read from the Texas instrument HDC1050 which has low power capability and highly accurate digital humidity sensor with temperature sensor. It also has a buzzer that signals when the alarm time is reached. The alarm clock can be powered by using a micro-USB connector or an AAA battery.
Schematic | Assembly | |
This program first configures the hardware and runs through the setup routine. When the main loop runs, it checks the buttons to see if they are pressed and performs the function based on the current clock state. The diagram below displays the clock states, the functions it performs at each stage, and the mode each button changes to when it is pressed. The program also puts the microcontroller to sleep and wakes it up every 20 miliseconds to save power and efficiently use the battery life. Also, it includes code for accurate the button debouncing. In state 0, at the end of each loop, if the alarmOn variable is equal to 1 (meaning the alarm is on), the current time is compared with the alarm time and if the alarm time is equal to the current time, the buzzer starts to beep. It beeps and stops every 20 milliseconds so as to produce a repetitive sound. The buzzer stops making sounds when the snooze button is pressed.
Here:
I am pleased with my project functionality and design. I can use this as my daily alarm which is good for me because the buzzer sounds really loud. I look forward to learning more about microcontrollers and working with microcontrollers in other projects as they are inexpensive, fast, and flexible.
Last modified:Mon, Jan 23, 2023.