Hacker News new | ask | show | jobs
by fpgaminer 2765 days ago
I'm building a gift for someone else that uses a RasPi internally, and thus needed a user friendly way for them to configure its WiFi connection. It's been ... quite the adventure (mostly because I'm dumb).

My first idea was to put an OLED and a rotary encoder on the box. That way they can do a special dance on the button to enter setup mode, scroll through a list of wifi networks, and then tediously scroll through letters to enter the wifi password. I found a 1" OLED for cheap, and already needed a button for other things, so this was a cheap, effective solution.

But having to tediously type out a password with a knob sounded very user unfriendly.

Then I realized I could bring out a USB port, and they could plug in a USB keyboard! So I worked on that for bit. It's a lot easier to use. And the whole keyboard + tiny OLED idea was kinda fun.

But then I remembered the idea of doing a WiFi AP dance. That's where the device broadcasts as an AP, you connect with your phone, browse to a webpage to tell the device your Wifi network's info, and done! It's a solution that doesn't require an OLED or for me to bring out a USB connection. Cheaper and less mechanical engineering.

To that end I found Mozilla's IoT project which, conveniently, has RasPi compatible code for doing just that dance: https://github.com/mozilla-iot/gateway-wifi-setup (By the way, Mozilla's IoT project is neat and worth checking out).

That setup is quite similar to OP, except it doesn't require a separate app. Its downside is requiring the user to mess with the wifi settings on their phone. Not a huge deal (for my target audience) but can be annoying. (Hence why OP's project uses the Bluetooth connection; Smart!)

I've been tinkering with this on and off for about two weeks. While I wasn't thrilled with the solution, it was at least usable, cheap, and easy. ... then I realized I was dumb.

I have a camera on the device. I could just have them go to a website, punch in their wifi info, encode that as a QR code, and have them show it to the camera... (It'd be a secure website I set up, so no security hygiene problems). Same benefits of being cheap and easy, while being easier to use. Using `pyzbar` to do real-time QR detection I had something working within an hour. Just hold your phone in front of the camera and it'll automatically detect, decode, and setup the wifi settings.

The only downside to this approach is that I can't conveniently display a list of nearby wifi networks; so they have to type their SSID manually.

Figured I'd share my comedy of errors in case someone is looking for ideas for wifi setup solutions. Obviously if you're just setting up a RasPi yourself it's easier to just pop a wpa_supplicant.conf on the SD card. (Though I wish Raspbian also had a way to configure hostname, authorized_keys, and disable ssh password authentication through boot files. Only way to do that today is by mounting the root filesystem which isn't convenient on, e.g., a Mac)

2 comments

Raspbian defaults to being discoverable by bonjour so you can just `ssh pi@raspberrypi.local` and then modify the wifi config file (`/etc/network/interfaces`). You can script this bootstrap process pretty easily using Ansible etc. Downside is you do have to have a machine on the same ethernet network as the rpi for a short time. So fewer "cool project" points but ends up being quite simple.
Aside from the simpler method of dropping wpa_supplicant.conf in /boot as has already been said, mdns support in Android is terrible/non-existent. I've had no end of users struggling because of that, I 100% do not suggest relying on it.
>Raspbian defaults to being discoverable by bonjour so you can just `ssh pi@raspberrypi.local` and then modify the wifi config file

Why would you do that when you can just drop a wpa_supplicant.conf on /boot?

I wrote this to configure my Raspberry and connect to WiFi right after burning an OS: https://github.com/afdezl/rpi-headless