WIFI & Bluetooth
Luckfox Lyra Pi is equipped with the AIC8800DC module, which supports the Wi-Fi AX protocol (Wi-Fi 6), 2.4GHz Wi-Fi, and Bluetooth 5.2/BLE. By default, the development board uses an external antenna.
1. Wi-Fi Testing
In wireless communication, Wi-Fi devices typically operate in two basic modes: AP (Access Point) mode and STA (Station) mode. In AP mode, the device acts as a wireless hotspot that other devices can connect to—similar to a home Wi-Fi router. In STA mode, the device connects to an existing wireless network as a Wi-Fi client, just like a phone or laptop connects to Wi-Fi.
1.1 Wi-Fi Connection (STA Mode)
Connect to Wi-Fi using the
wifi-connectscript:wifi-connect.sh Luckfox-2.4G luckfox12345Luckfox-2.4G:Name of the Wi-Fi networkluckfox12345:Wi-Fi password- Replace the SSID and password with your actual Wi-Fi credentials. No other changes are needed.
Obtain an IP address via DHCP:
udhcpc -i wlan0According to the above configuration method, the settings will be lost after reboot. Therefore, you need to create a startup script to reapply them.
nano /etc/init.d/S99wlan0#!/bin/sh
WIFI_SSID="Luckfox-2.4G"
WIFI_PASSWD="luckfox12345"
echo_log() {
echo "[wifi-autostart] $1"
}
wait_for_interface() {
for i in $(seq 1 5); do
if ip link show wlan0 > /dev/null 2>&1; then
return 0
fi
echo_log "Waiting for wlan0... ($i)"
sleep 2
done
return 1
}
case "$1" in
start)
echo_log "Checking wlan0 interface..."
if ! wait_for_interface; then
echo_log "wlan0 not found after retries, aborting."
exit 1
fi
echo_log "Connecting to WiFi: $WIFI_SSID"
if [ -x /usr/bin/wifi-connect.sh ]; then
/usr/bin/wifi-connect.sh "$WIFI_SSID" "$WIFI_PASSWD"
else
echo_log "wifi-connect.sh not found or not executable"
fi
echo_log "Requesting IP via udhcpc..."
udhcpc -i wlan0
echo_log "WiFi setup done."
;;
stop)
echo_log "Stop command received. No action defined."
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esacchmod +x /etc/init.d/S99wlan0
reboot
1.2 AP Mode
In embedded Linux systems, configuring the development board to work as a Wi-Fi hotspot (AP mode) mainly relies on hostapd and dnsmasq/udhcpd, which handle wireless network creation and client management respectively:
- hostapd: The core component responsible for creating the Wi-Fi network, defining SSID, encryption methods, etc., enabling the device to run in AP mo
- dnsmasq/udhcpd: Provides DHCP server functionality to automatically assign IP addresses to connected clients (e.g.,
192.168.4.x) and supports DNS resolution, eliminating the need for manual network configuration.
With hostapd handling signal broadcasting and dnsmasq/udhcpd handling IP assignment, you can build a fully functional Wi-Fi hotspot for wireless communication between devices.
Steps:
Open the
hostapdconfiguration file and modify the Wi-Fi name.vim /etc/hostapd.conf- Wi-Fi name (SSID):

- Wi-Fi password (
wpa_passphrase):
- Wi-Fi name (SSID):
Enable WPA encryption.
- Enable WPA2 encryption:

- Use PSK (Pre-Shared Key) authentication (common for home and small networks):

- Enable WPA2 encryption:
Run the hotspot:
hostapd /etc/hostapd.conf &- Result:

- Result:
Successful connection:

1.3 Wi-Fi Speed Test
On your PC or virtual machine:
iperf3 -s -i 10 -p 5001-s: Start in server mode-i: Report interval set to 10 seconds-p: Use port 5001
On the development board:
iperf3 -c 192.168.10.176 -p 5001 -f m -i 2 -t 24-c: Client mode, connecting to server IP 192.168.10.176-p: Use port 5001-f: Report format,m= Mbps-i: Report interval = 2 seconds-t: Duration = 24 seconds
2. Bluetooth Test
By default, the Wi-Fi and Bluetooth modules work cooperatively in BLE (Low Energy) mode. If you need to connect traditional Bluetooth devices (like speakers), you must manually switch the Bluetooth mode.
In the file
/usr/bin/wifibt-util.sh, comment out the following line:# Aicsemi AIC8800DC a69c:88dc aic8800_fdrv.koReboot the development board:
rebootStart Bluetooth:
root@luckfox:~# bluetoothctl
hci0 new_settings: powered bondable ssp br/edr le secure-conn
Agent registered
[CHG] Controller 38:54:39:03:10:70 Powered: yes
[CHG] Controller 38:54:39:03:10:70 Pairable: yes
[bluetooth]# power on # Power on Bluetooth
[bluetooth]# scan on # Scan for Bluetooth devices
[bluetooth]# trust 12:11:32:DE:A3:03 # Trust device
[bluetooth]# pair 12:11:32:DE:A3:03 # Pair device
[bluetooth]# connect 12:11:32:DE:A3:03 # Connect device
[M1]# exit