Science Fair 2016

For my science fair, it became time to choose a project as the deadline loomed closer. Because I am a big fan of Harry Potter, I chose to recreate the Weasley’s Clock. My father and I will use Raspberry Pi to complete the project. The coding for the project is at the bottom, and a step by step process on how it was created. All words or phrases with hyperlinks connect to websites explaining the definition of said phrase or term. 

September 18, 2016:

Today we opened our Raspberry Pi package. It came with the computer, an HDMI Cable, and a Micro SD chip, with 32 gigabytes of storage. The first thing we did was set up the Raspberry Pi. We plugged the HDMI cable to the screen, and the Raspberry. Then we inserted the Micro SD card, and two USB ports connecting to my keyboard and mouse.

After that, we connected the Raspberry Pi to the monitor we will be using. After that, we set up Raspbian, the operating system for Raspberry Pi. Once that was finished, we set up local time and Wi-Fi. Once the computer was set up, we started downloading the applications we will need to complete the project. We realized we couldn’t download the applications without updating the computer, so we updated the Raspberry Pi. After that, we downloaded Mosquitto to Raspberry Pi. After the download was complete, we downloaded a MySQL Server, that was attached to Python. The MySQL server ended up unused. Once that download was complete, my father found the coordinates for the two locations we are using – home and school. We found the location of my middle school, but not my sister’s elementary school; my sister will act as the second person on the clock. At the end, we downloaded an MQTT Broker.

Computer Terms:

  • MySQL

    • SQL stands for Structured Query Language
    • Used to store tables
    • Data storage application
  • MQTT Broker

    • MQTT stands for Message Queuing Telemetry Transport
    • Sends messages inside the computer to other functions
  • Mosquitto

    • An application that implements MQTT protocol.

September 21, 2016:

Today my we set up OwnTracks. We downloaded the app on our phone and registered a server, which we then connected to Raspberry Pi. I then opened the program Geany on the Raspberry Pi and used it to print the information coming from the server, from both phones. This took us a long time because we could not figure out how to print it until our server was set up, and to set up the server, we had to change our computer from dynamic to static, so we added our own server and Broadcast Mask. Then, we were able to connect the phone to the server. A static server is
given its range of coordinates manually, and it was needed since the Raspberry Pi is automatically dynamic, and with dynamic, outside information can’t be reached.

September 26, 2016:

Today I was told to start using Python to set up the coding with which the distance from home will be calculated. I made the code on Python and emailed it to myself to copy paste into Geany.  It involved turning my coordinates into Radians and plugging that into the distance formula. The distance formula involved sine and cosine, so trigonometry was needed. We used to locations to determine the distance and radius- School and home. We found the location coordinates using Google Maps, and we plugged them into the program. I  also changed the program I made so the coordinates came from OwnTracks. The program involved the radius of Earth and some programming that will print my location. I used the following links to get my program working:

October 22, 2016:

For the past few weeks, I have been working on developing my distance formula to make it more accessible and I started working on the GUI Display today. I will develop my GUI in Python. I will import Tkinter to make my project easier. Tkinter is a GUI module. My display will include a clock face with icons for the two members of the family, and the icons will move depending on the location. I also changed the clock idea, so that the Tkinter will be used for the GUI programming. A canvas was made, and a clock using kwargs. The canvas is 800 by 800. I also combined the program to get the coordinates from the OwnTracks server and the program for the distance formula. The programs were changed up so they worked in synchronization.

November 5, 2016:

I found that when combining the GUI interface on Tkinter and the OwnTracks information, two separate loops must run at the same time, but once one loop starts, the other loop won’t until the first loop has ended. Combining the GUI caused 2 loops to run at once, with the GUI loop updating depending on the location from the distance OwnTracks loop. Therefore, we experimented with multi looping. We found that the MQTT server we used did not allow for multi looping, so I consulted one of my father’s friends, and he told us about a server that allows for multithreading. It is called mtTkinter. Multithreading is the process of combining two loops to run in parallel. Once I substituted Tkinter for mtTkinter, the program worked flawlessly. My dad and I spent the whole weekend working on running the two codes simultaneously. Eventually, we figured it out and got the program to work. I finished my coding. 

