A common complaint from Raspberry Pi owners is when running headless (no monitor or keyboard). If the Pi reboots then you lose your login session and often the previous IP address.
Using a something.local hostname sometimes works, but knowing the IP address is often more useful.
Here is a quick Python script to add to your rc.local file so it emails you on bootup.
Code
In this script I am using the Mailgun API so the message is less likely to end up in spam. You get a ton of free emails with Mailgun so it will not cost you a penny.
Add a text file containing your API key to your directory and call it mailgun-api.txt - that way you don't need to store the key in your script.
import subprocess
import requests
# load API key from file
inFile = open('/home/pi/mailgun-api.txt', 'r')
api_key = inFile.readline().rstrip()
inFile.close()
# get host and IP
this_host = subprocess.check_output("hostname", shell=True).rstrip()
IP_line = subprocess.check_output("hostname -I", shell=True).rstrip()
# send via Mailgun
def send_message():
return requests.post(
"https://api.mailgun.net/v3/YOURHOST.mailgun.org/messages",
auth=("api", api_key),
data={"from": "Bot <pibot@YOURHOST.mailgun.org>",
"to": ["your@emails.com"],
"subject": "MY IP: " + IP_line,
"text": this_host + " = host and " + IP_line + " is my IP!"})
print send_message()
At first i thought it was a devil fruit. Hahahaha it seems like i have watch to many one piece article. :D
Great little tip.
My Uni team won a total of 10 Raspberry Pi Zero starter kits in a coding competition in December, and just got news I was selected to get one of them, so this is sure to come in handy when I play around with it !
My dad got himself some Onions to test out IOTA's wallets and set up a micro-temperature/humidity data collection station in Andorra. so it's becoming a family thing to play with XD
That's a great prize :)
I have an onion omega (might have two, they were kickstarters) but haven't really tried it out yet :)
They're interesting, though it's best if you have an ethernet module for them.
Their in-built wifi capability is rubbish, often not able to find and/or connect to any networks even if the box is right next to them X/
But otherwise, the modularity of the system is pretty interesting.
Kind of like my iPhone ;)
I haven't had an issue with the wifi on mine (I use pi2, pi3 and pi zerow for octoprint) but yeah if you need reliable connection or good throughput wired is best.
I was talking about the Onion.
Those ones are pure torture XD
I'm currently a bit bummed out. My Mac book has begun making severe noises when I attempt a startup.
I think it's permanently dead now...
I'm back to using Mr. Emergency. An old X60 tablet-computer hybrid with a bit of a screen defect where I have to apply pressure to part of the screen to see anything else than static 😕
Alternately, and perhaps more flexibly, you can go into your router's configuration and set the DHCP allocation to always give the MAC address on the Raspberry Pi the same IP. This will keep it from moving around if you're regularly reimaging the Pi or don't want to edit startup files.
yep, good point
You got a 2.62% upvote from @postpromoter courtesy of @makerhacks!
Want to promote your posts too? Check out the Steem Bot Tracker website for more info. If you would like to support the development of @postpromoter and the bot tracker please vote for @yabapmatt for witness!
You got a 34.48% upvote from @ipromote courtesy of @makerhacks!
If you believe this post is spam or abuse, please report it to our Discord #abuse channel.
If you want to support our Curation Digest or our Spam & Abuse prevention efforts, please vote @themarkymark as witness.
You got a 1.74% upvote from @buildawhale courtesy of @makerhacks!
If you believe this post is spam or abuse, please report it to our Discord #abuse channel.
If you want to support our Curation Digest or our Spam & Abuse prevention efforts, please vote @themarkymark as witness.
You got a 8.67% upvote from @upmyvote courtesy of @makerhacks!
If you believe this post is spam or abuse, please report it to our Discord #abuse channel.
If you want to support our Curation Digest or our Spam & Abuse prevention efforts, please vote @themarkymark as witness.
Congratulations! This post has been upvoted by SteemMakers. We are a community based project that aims to support makers and DIYers on the blockchain in every way possible. Find out more about us on our website: www.steemmakers.com.
If you like our work, please consider upvoting this comment to support the growth of our community. Thank you.