The Electronics & Code
Apologies for those that have been waiting for this part…this web page went live a little earlier than i expected.
So…The Raspberry PI Zero is housed inside the completed model in the base. I used some Velcro tape to attach it to the model. A little cut out for the USB power lead can help not topple the model and using one of those soft silicone leads can stop the wire lifting the model.
Next we wire the simple circuit from the PI to the LED i joined 2 jumper cables together to achieve the distance from the PI to the LED which is about 300mm (in the small version of the model) *Edit please use a resistor to prevent LED burn out…i soldered one inline but you can get LEDs with built in resistors
I used a dob of hot glue to attach the LED to the base of the antenna arms and then slid the jumper connectors onto the legs of the LED.
The threading of the wires through the antenna arms i found a little tricky but this was because of the connectors in the jumper cables so i recommend you use the correct length of wire to simplify the routing.
The software consists of downloading the python code from the github i then had this run on a crontab so the code will run on boot. Crontabs are another subject but i quickly learned all i needed from here
Register Your Twitter App
Details taken from https://learn.sparkfun.com/tutorials/raspberry-pi-twitter-monitor
In order for the code to interact with your Twitter account, you will need to register your application. This is accomplished by going to https://dev.twitter.com/.
Click the “Sign In” button at the top-right of the screen and enter your Twitter credentials (you can also sign up if you don’t have a Twitter account).
Once you have signed in, click on your user icon, and select “My Applications.”
Picture from https://learn.sparkfun.com/tutorials/raspberry-pi-twitter-monitor
Click the “Create a new application” button, and you will be presented with a form to fill out about your application. Fill out the name and description fields. For “Website,” you can put something random, like http://github.com or something else that looks legitimate. At the bottom of the page, click the checkbox to agree to the rules, fill out the Captcha, and click the “Create your Twitter application” button.
Once completed, you will be presented with a dashboard for your registered application. You need to create an access token, so click the “Create my access token” button at the bottom of the screen.
Wait a few seconds and then refresh the page. You should see a section titled “Your access token” at the bottom. Copy down the “Consumer key,” “Consumer secret,” “Access token,” and “Access token secret.” We will need these for our application. Note that we set up this Twitter application as an example. It will have been deleted by the time you read this, so don’t be trying to use our tokens!
Now you need to edit the code on your PI at line 22 to include your twitter keys.
We will now create the IFTTT applet that will post a tweet to your account when the ISS is over the lat&lon you specify. When the tweet is posted with the user specified #hashtag such as #ISSovermyhouse the code running on the PI will pick this up and flash the LED..
- Head over to IFTTT and create a new account.
- Create a new Applet click the + sign as above (i didn’t find that obvious if your listening IFTTT)
- Search for ‘Space’ in the search bar and click the below applet.
- Select your location by moving the black pin on the map to where you you want the alert to trigger.
- Now we create the ‘That’ part of If This Then That. So if The ISS flys over your location ‘Then’ do ‘That’ which is post a tweet to your account.
- Select ‘Post a Tweet’ service.
- Now you need to edit the python code on the PI on line 6 where it says TERM=’ISSOverhead’ this is the hashtag that the PI is going to search Twitter for 24/7. I was amazed how quick the PI picked up the hashtag when it was posted literally instantly.
- Now add that hashtag to the end of the applet details as below.
- Thats it…make sure the applet is on as below and as long as the code is running on the PI when the ISS passes overhead the applet will run on IFTTT tweet your hashtag and light up Arthur…To test it you can post any tweet with the hashtag and it should light up. Thats what i love about this project is that it opens up your imagination to the internet of things and causing physical actions in the real world that dont require you to look at a screen!.
I would like to thank Sparkfun for their tutorial https://learn.sparkfun.com/tutorials/raspberry-pi-twitter-monitor which inspired me to create this.
I would also love to create a V2 that plays the audio snippet in the github using https://shop.pimoroni.com/products/speaker-phat. Ive bought the speaker but haven’t had the time recently to write the code.
Follow me at https://twitter.com/ginandtronics