THE INTERNET IS DOWN!!
How many of you “home IT support technicians” have heard this before? I hear it a lot, so I decided to create a device that would notify me visually when problems occur. Sometimes it winds up being a flaky wifi router that either reboots or just needs to take a breath. Other times, it’s our Comcast connection in which case I can’t do anything other than call and file an outage. The kids seem to have a hard time with understanding that even though I’ve explained it to them a hundred times.
A little background on the reason for this project. At the company I work for, we employ a WAN load balancer which uses a series of pings to major internet presences such as google, AT&T or OpenDNS servers. Basically the device pings each of those addresses once per second and based on specific criteria, can determine if one of the two internet connections is down and can take appropriate action.
This is what made me decide to develop my version of the ping meter. There are a number of projects like this for the raspberry pi that involve some sort of visual representation. I wanted to put together a project that incorporated both the raspberry pi, an arduino board and the NeoPixel ring. This was mainly a project for me to learn how to integrate multiple devices. Honestly I could probably have done this without the Arduino but I wanted to challenge myself a little.
At this point, I have the device working the way I want. My next challenge is to package the device into something more aesthetically pleasing. WAF (Wife Acceptance Factor) is an important aspect to any geek project like this if it’s gonna be displayed somewhere that’s visible. I’m thinking maybe a small picture frame or maybe some sort of glass object that looks nice.
Here is a list of the parts you’ll need:
- Raspberry Pi (any model should work)
- Arduino board (I used an UNO but even that is overkill)
- NeoPixel LED ring (12 LED segments)
- Micro SD card (at least 4gb)
- USB Type A to USB type B (printer/scanner cable)
- 5V Micro USB power source (iPad charging brick is perfect)
I haven’t tested using a Pi Zero yet but I don’t see why it wouldn’t work. I also have an Arduino Trinket (5v version) that I’m trying to use for this however out of the box it doesn’t support serial communication. For size reasons, this combination would be perfect for just about any implementation where room is an issue. You could just as easily use a larger NeoPixel ring or even a strip with some very minor code modifications.
There are two programs that are used to make this system work. One is the “firmware” that you load onto the Arduino board itself. The other is the python script that runs on the Pi. Basically I use the Pi to ping 3 different IP addresses, and use the NeoPixel ring to display the average ping latency in LED segments. If I can’t ping all three then I start to progressively change the color of the LED’s from green to red. Throughout this project I learned a lot about programming in python, Arduino and interacting with external physical devices. I first started by just getting the LED’s to turn on and off. I borrowed a lot of code from examples and implemented the same routines to get the NeoPixel to do what I wanted to.
I tried to sprinkle comments throughout the code to explain what I’m doing and why. Most of these were added after I made a breakthrough in something that was kicking my ass for awhile so I would know how to fix the problem the next time around. I won’t focus a lot on how to install the OS on your Pi or how to download code to the Arduino- there are a LOT of helpful resources on the internet that can walk you through it. Also, in the spirit of this being a learning exercise for me- I think it’s valuable for someone starting out fresh to do the research and have a basic understanding of what’s going on rather than just copying and pasting code. If you’re trying to put this together and run into problems, feel free to comment on the article and I’ll do my best to answer questions.
In the next article, I’ll show you the code and how it all works. Stay tuned!