Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

How to determine if powered by USB?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

How to determine if powered by USB?

by kevinjwalters on Sat May 30, 2020 1:42 pm

Is there a good way to determine if a board is connected to USB power in CircuitPython? I was pondering changing application behaviour a little when not connected to lower the power usage slightly on the assumption that the device is battery powered. Given that the battery and USB power can be simultaneously connected I think I want to avoid an is-battery-connected test?

kevinjwalters
 
Posts: 634
Joined: Sun Oct 01, 2017 3:15 pm

Re: How to determine if powered by USB?

by adafruit_support_bill on Sat May 30, 2020 1:56 pm

You can monitor the voltage on the USB pin with an analog input. Since it will be 5v when connected to USB, you'll need to use a voltage divider to scale it down to 3.3v max.

adafruit_support_bill
 
Posts: 77937
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.