Enable external wifi antenna on XIAO_ESP32C6

Is there anyway to activate the external antenna on the XIAO ESP32C6 in ESPHome?

I know i have to set GPIO03 to low and GPIO14 to high, but can’t get it to work.

I have tried to make some output and run them on boot, but don’t work.

output:

  • platform: gpio
    id: “GPIO14”
    pin: GPIO14
  • platform: gpio
    id: “GPIO03”
    pin: GPIO03

and

on_boot:
priority: 1000
then:
- output.turn_off: GPIO03
- output.turn_on: GPIO14

Also tried switch, but also don’t work.

Then i found someone that wort you should do this, but i get a error when trying it, so not sure what to do.
on_boot:
priority: 1000
then:
- lambda: |-
pinMode(02, OUTPUT);
digitalWrite(02, HIGH);

And can’t find it anywhere on google how to do it, so is there anyone here that know?

Can be tricky with esphome.
Try with that 100ms delay between outputs.

C6 is still on experimental state here.

How do i add delay?
Can find the right command for that.

      - output.turn_on:: output03
      - delay: 100ms
      - output.turn_off: output14

Don’t give id like “GPIO14”, it’s too confusing (if it even work).

That don’t work :confused:
i will keep trying other stuff.

I got it working.

I added a output and a switch to switch from internal to external wifi antenna :slight_smile:

output:

  • platform: gpio
    id: “GPIO03”
    pin: GPIO03

switch:

  • platform: gpio
    pin: GPIO14
    restore_mode: ALWAYS_OFF
    name: “Internal Wifi Antenna On/Off”
    id: “GPIO14”

And added this to the start
on_boot:
priority: 800
then:
- output.turn_off: GPIO03

So now i have a switch that work and i can turn on or off the internal antenna.
Off is the external antenna.

What worked for me:

esphome: 
  esphome:
  name: esp32-c6

  on_boot:
      priority: 800
      then:
        - wifi.disable:
        - output.turn_off: pin3 # activate RF Switch control
        - delay: 100ms
        - switch.turn_on: pin14 
        - wifi.enable:

output:
    platform: gpio
    id: pin3
    pin: GPIO03

switch:
    platform: gpio
    pin: GPIO14
    restore_mode: ALWAYS_OFF 
    name: "External Wifi Antenna On/Off"
    id: pin14

But the signal only got around 5-8 dB better. Might depend on the antenna-design.

2 Likes

Try playing around with the output power under the wifi section:

wifi:
...
 output_power: 20.4 dB

Why is that “only”?
If I was offered a salary increase of 5-8 dB I would be ecstatic Text

How do you measure it?
Im currently experiencing issueds with zigbee range of esp32c6 and used antena also, no luck at all.

I’m a little bit late to the party but this is what I’m using:

esphome:
  ...
  on_boot:
    then:
      - output.turn_off: rf_switch_enable
      - delay: 100ms
      - output.turn_on: antenna_select

output:
  - platform: gpio
    id: rf_switch_enable
    pin: GPIO3
  - platform: gpio
    id: antenna_select
    pin: GPIO14

The node has been running reliably and has decent WiFi reception but I’m also curious if there is a reliable way to actually confirm which antenna it is using?

Code (posted by michapixel) is working for me, confirmed both with wifi signal from Ubiquiti AP and Bluetooth device.