MCU detect when USB is connected

Thread Starter

mosibrahim

Joined Sep 14, 2022
1
I wanted the MCU I'm using, samd21g, to detect when USB is connected on the board. The USB is used to power some other things on the board and currently isn't connected to the MCU. Also, the MCU can only handle 3.3V. I have a pin open on the MCU that I can connect the power of the USB to it through a voltage divider for example and I can detect when it goes high, but I'm worried that there could be too much current that would flow into that MCU pin. So I wanted to know, what is the best way to detect when the USB is connected?
 

Ya’akov

Joined Jan 27, 2019
9,070
I wanted the MCU I'm using, samd21g, to detect when USB is connected on the board. The USB is used to power some other things on the board and currently isn't connected to the MCU. Also, the MCU can only handle 3.3V. I have a pin open on the MCU that I can connect the power of the USB to it through a voltage divider for example and I can detect when it goes high, but I'm worried that there could be too much current that would flow into that MCU pin. So I wanted to know, what is the best way to detect when the USB is connected?
Welcome to AAC.

Though a resistor would be current limiting in any case, and the poin is high impedance, ou might consider an optoisolator which will provide galvanic isolation and keep the MCU separated from whatever you are powering with the USB connection.
 
Top