DIY: Make a ScheduleBot to Remind You of Events

by Evie Laskaris in Circuits > Raspberry Pi

506 Views, 6 Favorites, 0 Comments

DIY: Make a ScheduleBot to Remind You of Events

CoverImage.jpg

Sometimes you need someone, or something, to remind you of a task or an event, like doing the laundry or going to a meeting. The ScheduleBot was created for this purpose by saying the reminder to you at the time you want. After answering some questions to the bot about what your event is, when it takes place, and when you should be reminded, the bot will save your request and remind you.

Supplies

  • Raspberry Pi
  • 2 DC Adapters
  • Keyboard
  • Mouse
  • Speakers
  • Screen

Set Up the Raspberry Pi

YOU BETTEWR DOWNLOAD OR ELSE.png
ipqjeiajpwierjgiqetj.png
aspfjoaisjgpioarjgpioaj.png
snippy snip snip snip.png
raspberry.png
download.png

The Raspberry Pi [3] is a small computer that is powered by one circuit board. The Raspberry Pi is much smaller and slower than the average computer, but it can still do what a regular computer can. My example setup is shown in Figures 1-3.

Figure 1: Here is a close-up of what the Raspberry Pi’s plugs should look like. The pink/red is to connect the mouse, the black is for the speakers, the left white is the cable for power, and the right white cable connects to the screen.

Figure 2:  The black plug on the left is the DC adapter used to power the screen. The white HDMI plug is used to connect the Raspberry Pi to the screen.

Figure 3: The Raspberry Pi turned on, and the command line used to run ScheduleBot.


Set Up the Python Packages

Open a terminal window and install the following Python libraries:

  • keyboard [1]: enables you to access keypresses from the keyboard while code is executing.
  • pyttsx3 (Python Text-to-Speech X-Platform): a library that converts text given to it into speech in order for you to program your ScheduleBot to speak your event reminders.

Write the Code.

download (2).png
  1. Import the datetime, keyboard, pyttsx3, and time libraries.
  2. Write the function time1_less_than_eq_time2 to check if one time is before another so the program can compare times. The times will be compared by the event hour (before the colon) and the event minute (after the colon). For example, if one time is before or after another, the computer can know if an event is in the past or if the reminder time is after the event time.
  3. Make a Class [4] called Event. A Class is a data type that describes the data it has and what a programmer can do with it. Make sure this Class has event_name, event_time, event_date, event_reminder_date, and event_reminder_time.
  4. Write the function checkForReminders. This function will check for reminders to make sure if there are any reminders and when to execute them. You should use the function time1_less_eq_time2 because it will let you compare the current time and the reminder time so the computer can know whether or not to give out a reminder.
  5. In the main function, add code to create a new event when you press the letter “n”, and to print all events in chronological order when you press the letter “p”. Use the function sort_events to put the events in chronological order, and make a for loop to print each event in the list_of_events, one event at a time.

Figure 4: The program may not execute its time check at the precise reminder time, so the reminder should be executed when the current time is in the yellow region.

Customize Your ScheduleBot Code.

For example, I wanted to have a limit for the reminder time for it to be no more than a month before an event, and no events more than two years in the future, so I added these optional customizations.

Add Functions to Validate the Data.

Some functions make sure that the information is given in an expected way that meets all requirements. These functions are important because they help make the program run correctly, give you accurate reminders, and store your event data correctly. Write functions which check if eventIsInThePast, validMilitaryTime, validDate, and checkValidEvent which checks all of the previous criteria, plus any customizations you create, before adding the event to the program’s list.

Run the Code.

compiled images.png

Open the terminal on the Raspberry Pi and run your program using the command “sudo python scheduleBot.py”. Sudo [2] is used to let someone use code as the super user. This is important so that the program can use the computer speakers to tell us reminders, and check the keyboard for the ‘n’ and ‘p’ keys.

Demo

Figure 5: This is what the program will say when you insert an event.

Figure 6: When you press “p” on your keyboard, the events will appear in chronological order.

Figure 7: When you receive your reminder, it will appear on the screen like this and be spoken aloud from the computer speakers.


Conclusion/References

The ScheduleBot will help you remember your tasks and events. While making this robot, Python has done many spectacular things, such as being able to say words and being able to provide input using library functions. Unlike other calendars, the ScheduleBot will say the reminder you requested.Have fun with this coding DIY project!


References

[1] BoppreH. (n.d.). Keyboard: Hook and simulate keyboard events on Windows and Linux [Python; MacOS :: MacOS X, Microsoft :: Windows, Unix]. Retrieved July 18, 2021, from https://github.com/boppreh/keyboard

[2] Wallen, J. (2010, May 12). Linux 101: Introduction to sudo. Retrieved August 8, 2021, from https://www.linux.com/training-tutorials/linux-101-introduction-sudo/

[3] Raspberry Pi. (n.d.). Teach, Learn, and Make with Raspberry Pi. Retrieved August 8, 2021, from https://www.raspberrypi.org/

[4] Codecademy Introduction to Classes. (n.d.). Retrieved August 8, 2021, from https://www.codecademy.com/courses/learn-python-3/lessons/data-types/exercises/class

[5] Bhat, N. M. (2020, July 6). Pyttsx3 - Text-to-speech x-platform (Version 2.90) [Computer software]. Retrieved August 15, 2021, from https://pypi.org/project/pyttsx3/