Raspberry startup tweet
27 Oct 2017Have a Raspberry send a tweet with its IP when it boots. This is incredibly useful when your Pi is headless with no monitor. There are tons of tutorials on this including one at instructables and another at opensource.
This is what you will get
triggercamera1 10.16.80.238 2016-10-20 18:04:40
— cudmore.io (@cudmore_io) October 20, 2016
Used to send email at boot but I can’t get the Pi to send email via gmail any more?
Create and configure a twitter app
Go to apps.twitter.com and make a twitter app. You will need a normal twitter account. Make sure you turn on read/write access. Once that is done, note down all the keys.
- Consumer Key (API key)
- Consumer Secret (API Secret)
- Access Token
- Access Token Secret
install tweepy (could also use twython)
pip install tweepy
Write a python script
Lets call it startup_tweeter.py
. See Github Gist below.
Make the python script run at boot
Make script executable
chmod u+x startup_tweeter.py
Edit crontab
sudo crontab -e
Add one line at the end of crontab
@reboot (sleep 10; python /home/pi/startup_tweeter.py)
Python script to tweet IP
This is taken from RasPi.tv