Entries tagged 'IoT'
Using a Raspberry Pi as a WiFi Hotspot
The wireless router/gateway from our internet provider (Verizon 5G Home) works okay for most things, but it only supports “band steering” aka using the same SSID (wireless network name) for the 2.4 GHz and 5 GHz bands. I’m still using some older Wyze smart plugs that only support 2.4 GHz and for whatever reason they seem to be flaky in such a setup.
I’m running HomeBridge on a Raspberry Pi 4 to bridge between these Wyze devices and HomeKit because we’re an Apple-heavy household. The Pi is connected via ethernet to our internet gateway, so that leaves its WiFi capabilities free to create another bridge. It doesn’t have a keyboard or monitor, so I did all the setup via ssh
.
The first thing to do is to make sure that the WiFi is configured to the correct country so it uses the appropriate channels. You can do this with the raspi-config
program by setting the appropriate value in “Localisation Options” → “WLAN Country.”
$ sudo raspi-config
For the rest, we’re going to use the nmcli
utility which is the command-line interface for the NetworkManager system. I haven’t poked around under the hood much, but the configuration ultimately lives in files under /etc/NetworkManager
.
The first thing we do is create what NetworkManager calls a connection which we’ll use with the WiFi interface, wlan0
.
$ sudo nmcli con add con-name hotspot ifname wlan0 type wifi ssid "Idiot"
This creates a WiFi network named “Idiot,” which is short in my case for “Imperial Dog Internet of Things.” You can name yours whatever you want. That name hotspot
in there could be something else, too, you’ll just need to make sure to change further references to hotspot
below.
You’ll want to secure your WiFi network with a password, so there’s a couple of commands for that:
$ sudo nmcli con modify hotspot wifi-sec.key-mgmt wpa-psk
$ sudo nmcli con modify hotspot wifi-sec.psk 'This is where the password goes'
The first command says we’re going to use a key, and the second configures the password. Substitute your own.
Finally, we need to set the mode on the connection and tell it that we just want to share the Pi’s connection.
$ sudo nmcli con modify hotspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
By only enabling the “bg” band we’re restricting this network to the 2.4 GHz range, which is what I hopes makes the plug(s) happier.
After this, I was just able to reset the smart plug to use the new “Idiot” network and it seems to have been stable for a couple of days.
It is kind of a Rube Goldberg situation where I say “Hey Siri, turn on my desk lamp” and it is sending out that speech to be processed by Apple, deciding what to do, the device that heard it telling the Pi what I wanted, the Pi going out to the Wyze server to tell it what to do, and somehow my smart plug getting notified what to do. It does take a second or two.
(These steps are just a distillation of what is in this article but without a browser-choking number of ads and popups.)