Adding WiFi Connections to Kolibri RPi

Installing the Kolibri RPi image is an easy way to get going with a micro server, however the internal WiFi on an RPi4 will only support around 7 concurrent connections. We wanted to be able to support a classroom of around 30 students.

One approach is to add a separate WiFi Access Point and network it with the RPi, and this works quite well but obviously requires a second device and networking set up.

For a simpler approach we looked at using USB WiFi adapters as a way to add more concurrent WiFi connections to a standalone RPi device.

USB WiFi adapters have a somewhat chequered reputation when used in AP mode, but by selecting the right devices we found that it is quite easy to add one or two additional WiFi devices, each of which is capable of handling up to 30+ concurrent connections.
Note that some devices are programmed to support a limited number of connections (eg AR9271 will support 8 connections).
Also in the hostapd config file you will see a line ‘max_num_sta=35’ that will set a limit to the number of concurrent connections. Setting this limit will prevent the device from accepting unlimited connections until it is overloaded and becomes unstable.

The USB devices that are known to work well are based on these chipsets:
RTL5370 / RT2870 / RT3070 / R5572 / AR9271

These are all older chipsets which typically offer ‘150Mbps’ operation on the 2.4GHz band.
In practice they will deliver around 50Mbps throughput, so not blazingly fast, but adequate for classroom use if the server is set up correctly.

The RPi software includes drivers for the devices mentioned above, so they will be recognised immediately when added to the RPi.

There may also be other chipsets that work, but please be aware that many USB WiFi dongles will not work, either because the implementation is designed for WiFi Client operation, and/or because the drivers have not been included by default with the RPi software (RPi OS or Kolibri RPi image).

The internal WiFi will appear as ‘wlan0’.
Adding one or two suitable USB WiFi adapters will create new interfaces called ‘wlan1’ and wlan2’. The output of the ‘iw dev’ command on a configured system with two additional USB WiFi adapters will look something like this:

$ iw dev
phy#2
	Interface wlan2
		ifindex 5
		wdev 0x200000001
		addr ac:a2:13:12:34:56
		ssid kolibri-2
		type AP
		channel 11 (2462 MHz), width: 20 MHz (no HT), center1: 2462 MHz
		txpower 36.00 dBm
phy#1
	Interface wlan1
		ifindex 4
		wdev 0x100000001
		addr 7c:dd:90:34:56:78
		ssid kolibri-1
		type AP
		channel 11 (2462 MHz), width: 20 MHz (no HT), center1: 2462 MHz
		txpower 36.00 dBm
phy#0
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr e4:5f:01:56:78:90
		ssid kolibri-0
		type AP
		channel 36 (5180 MHz), width: 20 MHz, center1: 5180 MHz
		txpower 31.00 dBm

To get the additional WiFi interfaces running requires creation / modifications to the following files:

  /etc/dhcpcd.conf
  /etc/hostapd/wlan1.conf,  wlan2.conf
  /etc/dnsmasq.conf

In addition, the new interfaces have to enabled with the following commands:

  $ sudo systemctl enable hostapd@wlan1
  $ sudo systemctl enable hostapd@wlan2


After modifying the config files and enabling the interfaces, restart the RPi and the new interfaces should be operating.

Client devices can then connect to one or other of the APs in the normal manner and access the Kolibri system at the usual IP address.

Enjoy!


--------------------------------------------------------------------
The config file modifications are as follows:


> 1.  /etc/dhcpcd.conf
> -------------------------
> 
> # BEGIN ANSIBLE MANAGED BLOCK
> # WiFi Interface
> interface wlan0
>     static ip_address=10.10.10.10/24
>     nohook resolv.conf, wpa_supplicant
> 
> interface wlan1
>     static ip_address=10.10.20.10/24
>     nohook resolv.conf, wpa_supplicant
> 
> interface wlan2
>     static ip_address=10.10.30.10/24
>     nohook resolv.conf, wpa_supplicant
>     
> # END ANSIBLE MANAGED BLOCK
> ------------------------------------------------------
> 
> 2.  /etc/dnsmasq.conf
> ----------------------------
> #RPiHotspot config
> interface=wlan0
>   domain-needed
>   bogus-priv
>   dhcp-range=10.10.10.100,10.10.10.200,255.255.255.0,12h
>   # Gateway + DNS server
>   dhcp-option=3,10.10.10.10
>   dhcp-option=6,10.10.10.10
> 
> interface=wlan1
>   domain-needed
>   bogus-priv
>   dhcp-range=10.10.20.100,10.10.20.200,255.255.255.0,12h
>   # Gateway + DNS server
>   dhcp-option=3,10.10.20.10
>   dhcp-option=6,10.10.20.10
> 
> interface=wlan2
>   domain-needed
>   bogus-priv
>   dhcp-range=10.10.30.100,10.10.30.200,255.255.255.0,12h
>   # Gateway + DNS server
>   dhcp-option=3,10.10.30.10
>   dhcp-option=6,10.10.30.10
>   
> ---------------------------------------------------------------------
> 
> 3.  /etc/hostapd/wlan1.conf
> 
> interface=wlan1
> driver=nl80211
> ssid=kolibri-1
> hw_mode=g
> channel=11
> wmm_enabled=0
> macaddr_acl=0
> auth_algs=1
> ignore_broadcast_ssid=0
> wpa=2
> wpa_passphrase=password
> wpa_key_mgmt=WPA-PSK
> rsn_pairwise=CCMP
> country_code=AU
> max_num_sta=35
> -----------------------------------------------
> 
> 4.  /etc/hostapd/wlan2.conf
> ------------------------------------
> interface=wlan2
> driver=nl80211
> ssid=kolibri-2
> hw_mode=g
> channel=6
> wmm_enabled=0
> macaddr_acl=0
> auth_algs=1
> ignore_broadcast_ssid=0
> wpa=2
> wpa_passphrase=password
> wpa_key_mgmt=WPA-PSK
> rsn_pairwise=CCMP
> country_code=AU
> max_num_sta=35
> 
> ----------------------------------------------------------------------
> ```

I just use old but good routers, it hasn’t presented any serious issues yet!

I agree it is a good use for re-purposed routers.

In our case we needed a simple “one box” solution to deploy to remote sites via snail mail.
Plugging in a USB WiFi Adapter that allows all the students to connect works well in this situation.