ESP32-S3 VBUS Detect - alternatives to GPIO pin
Posted: Sun Apr 13, 2025 5:48 pm
Hi all-
I'm working on a new industrial device that has the ability to work with both self-power and bus-power. It uses two eFuses and a USB-C PD chip to autonegotiate a power source through a fairly complex set of circuitry, and has substantial protection circuitry between the processor and the inputs.
As the documentation says, if you have a device that is self-powered, you need to implement your own VBUS detection to determine when a cable is attached or removed. https://docs.espressif.com/projects/esp ... red-device indicates the default approach is to use a voltage divider to attach the VBUS signal to a pin, then use that pin number when initializing the USB stack for .vbus_monitor_io.
Under the covers, it appears this results in that pin being directly mapped to a signal that goes into the PHY, vbusvalid. https://github.com/espressif/esp-idf/bl ... phy.c#L115
I'm in a situation where I'd like to take a different approach and not use a GPIO pin:
- A simple voltage divider is complicated because VBUS may be any voltage between 5V and 20V, and requires external components/board space
- I'm out of GPIO pins and want to reclaim the pin used for VBUS detection
- My USB-C PD controller knows if a cable is plugged in, but it communicates via I2C with the host, not GPIO
So the approach I'd like to take is to communicate with my USB-C PD controller, then write a register or call a function when a plug or disconnect event occurs.
Is there a supported way to do this? If not, the documentation indicates the PHY is a proprietary design - can someone with access to these suggest the appropriate way to communicate with it to indicate that a connection or disconnection has happened?
Thanks in advance!
I'm working on a new industrial device that has the ability to work with both self-power and bus-power. It uses two eFuses and a USB-C PD chip to autonegotiate a power source through a fairly complex set of circuitry, and has substantial protection circuitry between the processor and the inputs.
As the documentation says, if you have a device that is self-powered, you need to implement your own VBUS detection to determine when a cable is attached or removed. https://docs.espressif.com/projects/esp ... red-device indicates the default approach is to use a voltage divider to attach the VBUS signal to a pin, then use that pin number when initializing the USB stack for .vbus_monitor_io.
Under the covers, it appears this results in that pin being directly mapped to a signal that goes into the PHY, vbusvalid. https://github.com/espressif/esp-idf/bl ... phy.c#L115
I'm in a situation where I'd like to take a different approach and not use a GPIO pin:
- A simple voltage divider is complicated because VBUS may be any voltage between 5V and 20V, and requires external components/board space
- I'm out of GPIO pins and want to reclaim the pin used for VBUS detection
- My USB-C PD controller knows if a cable is plugged in, but it communicates via I2C with the host, not GPIO
So the approach I'd like to take is to communicate with my USB-C PD controller, then write a register or call a function when a plug or disconnect event occurs.
Is there a supported way to do this? If not, the documentation indicates the PHY is a proprietary design - can someone with access to these suggest the appropriate way to communicate with it to indicate that a connection or disconnection has happened?
Thanks in advance!