Detect USB is connected on esp32-s2

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
def1149
 
Posts: 4
Joined: Sat Jul 04, 2015 12:38 pm

Detect USB is connected on esp32-s2

Post by def1149 »

How do I detect that the native USB is connected to PC? I use deep sleep and wake up on timer. When the esp32-s2 wakes up I'd like to detect if the USB is connected to the PC.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: Detect USB is connected on esp32-s2

Post by mikeysklar »

With CircuitPython you can for a PC connect by using:

Code: Select all

supervisor.runtime.serial_connected 
supervisor.runtime.usb_connected
You can try the suggestion here from a reddit thread that uses usb_dev.

If the above does't work out you could set a pin alarm and tie the USB power pin to another GPIO and use it as an interrupt.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”