Hello, We are using the 32u4 5V board. Is there any way to determine if it is being powered by USB or Battery? It is important that we know the power source for the board when it is running.
Thanks!
ItsyBitsy 32u4 - Determine Power Source
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- dastels
- Posts: 15820
- Joined: Tue Oct 20, 2015 3:22 pm
Re: ItsyBitsy 32u4 - Determine Power Source
You could add a voltage divider to Vbus and monitor it using an analog input. If there's 5v on it, USB is connected and is powering the board.
100K resistor with one end connected to Vbus, another with one end connected to ground. Connect the free ends together and to an analog input. If the reading is relatively high, USB is powering the board. Relatively high will be roughly ta half of the input value range. Since the 23u4 has 10-bit ADCs that'll be close to 512. Don't go too close because the resistors won't be exact. The best thing to do is code up a script to read it and output the result. Switch between USB and battery and see what values you get.
Dave
100K resistor with one end connected to Vbus, another with one end connected to ground. Connect the free ends together and to an analog input. If the reading is relatively high, USB is powering the board. Relatively high will be roughly ta half of the input value range. Since the 23u4 has 10-bit ADCs that'll be close to 512. Don't go too close because the resistors won't be exact. The best thing to do is code up a script to read it and output the result. Switch between USB and battery and see what values you get.
Dave
- Wellcore430
- Posts: 2
- Joined: Mon May 02, 2022 5:44 pm
Re: ItsyBitsy 32u4 - Determine Power Source
Thanks for your helpful suggestion, Dave,
We will give it a try!
We will give it a try!
Please be positive and constructive with your questions and comments.