XIAO_ESP32C6 Switching between builtin and external antenna

In addition to the on-board antenna, XIAO_ESP32C6 has a connector for an external antenna. As shown in the schematic, the antenna is switched by the FM8625H RF switch. The on-board antenna is selected by default. The external antenna can be selected with the following code.

pinMode(3, OUTPUT);    // RF switch power on
digitalWrite(3, LOW);
pinMode(14, OUTPUT);   // select external antenna
digitalWrite(14, HIGH);

The following code or a reset will enable the on-board antenna.

pinMode(14, INPUT);    // select on-board antenna
pinMode(3, INPUT);   // RF switch power off

This is the sketch I used for confirmation.
ESP32C6_XIAO_Scan_AntSelect.zip (1.1 KB)

I connected the antenna that came with the ESP32C3.
I confirmed that the antenna is switched by increasing the RSSI value.

2 Likes

I am having trouble to get the external antenna of my XIAO C6 to work and got to this post.

I am confused about GPIO3. Doesn’t the RF switch chip (FM8625H) need to be enabled regardless of the antenna used?

In other words, according to the schematic (which is pretty confusing due to the crossed-out components) doesn’t the VDD input of the chip always need to set high (and consequently GPIO3 set to 0) for any antennae to work?

After setting GPIO3=0 and GPIO14=1 I was expecting the board to be unable to use WiFi at all without an external antenna plugged-in. However, that’s not the case. I get some erratic WiFi connections, so something is amiss.

Also, WiFi seems to work (also erratically, but it works) regardless of the settings I choose for GPIO3 and 14.

I have confirmed that my GPIO output code works since it turns on the yellow LED if I set GPIO15 to 0.

I may be making wrong assumptions here, but I have a sense that the schematic we have is not precise.

Although not explicitly stated in the FM8625H datasheet, it was assumed that ANT-RF1 would conduct if no power was supplied to VDD.
Also, the isolation between ANT-RF is about 30 dB, so it might be possible to use it with signal leakage, albeit unstable.

Ah, that can explain it! Although I find it really odd that the datasheet doesn’t state it explicitly since it’s a pretty fundamental behavior.

Makes sense, thanks! I will conduct some further testing.

Hi,
Thank you for all the great information.

Please note that the XIAO ESP32C3 antenna and XIAO ESP32C6 combination is not TELEC compliant in Japan. :wink:
https://lab.seeed.co.jp/entry/2024/06/19/120000

image

Thank you for the information.
I checked and all my antennas are V1.2. I will use the on-board antenna for the C6.

1 Like

I thought a lot about the behaviour of the RFSW FM8625H when no power is applied to the VDD pin.
I came to the conclusion that the ANT is never connected to either RF port and that the signal is leaking because it is not sufficiently isolated. Therefore, when using the antenna switch, it is correct to explicitly apply power to the switch and set the selection signal to HIGH or LOW. (The ESP32C6 wiki says so)
With this in mind, the diagram shown in POST1 is modified.

If the RF switch should be enabled whenever using WiFi (and not just the external antenna) it’s odd that the Seeed wiki doesn’t state it explicitly. I recall they only mention you should do it for the external antenna.

It would be good if Seed Studio released the final schematic (without crossed-out components) and positioned themselves about this.

I wanted to upgrade to the C6 from the S3, but the WiFi connectivity has proven to be very unstable (I don’t know if it’s a problem with the antenna configuration or something else).

Hi there,
Probably both is what I’m feeling… and power consumption wise they throw the baby out with the proverbial WiFi bath water IMO. a.k.a. Giant batteries a must! YOI! :yawning_face:
YMMV
GL :slight_smile: PJ :pinched_fingers:

the S3 is the only good one because of the extra IO available IMO, too bad you need to buy a stupid gimmick of a camera to get access to it.(B2B) connector, and role your own IO board.

Wiki said:

you need to set GPIO3 low level to turn on this function.

I think “this function” means antenna select function.
There may be interference between components due to the antenna circuits being placed in a small area, which could make WiFi unstable.
When I have more time, I will try to compare RSSI while switching antennas.

1 Like

Not to derail the thread but that red breakout board and white “breadboard” seem super useful. Did you make them yourself?

I think you should be able to solder the connector to a non-sense S3 (and thus removing the need to buy the camera expansion board).

Hi there, Yes I did, and No I won’t (NO NON-SENSE) for me :smile: :grin:
Seeed needs to make a SKU# and sell it with the connector so the “Makers” they purport to support don’t have to do that just to get more I/O. Hence the Name…:v:

I can post the JLCPCB build info and you can order 5, seeed is tripping out on AI and not really supporting their core business iMo that made them an early success. Just more ESP boards , YUC :stuck_out_tongue_closed_eyes: and only one good one. the rest are just Meh’ :pinched_fingers:

HTH
GL :slight_smile: PJ :v:

check out what I have up on thingiverse and here “socket” key word Zips with all of it.
3D printed easy , with or with out pogo’s etc.

Sorry for flogging a dead horse, but here is my summary:

  • The RF switch is not enabled (powered) by the hardware when the XIAO boots.
  • The radio is still usable because of leakage across the RF switch even when it is not powered.
  • Internal or external antenna performance is better when the RF switch is enabled

