Page 1 of 1

Detect if USB is connected

Posted: Mon Apr 06, 2020 3:27 pm
by CtnAdrian
Hello,

I am using ESP32 WEMOS LOLIN32 board.
The project I am developing is using an external battery to run. I am trying to use USB connection only for charging the battery, and to stop the program execution when it is connected.
Is there any solution to detect (pin, register, interrupt, etc) if USB is connected without changing the hardware (soldering wires to VBUS)?

I can't find anywhere on the internet this information.
Thank you!

Re: Detect if USB is connected

Posted: Mon Apr 06, 2020 7:47 pm
by ESP_igrr
Hi CtnAdrian,

On the ESP32 development boards, USB is provided by an external component, usually a CP2102, CP2104 or FT223H chip. These chips do have outputs to indicate whether USB is connected (check respective datasheets). However on all the boards I know these outputs are not wired to the ESP32. You might be able to solder a wire from the respective USB-UART chip pad to one of the ESP32 inputs.