Crawfis, Gilmartin, Harkenrider 1 The Dining Hall Alarm Clock Aaron Crawfis Web Fetching and Parsing Gina Gilmartin Clock and Alarm Functionality Kenneth Harkenrider User Input and Output Crawfis, Gilmartin, Harkenrider 2 Executive Summary The Rise & Dine group set out to produce a dining hall alarm clock for the CSE 20232 final project. The group planned, researched, implemented, and built a functioning alarm clock using only a Raspberry Pi, Arduino, LCD display, buttons, and a speaker. This report contains the details of each portion of the group’s experiences, along with the technical details of each subcomponent. Table of Contents: Topic: Page #: Introduction 03 Methodology 04 Hardware 07 Web Fetching and Parsing 08 User I/O 09 Clock and Alarm Functionality 10 Results 11 Discussion and Future Work 12 Sources 12 Crawfis, Gilmartin, Harkenrider 3 Introduction The Rise & Dine project was developed with the intent of being a time and energy efficient device for breakfast enthusiasts that would maximize sleep time and the consumption of a user’s favorite food(s). The problem this device aims to solve is deciding whether to go to the dining hall in the morning or get an additional twenty minutes of sleep. Currently, this process involves getting a phone or computer, going to the dining hall website, and scanning through it for a favorite food. In the morning, there is little time for unnecessary tasks, and this is where the dining hall alarm clock comes in. Building upon prior experience and expertise, the group decided to develop an embedded hardware project. The group wanted to employ at least one Arduino and use it as a base for a larger software project. Having established the alarm clock idea, the group also realized that a Raspberry Pi would be necessary to accomplish the determined goal. The base functionality that the group desired was an alarm clock that could set itself automatically according to the dining hall website. Thus, the project was split into two main categories: web fetching and alarm clock. Both categories could be built and tested independently. Within the alarm clock category further distinctions were made between input/output and basic clock functionality. Each group member assigned himself/herself to a section depending on his/her strengths, using multiple prebuilt APIs to allow for faster and more advanced development. Crawfis, Gilmartin, Harkenrider 4 Methodology Overview and Main Control Flow The first goal of the team was to set a rigid schedule to follow throughout the design and implementation processes. Figure 1 shows the team’s final production schedule as a gantt chart. Figure 1 : Project Gantt Chart After the schedule was set, the next step was to create flowcharts laying out the basic steps necessary to make an alarm clock. Using prebuilt APIs, basic clock functionality could be built into an Arduino. The majority of the group’s planning went into connecting the time functions with the LCD display. The main software libraries used by the group included Time, LiquidCrystal, curl, and wiringPi. These libraries provided the basic functionality in each category of design necessary to allow for more advanced programs to be built. After finalizing the basic structure, the group planned out the individual functions that would be used on the Raspberry Pi and Arduino. Table 1 lists these functions, along with the inputs and outputs. Crawfis, Gilmartin, Harkenrider 5 Table 1: Function List w/ Inputs & Outputs Function Name Input Output Description getTime void User Input void LCD Output Display a menu on the screen prompting the user for the current time. Testing plan : Will test/debug by only asking for one variable (hour) getAlarm void User Input void LCD Output Display a menu on the screen prompting the user for the alarm setting. Testing plan : Will test/debug by only asking for one variable (hour) displayTime int sec, min, hour void LCD Output Display the current time on the screen. Testing plan : Will first test/debug using a time that is set as a constant already defined, not being read in displayAlarm void void LCD Output Display a message on the screen when the alarm is going off. Testing plan : Will first test/debug using an alarm time that is set as a constant already defined, not one that is read in setTime int sec, min, hour void Seed the current time of the Arduino time library using the values the user input with the getTime function. Testing plan : Will first test/debug by seeding in only the hour, which will be a defined time, not input by the user setAlarm int alarmMin, alarmHour void Sets an alarm time saved in the Arduino. Testing plan : Will test/debug with only the hour integer Crawfis, Gilmartin, Harkenrider 6 runClock void void Check the current time against the alarm time, send the current time to displayTime function to be displayed. Testing plan : Will first set up compare without looping through continuously runAlarm void void Turn on the alarm when the current time is equal to the alarm time and play a sound. Testing plan : Will test/debug with the alarm playing one note for the alarm getWeb inFile.txt outFile.txt Read the text from the dining hall menu website and write it into a .txt file. Testing plan : Will test by looping to make sure both the input and output files are actually found and are not null, will start by reading in one line searchWeb outFile.txt void Search the .txt file created in the getWeb function for a string of the favorite food. Testing plan : Will test using a simple .txt file that we create with a list of foods triggerAlarm int isFood void GPIO Pins Set a high value to a GPIO (general purpose input output) pin if input == true or set a low value if input = false. Testing plan : Will first test/debug by sending a high value, then a low value, manually changing them (not dependent on whether the food is actually there or not) After the key functions were planned out, flowcharts were produced to place them in the proper order, both for the Arduino and the Raspberry Pi programs. Figures 2 and 3 show how the group planned to implement the functions. Crawfis, Gilmartin, Harkenrider 7 Figure 2 : Raspberry Pi Flowchart Figure 3 : Arduino Flowchart Once all of the subcomponents were complete they were integrated into a final program and added to the hardware setup. Hardware An Arduino and Raspberry Pi were used as a base on which to build the alarm clock. The Raspberry Pi was used to fetch website data and the Arduino ran the clock. Figure 4 displays the final hardware setup of the completed alarm clock. Crawfis, Gilmartin, Harkenrider 8 Figure 4 : Final Hardware Diagram The Raspberry Pi connects to the Arduino via three wires: +5V, ground, and a trigger port. An ethernet cable and 5V power supply are connected to the Raspberry Pi to supply internet access and power. The Raspberry Pi will scan the dining hall website for the user’s favorite foods, and the trigger port will supply +5V if the search is successful or supply ground if the search fails. Two buttons, a speaker, and an LCD display are also connected to the Arduino. The buttons employ pullup resistors built into the Arduino, allowing for less external hardware. 2 The LCD display is built upon the I C protocol, requiring only two outputs on the Arduino, along with the pins for power. Web Fetching and Parsing Once powered on, the Raspberry Pi will fetch the HTML file of the dining hall website and save it to output.txt on the device using getWeb(). The curl library is employed to perform the fetch. Once the file is saved, the searchWeb() function performs a string search on output.txt. The keyword string(s) comes from food.txt, and a search is run for each keyword found in the file. The food.txt file allows the user to have multiple favorite foods and edit them easily. Once the search is complete, triggerAlarm() is run and +5V is supplied to the Arduino Crawfis, Gilmartin, Harkenrider 9 input pin if the search was a success or ground if the search was a failure. The output to the GPIO pins of the Raspberry Pi is handled by the wiringPi library. Once the search is complete, the device sleeps for 10 minutes and the process is repeated. The complete process can be seen in Figure 5. Figure 5 : Web Fetching and Parsing Process User Input and Output The user I/O interface consists of two push buttons, one that acts as an increment button and another that acts as a select button, an LCD, and the functions getTime(), getAlarm(), displayTime(), and displayAlarm(). The goal was to recreate a typical alarm clock interface that allows the user to set the hour and minute for both the time and an alarm. For all other time, the device would display the current time. Additionally, when the alarm is triggered, the LCD will also display a message that indicates whether or not the user’s favorite breakfast food is being served at the dining hall. Arduino’s LiquidCrystal library was implemented to utilize the LCD display. The functions getTime() and getAlarm() work similarly by displaying a menu on the LCD while the user sets the hour variable with the increment button. Then, after the user presses the select button, the hour variable is saved and the display menu changes to request the minute. The user again presses the increment button to set the desired value for the minute variable and presses select to save the variable. Crawfis, Gilmartin, Harkenrider 10 The displayTime() function takes the current values of the hour and minute variables, converts the hour into standard 12hour time with AM/PM using a series of ifelse statements, and prints the result to the LCD. Gina’s runClock() will call displayTime() from within to continually display the current time to the user. The function displayAlarm() simply writes an affirmative or negative statement to the LCD to alert the user as to whether or not food is present. displayAlarm() will be called every time the alarm is triggered, and depending on the status of the food (which is determined by the input from the Raspberry Pi), the function will write a corresponding message to the LCD. Clock and Alarm Functionality The clock time will be kept using the Time library for the Arduino. When the user inputs the values for the hour and minute in the steps above, the variables will be passed into the setTime() function that will use the variables as seed time values. After this point, the Arduino will be able to keep accurate time on a twentyfour hour clock. When the function displayTime() calls for the time, it will receive the updated time from the Arduino. The function runClock() will be used to make sure that the clock is always displaying the current time and that the alarm rings when it is supposed to. If the user presses one of the buttons while this loop is running, they would be able to readjust the clock or alarm settings. This function first calls displayTime(), then it checks to see if the alarm should be set twenty minutes earlier by reading the trigger port from the Raspberry Pi. If the favorite food is there, the alarm time is set back twenty minutes (the function checks if the hour needs to be readjusted as well). The function checks the current time versus the alarm setting, and when the two are equal the runAlarm() function is called. The function runAlarm() will cause the speaker to make noise, call the displayAlarm() function, and check whether the user presses the off button or the snooze button. If the off button is pressed, the alarm will stop ringing and the LCD will continue to display the current time. If the snooze button is pressed, a temporary variable will be created that will keep track of the seconds that have passed since the button was pressed. Once 300 seconds (five minutes) have passed, the alarm will continue ringing until either the off button or snooze button is pressed again. After the alarm is turned off, a variable stating that the alarm has run is set to true to avoid having the clock ring for an entire minute when the current minute is equal to the set alarm time minute. This variable is reset to false at midnight in the runClock() function. Crawfis, Gilmartin, Harkenrider 11 Results The initial gantt chart proved to be a very realistic timeline for the group. Tasks deviated from the schedule rarely, and each subcomponent was completed on time. The final build was successfully pieced together, and the final software functioned as intended: the device will scan the dining hall website and trigger a homemade alarm clock. Figure 6 shows the completed project. Figure 6 : Final Version of Rise & Dine Clock Device An enclosure was built for the Arduino alarm clock to allow for easy containment and a clean, aesthetic quality. The Raspberry Pi was placed outside the enclosure because it could not fit inside. The alarm clock was tested on the morning of Monday, December 15, 2014. Oatmeal was selected as the favorite food, as it was known to be on the menu. The initial alarm time was set for 8:00 AM. At 7:40 the alarm was triggered, waking up the user and proving the alarm clock functioned as intended. Crawfis, Gilmartin, Harkenrider 12 Discussion and Future Work This project was a great learning experience for the group. Triweekly meetings provided just the right amount of time to produce the alarm clock, and each member had ample time to complete his/her portion of the project. Many obstacles were met, and each solution increased the group’s knowledge of embedded projects, software development, and teambuilding. The completed alarm clock can be used as a vital tool for college students. Many more features could be implemented into it to make it more robust and powerful, such as setting the favorite food menu through the Arduino, displaying the date along with the time, or retaining the time when removed from power. With more time to work on the project, the group would be capable of adding all of these features and more. Code Libraries: http://playground.arduino.cc/Code/Time (Time) http://arduino.cc/en/Tutorial/LiquidCrystal (LiquidCrystal) http://curl.haxx.se/ (curl) http://wiringpi.com/ (wiringPi) Image Sources: http://fsntserv.foodserv.nd.edu/dh_menus/ndh_menu_today.cfm http://www.easyvectors.com/assets/images/vectors/afbig/9f381bc89cd6577b72693b13917dd12bmagnifying glassclipart.jpg https://cdn.sparkfun.com//assets/parts/7/4/9/7/1154604.jpg http://static.rapidonline.com/catalogueimages/Module/M500165P01WL.jpg https://img.4plebs.org/boards/pol/image/1398/80/1398800834069.png https://openclipart.org/
© Copyright 2026 Paperzz