The internal WiFi module on the Compute Module 4 (that's the bit under the metal shield in the picture above) routes its antenna signal via software. You can route the signal to either:
- The built-in PCB triangle antenna (this is the default).
- The external U.FL connector (which has an external antenna plugged into it in the picture above)
To switch the signal to the U.FL connector (for example, if you're installing your CM4 in a metal box where the PCB antenna would be useless), you need to edit the boot config file (
sudo nano /boot/firmware/config.txt, and add the following at the bottom:
# Switch to external antenna.
Then reboot the Pi.
To switch back, comment out or delete the
dtparam line above. Note that you can actually disable the WiFi antenna route entirely (even without disabling the WiFi chip); here are the docs straight from the firmware repository:
ant1 Select antenna 1 (default). CM4 only.
ant2 Select antenna 2. CM4 only.
noant Disable both antennas. CM4 only.
See my original review of the Compute Module 4 for more information about antenna performance, and a recommendation of an external antenna to buy (though you can't go wrong with the one from Raspberry Pi themselves!).