Enable the external antenna connector on the Raspberry Pi Compute Module 4/5

Feb 4, 2022
Raspberry Pi Compute Module 4 external U.FL antenna

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:

  1. The built-in PCB triangle antenna (this is the default).
  2. 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.
dtparam=ant2

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:

Params:
        ant1                    Select antenna 1 (default). CM4/5 only.

        ant2                    Select antenna 2. CM4/5 only.

        noant                   Disable both antennas. CM4/5 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!).