WiFi
selectAntenna() [antenna]
WiFi.selectAntenna, selectAntenna
Note:
On the P2 and Photon 2, selectAntenna selects which antenna the device should connect to Wi-Fi and BLE with and remembers that setting until it is changed. Resetting Wi-Fi credentials does not clear the antenna setting.
The Argon (Gen 3) does not have an antenna switch for Wi-Fi; it can only use an external antenna. There is a separate setting for the Argon BLE antenna (BLE.selectAntenna).
On the Photon and P1 (Gen 2), selectAntenna selects which antenna the device should connect to Wi-Fi with and remembers that setting until it is changed. Resetting Wi-Fi credentials does not clear the antenna setting.
// SYNTAX
STARTUP(WiFi.selectAntenna(ANT_INTERNAL)); // selects the CHIP antenna
STARTUP(WiFi.selectAntenna(ANT_EXTERNAL)); // selects the u.FL antenna
STARTUP(WiFi.selectAntenna(ANT_AUTO)); // continually switches at high speed between antennas
WiFi.selectAntenna()
selects one of three antenna modes on your Photon or P1. It takes one argument: ANT_AUTO
, ANT_INTERNAL
or ANT_EXTERNAL
.
WiFi.selectAntenna()
must be used inside another function like STARTUP(), setup(), or loop() to compile.
You may specify in code which antenna to use as the default at boot time using the STARTUP() macro.
Note that the antenna selection is remembered even after power off or when entering safe mode. This is to allow your device to be configured once and then continue to function with the selected antenna when applications are flashed that don't specify which antenna to use.
This ensures that devices which must use the external antenna continue to use the external antenna in all cases even when the application code isn't being executed (e.g. safe mode.)
If no antenna has been previously selected, the ANT_INTERNAL
antenna will be chosen by default.
WiFi.selectAntenna()
returns 0 on success, or -1005 if the antenna choice was not found.
Other errors that may appear will all be negative values.
// Use the STARTUP() macro to set the default antenna
// to use system boot time.
// In this case it would be set to the chip antenna
STARTUP(WiFi.selectAntenna(ANT_INTERNAL));
void setup() {
// your setup code
}
void loop() {
// your loop code
}