Starting with version 3.0.4 of the ESP32 Arduino core, the RF switch is enabled and the internal antenna is selected in software at boot time. See the GitHub commit.

I don’t know how this is handled in the ESP-IDF.

Warning - shameless self-promotion :blush:: more details about this here: Internal vs External Antenna

1 Like

@sigmdel, I am impressed with this very well written article. Thank you for the information.

One thing I noticed while researching RF switches.
Even when no power is applied, when HIGH is input to a port, it is the same as applying power to VDD through an ESD protection diode that is built in between an input pin and VDD.
According to this hypothesis, if an external antenna is selected (by inputting HIGH), it will function properly even if no power is supplied.

Thank you @msfujino for your kind comments.

Some tests suggest that your hypothesis may not apply in the particular case of the FM8625H on the XIAO.

Average RSSI during some tests:

Test 1
   Both I/O Pins in INPUT mode  ()
   no external antenna:       -64.6
   with external rod antenna: -55.9 
----------------
Test 2     
   VDD I/O pin in INPUT mode and VCTL I/O pin is LOW (OUTPUT mode) 
   no external antenna:       -66.0
   with external rod antenna: -56.0
   
Test 3
   VDD I/O pin in INPUT mode and VCTL I/O pin is HIGH (OUTPUT mode)
   no external antenna:       -66.6
   with external rod antenna: -56.0
----------------
Test 8
   VDD I/O pin is (OUTPUT mode) and VCTL I/O pin is LOW (OUTPUT mode)
   no external antenna:       -47.5
   with external rod antenna: -51.8

Test 9
   VDD I/O pin is LOW (OUTPUT mode) and VCTL I/O pin is HIGH (OUTPUT mode)
   no external antenna:       -68.7
   with external rod antenna: -44.8

As can be seen, when the RF switch is not enabled, the RSSI is about -66 when no external antenna is connected to the XIAO and it is about -56 when an external rod antenna is connected to the XIAO no matter the state of I/O pin 14.

Is it meaningful that the presence of an external antenna actually degrades the performance when the RF switch is enabled and the internal antenna is selected while it helps when the RF switch is not enabled?

Truth be told, this is way outside of my knowledge set. You may wish to check the code on GitHub and run the tests in a different environment to see if that yields different results.

Thank you very much for making sense of antenna circuit on the XIAO and many thanks to @fons for pointing me to this topic. I learned one important lesson: turn the RF switch on.

This is an interim report on some experiments with BLE regarding the effects of RF switch power on/off and antenna selection.
The conditions are as follows

  1. Receiver side turns on RF switch and uses an external antenna
  2. Transmitter side, RF switch is on or off, and an antenna is selected
  3. When sing an on-board antenna, an external antenna must be removed
  4. The distance is approximately 10 meters over a wall

The results are summarised in the graph below.
When RF switch is powered, an external antenna has about 10 dB advantage over an on-board antenna. When RF switch is not powered, an external antenna is about 10 dB smaller, while an on-board antenna is about 30 dB smaller.

Based on the “powered from input pins” hypothesis:
If an external antenna is selected on HIGH, it will drop by 10 dB, but appears to be working. On the other hand, when set to LOW and an on-board antenna is selected, it is 25 dB smaller, close to the data sheet isolation value of 30 dB.
This is just my hypothesis.

1 Like

@msfujino : Thank you for that graphic. Here’s a graphical presentation of part of the data obtained with my sketch.

I think it shows that the only significant change in RSSI values is when the RF switch is powered (IO3 = LOW) and its VCTL signal selects the appropriate antenna. The external antenna is not connected when testing the internal antenna as in your tests.

The clear exposition of your methodology made me realize that we are not measuring the same thing.

As I understand it, you are obtaining RSSI values for wireless transmissions from a XIAO while “playing” with the RF switch of that device acting as a transmitter. In my test, RSSI values of a wireless transmission coming from a Wi-Fi access point are obtained while “playing” with the RF switch of the XIAO acting as a receiver.

Would that mean that the flow of current through the ANT signal of the RF switch matters?

Even when no power is applied, when HIGH is input to a port, it is the same as applying power to VDD through an ESD protection diode that is built in between an input pin and VDD.

I thought you were referring to the VCTL input only, but it seems to apply to the ANT port as well assuming there is an ESD protection diode on that input. Again, I am way out of my league, but would that make sense?

I thought you were referring to the VCTL input only, but it seems to apply to the ANT port as well assuming there is an ESD protection diode on that input. Again, I am way out of my league, but would that make sense?

I made a hypothesis based on the ADRF5022 interface. I don’t think the RF port has a diode in it because of the higher losses.

My conclusion from the experiments with BLE is that on-board antenna work well enough if used with proper power supply to RF switch.

Your experimental results also show that on-board antennas can be used without problems if the RF switch is properly powered and the antenna is correctly selected.

1 Like

Yes I agree.

Thank you very much @msfujino for all this and for the excellent Comparison of Sleep Currents for XIAO ESP32C6, S3, and C3