Find if Onchip or External Antenna being used

Hello Guys,

Good Morning/Afternoon/Evening,

I am working on a project with Particle Photon P1 chip and I am trying to determine from the software/firmware side what (chip, or External) antenna is being used.

Reading upon the datasheets, and browsing the forums, I came across 2 possible solutions :-

  1. WiFi.selectAntenna(ANT_EXTERNAL) and WiFi.selectAntenna(ANT_INTERNAL) functions return 0 when antenna is present a negative value(-1005) when antenna is not present, but in my case I am always receiving 0 irrespective of the antenna I am using :frowning:

  2. SPDT RF switch that controls the selection of antenna. I am wondering if there is a way I can read if SW_ctrl1 is active or SW_ctrl2, through firmware/software.

As some additional piece of information : currently, there is a Startup Function to wrap (WiFi.selectAntenna(ANT_EXTERNAL)) before SETUP and Loop able to switch to External Antenna upon startup, and if I unplug/pull out the external antenna, P1 falls back to chip antenna.

Any help in either why I am recieving all zeroes in approach 1 and any further insights into step 2, in addition to any other knowledge/guidance is much appreciated.

Thanks

Have you considered WiFi.selectAntenna(ANT_AUTO) at all?
If so, why would you rather not use it?

I am not quite yet positive of the scenarios ( as I havent found any yet) when what combination/permutation of settings(on router, antenna, and firmware) will make the signal strength reported by external antenna be less than internal antenna. so thats my current plan is to check if external antenna is present in the hardware, and if yes, go with on-chip(internal) unless external fails.

Hello,

I did some more research and found these RF_SW_CTRL0_ANT0 and ANT1 controlling the SPDT switch. on Particle P1 chip they are connected to line 13 and 12. I am wondering how do I poll them to see if they are on/off? and if there is an API for this?

Thanks

Hey Good Evening @ScruffR

Would you happen to have any clues or path forward or a strategy/technique I can try that can tell, from the hardware layer, which antenna(chip or UFL) is currently turned on…??

The antenna switching is done by the WICED non-open source part of the device OS.
Since I have no access to that code I can’t really help with that but maybe @rickkas7 can.

What does the comment in the docs mean about switching between antennas at high speed?

STARTUP(WiFi.selectAntenna(ANT_AUTO)); // continually switches at high speed between antennas

Does it really continually switch between the two? I thought it would be based on RSSI level.

I don’t think checking the current antenna pin state will be helpful. If you set it manually, you should be able to know what you set it to.

If you selected ANT_AUTO, it frequently switches to the other antenna to see if the signal is better with that antenna. Since there is only one radio with an antenna switch, it can’t simultaneously check both antennas. So what’s returned by the antenna select pin will be what it happens to be looking at, at the moment, not what the currently selected antenna is. It could be the one that has no signal, at any given point in time.

There is an ioctl in WICED (the Photon/P0/P1 Wi-Fi networking stack) to get the current antenna in ANT_AUTO mode, but I don’t think you can call wwd_sdpcm_send_ioctl from user firmware, so that won’t help either.

1 Like