I got the idea for this project from a tutorial article in The MagPi written by Simon Monk. When it comes to interfacing electronics with the real world I usually use an Arduino and despite owning Raspberry Pis for years, I had never gotten around to using the GPIO pins. But once I discovered that you can integrate terminal commands into projects amongst other things that come with a full Linux environment, I found a great deal of potential in using a Pi for these projects.
So what this project does is, it regularly pings a specified server (like google.com) and will display the ping time if there is a connection or let you know that your Internet is down if there is none. My tweak on Simon Monk’s project is that instead of using a servo to display the ping time, I use a 16×2 LCD Screen. Not only can it show more information than a servo but it also doesn’t make any noise as opposed to quite a noisy servo. You can plug your Pi into your router over an Ethernet cable and have it working away in the background giving a fairly conclusive reading of whether the Internet is actually down, or if your phone is just acting up!
I have included the code in a Github repo linked above. To get the LCD working I used a library supplied by Adafruit which is also attached.
The wiring diagram for an LCD is as shown below as also as also supplied by Adafruit:
The lcdPingometer.py file is as follows:
When this setup is up and running, it should either display the ping time, refreshing every few seconds, or show that there is no connection when that occurs. Its nothing too exciting but it was just something to get me started with using a Raspberry Pi for creating real world projects.
I was thinking of add ons that you could bring to this and one intriguing one came to mind. You could add a light to the Pi, and have the Pi constantly ping the IP of your phone when you’re on the home WiFi. When there is a connection (phone connected to wifi => you are in the house), the light will be triggered to turn on and when the connection is lost (you have left the house), the light will turn on. Its something to think about.
I have been tinkering with LED strip lights and connecting the to the internet so I will be writing about my discoveries there soon.
So that is my first project on the blog, thanks a million for reading, please let me know if you have anything to add!
Any feedback is appreciated and thank you very much to Simon Monk for the inspiration.