Go Down

Topic: How to detect if board is running on USB or Battery? (Read 573 times) previous topic - next topic


Is it possible to detect by code in the sketch if the board is actually powered by USB or Battery?

I'd like to let my board running powered via USB but with batteries attached as a back-up and trigger a message in the moment the USB power supply fails and the board switches to battery power.

Thanks in advance!


I am not sure it is possible as is. However, I would monitor battery voltage (you can find a post on this) and when lower than a threshold, send a message. If threshold is sufficiently high, likely not too much time is passed from USB failure.

Go Up