Show HN: ESP32 Autoswitcher for Bad Campus WiFi
When looking for a networking-related problem to solve for my internetworking university course, I realized a major pain point for us specifically at our university – the WiFi sucks. Specifically, there are three available WiFi networks around campus, eduroam, UMB-Guest, and Event-Guest. They don’t usually suck at the same time, but all of them periodically become very slow.
This means that you, the user, have to take a break from whatever internet-dependent work you’re doing for a second and manually switch to one of the other options. I was thinking, "Why can't a laptop test all of the networks it's own?" And then I found this Python script on Reddit that automatically switches to the available known network with the strongest WiFi signal, all in the background using NetworkManager.
Problem solved, right? Well, not exactly. It only switches based on signal strength and physical data rate – not WiFi throughput1. Especially given the fact that many, many people are connected to these campus networks at any given time, WiFi signal strength alone is probably not a good indicator of the upload and download speeds you’ll get when you’re actually on the network.
The constraint here is that to measure a network’s internet throughput, you need to be actively connected to it, and use something like speedtest.net to see how fast your end-to-end data transfer rates are. Since laptops only have one network card and network cards can only connect to one network at a time, you can’t live test the internet speed of other networks without disconnecting from your current one.
Introducing the ESP32 Autoswitcher
The ESP32 comes in! The laptop will send over the list of available known networks while running, and the ESP32 will keep a map of each available network and its current speed. It will keep switching between the available networks and re-testing them, updating the map until a new fastest is found – at which point it will send a message and alert the host PC.
The host PC will then switch to the new fastest network, all without the user doing anything manually. We had a clear plan for our solution and spent a few hours hacking away at this thing until we eventually had a working version, which totalled in around 300 lines of C++/Arduino and Python.
The Prototype
The main test case was to connect to one of my university WiFi networks and then turn on my hotspot, which is faster than any of the university networks, at least during the afternoon. Without fail, the ESP32 would iterate through the available networks, see that my hotspot was the new fastest known network, tell the laptop to connect to it, and it would connect automatically.
Although we have a working prototype, there is still a laundry list of things that we could add to this device including:
Here are some key points about the ESP32 Autoswitcher:
* The ESP32 Autoswitcher is a solution for the problem of slow and unreliable WiFi networks on campus. * It uses an ESP32 as a second network card, dedicated to live-testing the WiFi throughput speed of available known networks. * It can automatically switch between available networks based on real-time internet speed measurements. * The host PC is alerted when a faster network is found, allowing it to connect to the new fastest network without manual intervention.
You can check out the project and give us a star on GitHub if you're interested in trying it out or contributing.