The top few lines are installments required for this program. Mqttclient.connect is the number for the OwnTracks server. Many of these lines are comments telling users about this program and are written with hashtags to show that they are comments. After that, it was a matter of adding text to the proper coordinates and changing the color of the circle’s quadrants.

November 11, 2016:

Once this was done, we sought to improve the program, allow it to run without our Wi-Fi, and without Wi-Fi. We went to a friend of my dad’s. He told us to go to Amazon AWS or Amazon Web Services. Once on this program, we found that it had its own IP address that could be accessed from all places because Amazon is international. My dad’s friend helped us switch the IP address to the AWS address. Before we did this, however, we downloaded Ubuntu and Mosquitto onto the AWS. Ubuntu is an open source cloud platform, on which information can be streamed. We tested this by walking until Wi-Fi was gone, then sending a message. True to the program, the message sent and flashed unknown. In the coding, our locations can be changed, along with the coordinates, and the server to fit another’s own needs.

November 12, 2016:

Today my dad and I decided to improve the program. We added another user, my father. We also added an Epoch Timestamp, to keep track of time. After, we checked the program and fixed a few bugs. Most of this program can be changed to suit other users needs if the code is examined properly. Our original plan for the program involved two users and four locations. We also wanted four locations on a white clock, with the picture of the user moving. Instead, the text was made for the user, and the clock was split into four quadrants.

November 13, 2016:

The original AWS IP address was on my dad’s friends account because we did not have enough time to set his new account up. Today, we set up an account and changed the IP address.

Creation of Code:

To start this code, JSON, math, MQTT client, and mtTkinter must be imported. These are packages on the Raspberry Pi, but due to the numerous amounts of packages, the coding must be written to show which packages are used. These importations are at the top of the coding. Then, the coordinates of the locations you wish to use must be found, and the app OwnTracks downloaded onto the phones of the users a user wishes to use. Once this is done, information must be programmed to come from the OwnTracks server and print on the computer being used. The coordinates for the locations can be changed. Next, a clock must be created, with users, and locations. After that is done, the distance from the coordinates to the location must be calculated, and the program should decide where the user is, based on the radius around said locations. The rest of the coding is then simple, and easily accessible. It can be found on my github here.

References:

  • “Weasley Clock.” Instructables.com. N.p., 14 Dec. 2014. Web. 19 Oct. 2016
  • Bell, Amanda. “The Weasley Clock Is A Harry Potter DIY-ers Dream.” News. N.p., 17 Sept. 2015. Web. 19 Oct. 2016. <http://www.mtv.com/news/2273579/weasley-family-clock/>.
  • Muoio, Danielle. “A 21-year-old Built a Working Replica of the Weasley Clock from ‘Harry Potter’ and It’s Amazing.” Business Insider. Business Insider, Inc, 17 Feb. 2016. Web. 19 Oct. 2016.
  • Chester, Tim. “Crafty ‘Harry Potter’ Fan Makes Genius Digital Version of the Weasley Family’s Clock.” Mashable. N.p., 15 Feb. 2016. Web. 19 Oct. 2016.
  • “Alzheimer’s Disease & Dementia | Alzheimer’s Association.” Alzheimer’s Disease & Dementia | Alzheimer’s Association. N.p., n.d. Web. 19 Oct. 2016.
  • com. “Python Time Clock() Method.”Www.tutorialspoint.com. N.p., n.d. Web. 22 Oct. 2016.
  • com. “Python GUI Programming (Tkinter).”Www.tutorialspoint.com. N.p., n.d. Web. 22 Oct. 2016
  • By Posting Your Answer, You Agree to the Privacy Policy and Terms of Service. “Draw Circle in Tkinter (Python).”- Stack Overflow. N.p., n.d. Web. 22 Oct. 2016

Pictures:

IMG_20161104_182538 (1).jpg
IMG_20161112_101303.jpg

Comments

Leave a comment