🛠 Basculer le Wi-Fi du CM4 sur l'antenne externe U.FL (dtparam=ant2)
Objectives
The wireless module of the CM4 (Cypress/Infineon CYW43455, dual-band Wi-Fi 802.11ac + Bluetooth 5.0) features two antennas and an electronic switch: the onboard PCB antenna (ant1) and a U.FL connector for an external antenna (ant2). This tutorial shows how to force the use of the external antenna — essential when the module is enclosed in a metal case — and explains that the antenna selection is fixed at boot time, not at runtime.
Hardware
- 1 × CM4 with wireless enabled (digit x=1 in the order code, e.g., CM4104032)
- 1 × CM4 IO Board + the official Antenna Kit (U.FL antenna) or a third-party antenna
- Manufacturer rule: the onboard antenna must not be surrounded by metal, including ground planes — otherwise, an external antenna is mandatory
- Power the IO Board, ensure the display or SSH is already working
Complete code
# 1. Sélectionner l'antenne externe (choix figé au boot)
echo 'dtparam=ant2' | sudo tee -a /boot/firmware/config.txt
sudo reboot
# 2. Après redémarrage : vérifier l'interface et le scan
ip -br link show wlan0
iw dev wlan0 scan | grep -E 'SSID|signal' | head -n 10
iw reg get | head -n 5 # vérifie le pays configuré
# 3. Mesurer la qualité du lien avant/après (même AP)
iw dev wlan0 link | grep -E 'Signal|tx bitrate'
# 4. (Optionnel) désactiver le Bluetooth par rail si non utilisé
# WL_nDisable / BT_nDisable sont des broches du module ; côté OS :
sudo systemctl disable --now bluetooth
Expected verification
After rebooting with dtparam=ant2, iw dev wlan0 scan returns networks, iw dev wlan0 link displays a consistent signal (e.g., −60 dBm at 2 m), and switching from ant1 to ant2 measurably changes the signal when the module is near a metal case. dmesg | grep -i brcm confirms the initialization of the CYW43455.
Common errors
- Expecting a hot antenna switch: the switch is configured at boot; without a reboot,
ant2has no effect. - Using a third-party antenna without considering certification: Raspberry Pi provides no certification support for third-party antennas — modular certification only covers the official kit.
- Using a metal case with the onboard antenna: the datasheet explicitly forbids this (including ground planes); Wi-Fi appears "dead" even though everything is valid.
- Forgetting that the wireless variant is a specific SKU: a CM4 without the wireless digit set to 1 simply has no radio — check the order code before buying an antenna kit.
Other tutorials for this board
- Premier démarrage d'un CM4 Lite depuis la microSD de l'IO Board
- GPIO du CM4 : comprendre les banks 1,8 V / 3,3 V avant de câbler
- Bootloader EEPROM du CM4 : maîtriser BOOT_ORDER via usbboot
- Ajouter une RTC au CM4 (PCF8523 sur I2C1 via dt-blob)
- Son sur CM4 : DAC I2S/PCM (PCM5102) sans prise jack
- Horodatage industriel : PTP IEEE 1588 sur le PHY Ethernet du CM4
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash