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/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 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!).
Awesome, thanks for sharing- I’ve a CM4 on order from Seeed Studio, so will look at this when it arrives.
Sorry to be a grammar Nazi, but "it's" in the first sentence is incorrectly used.
Oops! Thanks for catching that. I fixed it!
don't' be a pendant ;-)
The presence of this comment indicates this site is running on the Turing Pi 2 server. That's all.
Jeff thank you for writing this up. Certain tips are surprisingly un-prominent in the RPi boards. I needed this.
FWIW, the file is found in /boot/firmware/config.txt on Ubuntu if you work from their raspi image. They recommend you edit usercfg.txt, in the same directory, instead. It is pulled into config.txt at boot time.
I'm quite intresting in build WIFI router with this CM4-DUAL-ETH-4G/5G-BASE board, looking forward to more videos
Next week's video will be showing off that board!
I tried to disable the antenna alltogether with the noant option but it seems this has no effect and that the Wifi Connection is still there
I have the same problem, did you find any solution for this problem?
What are the odds.. running into the same issue on the same day.
I just completed multiple tests running the three antenna options. It doesn't seem to make any difference.
My CM4 is in a steel enclosure which causes a lot of interference. Screwing on my external antenna improves the signal for all options (ant1, ant2, noant). Maybe the latest PI firmware automatically detects the antenna?
Some info on my system:
[email protected]:~ $ sudo /opt/vc/bin/vcgencmd version
May 11 2020 18:59:41
Copyright (c) 2012 Broadcom
version 21bfdeee3a6ea823e2113b983390acd1eec8edfb (clean) (release) (start)
[email protected]rrypi:~ $ sudo rpi-eeprom-update
CURRENT: Tue Feb 16 13:23:36 UTC 2021 (1613481816)
LATEST: Thu Apr 16 17:11:26 UTC 2020 (1587057086)
FW DIR: /lib/firmware/raspberrypi/bootloader/critical
I found an identical issue. It seems that the antenna cannot be switched as expected. I found that the Tx power from the UFL connector does not change at all using different antenna configurations.