Switching Between Chip and u.LF antenna

Question about WiFi.selectAntenna()

In implementing the above what is the command that is passed to switched between EXTERNAL (u.LF) INTERNAL (Chip), and AUTO.

#394:
WiFi.antennaSelect(“AUTO”);
WiFi.antennaSelect(“EXTERNAL”);
WiFi.antennaSelect(“INTERNAL”);

as well as the photon change log thread:
WiFi.antennaSelect(“chip”);
WiFi.antennaSelect(“u.LF”);

Failed to work. See errors below
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privamribot.cpp: In function ‘void setup()’:
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privamribot.cpp:91:8: error: ‘class spark::WiFiClass’ has no member named ‘AntennaSelect’

changing capitalization
In function ‘void setup()’:
error: ‘class WiFiClass’ has no member named ‘antennaSelect’

@mdma is WiFi.selectAntenna() in the current release?

1 Like

Hi Kenneth,

Thanks for the response. It seemed to me like it was implemented according to the photon change log chain under firmware > enhancements .

Under the firmware github though I could only find this in src > wifitester.cpp

const char* parseAntennaSelect(const char* c, WLanSelectAntenna_TypeDef& select) {
static const char* names[] = {
    "INTERNAL", "EXTERNAL", "", "AUTO"
};
for (unsigned i=0; i<arraySize(names); i++) {
    if (!strncmp(names[i], c, strlen(c))) {
        select = WLanSelectAntenna_TypeDef(i);
        return names[i];
    }
}
return NULL;
}

as well as:

WiFi.on();
serialPrintln("ANTENNA TEST");
serialPrintln("");
serialPrintln("Internal");
serialPrintln("--------");
WiFi.selectAntenna(ANT_INTERNAL);
wifiScan();
serialPrintln("");
serialPrintln("External");
serialPrintln("--------");
WiFi.selectAntenna(ANT_EXTERNAL);
wifiScan();
serialPrintln("ANTENNA TEST COMPLETE");

note here it is "WiFi.selectAntenna()" rather than "WiFi.antennaSelect()"

Neither seemed to compile though:

/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privagaragebotv1.1.cpp: In function 'void setup()':
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privagaragebotv1.1.cpp:94:28: error: no matching function for call to 'spark::WiFiClass::selectAntenna(const char [5])'
int CharsWrote = 0;
^
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privagaragebotv1.1.cpp:94:28: note: candidate is:
In file included from ../wiring/inc/spark_wiring.h:41:0,
from ./inc/application.h:29,
from /spark/compile_service/shared/workspace/6_hal_12_0/firmware-privagaragebotv1.1.cpp:2:
../wiring/inc/spark_wiring_wifi.h:167:9: note: int spark::WiFiClass::selectAntenna(WLanSelectAntenna_TypeDef)
int selectAntenna(WLanSelectAntenna_TypeDef antenna) {
^
../wiring/inc/spark_wiring_wifi.h:167:9: note: no known conversion for argument 1 from 'const char [5]' to 'WLanSelectAntenna_TypeDef'

You can see the correct syntax in the tests linked below, for example WiFi.selectAntenna(ANT_EXTERNAL)

This does not compile in the cloud yet, but it does on the develop branch if you’re building locally. We look forward to releasing a new firmware version soon.

2 Likes

So, as of today, it’s not possible to use the external antenna on a Photon unless you build locally? Is that correct?

Yes that’s correct. We have one critical issue to address before we can roll out a new image to the cloud, but we are very much hoping it happens this week, such subsequent updates happening every couple of weeks.

So I have hooked up an external antenna following my earlier post just to see if the current photon firmware would auto switch between the external and internal antennas upon boot. I have been using the built in fxn, WiFi.RSSI() , to monitor the wifi strength. I have definately noticed a several dB boost in signal and in performance when using an external antenna such as the one from SparkFun . This boost seems too large for the external antenna simply funneling more wifi signal into in the internal antenna rather than acting as the antenna itself, but if it is not auto switching maybe that is what is happening.

I ordered an antenna from your site. Does this mean I can use when, say, 4.4 comes out? Just want to understand what I need to wait for!

Thanks!

I am just using the current release of the firmware and webIDE with the above mentioned antenna and a photon

The default mode is auto where it selects the strongest signal, so you should be able to simply plug in the antenna.

The WiFi.seletAntenna() API will be available when the compile farm is updated.

1 Like

@mdma, is this also the current behaviour for the P1?

Yes, that’s correct, same behavior on the P1.

Is this correct or incorrect? It’s kinda important.

If in doubt, try it. The WICED docs say that AUTO is the default.

Is the WiFi.selectAntenna() function available right now? I still get a linker error compiling a simple program using it.

It is not yet available. Once you hear the announcement for firmware V0.4.3 release it should be.

is the antenna selection available in 0.4.6?

@avidan - https://docs.particle.io/reference/firmware/photon/#wifi-selectantenna-