Ever since I was 12 years old, I've loved Harry Potter and the world that J.K. Rowling built with her books. I always loved that Rowling tied the wizarding world into the real world. I wanted to try and bring a piece of that world in to my own, the Weasley family’s magical clock, which led us to starting this project.
For all the muggles (non-magic humans) out there, the Weasley clock is a unique magical artifact which doesn't tell the time. Instead it tells the location of the family members so that the boss-master at home, Mrs. Weasley, can stop worrying about her family and know when to start setting up dinner.
*For the paranoid/privacy concerned among us, don't worry, this project doesn't track exactly where you are, just if you're in a particular region.
TL;DR: This project checks your Android phone's location and compares it against preset thresholds to see which "zone" you are in and represents the same using a pointer on a clock face using the Bolt IoT.
Put the Adafruit Motor Shield on the Arduino (be careful to match the pins, please don't blow anything up, please..don't). Plug your Hobby Servo motor into the Servo headers on the shield.
The SERVO_2 slot of Motor Shield connects the servo's signal to pin 9 on the Arduino. Black (GND or - ), Red (VCC or +), Yellow (Signal) is the pinout to be followed. Also, be sure to use an external power source like a 9V or a Lithium Ion/Polymer battery to source the current for driving the Servo motor. It might work via USB as well. But you don't want to draw excess current or worse damage your USB port, so do use a battery.
Fritzing part for the Servo courtesy Adafruit.
Lastly, connect the Bolt Wi-Fi module with the Motor shield mounted on top of an Arduino Uno.
- Bolt <------> Arduino
- TX -------> RX
- RX <-------- TX
- GND <----> GND
Login to cloud.boltiot.com and note the ID of your Bolt WiFi Module. Now click on the API Tab and under the section for Generate Key, click on Enable.
Next click on the copy button to copy your API key. Your API key will may look something like this:
From your Android device you need to make an HTTPS request to the Bolt cloud server with your Bolt device ID and your API key in order to send the command data to the clock according to the location.
So, every time your location changes, your device should request the Bolt cloud with the new location zone value. You can use AssyncTask to do this as shown in the snippet.
You can get location of the device by using android.Location package like:
But it will only give you longitude and latitude of the location. So, You need to convert it in distance. You can follow this function:
The entire code is available on GitHub under: https://github.com/Deepanshu625/Location_Alert
The location alert in the app will look something like:
We used the Adafruit Motor Shield and their library to test the motor shield and the Arduino Servo library to control the 180 deg Hobby Servo we had lying around. In order to link the Bolt Wi-Fi module to the Arduino using UART, we used our in-house Bolt-Arduino-helper library. Check out the Interfacing Controllers section of the Bolt IoT Docs.
Connect the Arduino Uno with your Bolt Wi-Fi device as explained in the hardware setup and flash this sketch.
*N00b Trap* Be sure to disconnect the Bolt module while programming the Arduino Uno as it uses the same TX/RX pins to talk to your PC.