Power Source Query

Hi

So I'm trying to design a project at the moment where my arduino board is powered by an external battery as the main source. But obviously when the battery gets low it needs to stop using the battery, first question, is there anyway I can stop the arduino receiving power from the battery source at Vin. Secondly, is there any way I can find out what power source is powering the arduino (USB or Vin etc)? As when it is connected to a USB I want it to charge rather than power the main circuit. I've currently got an SPDT relay in place to switch between the charging circuit and main circuit, when the battery source gets low.

Currently I haven't made my mind up on which Arduino board to use so if one type would be easier than the other then please let me know! For instance I know the MKR1000 has a LiPo charging circuit integrated into the board.

Cheers!

is there anyway I can stop the arduino receiving power from the battery source at Vin.

If you were able to, where would you get power from, instead?

Secondly, is there any way I can find out what power source is powering the arduino (USB or Vin etc)?

You googled this, right? The answer is yes, but it is not all that easy.

I've currently got an SPDT relay in place to switch between the charging circuit and main circuit, when the battery source gets low.

If you start charging the battery source soon enough, there is no reason to not continue drawing current from the battery while you are charging it.

On the other hand, if the power to charge the battery will always be present, it doesn't make sense to run the Arduino off of the battery.

PaulS:
If you were able to, where would you get power from, instead?

It is basically going to be portable, so would not get power, if the battery is effectively dead, until connected to a USB source which will charge the battery. Then it will run from the battery when disconnected from the USB source again.

PaulS:
If you start charging the battery source soon enough, there is no reason to not continue drawing current from the battery while you are charging it.

On the other hand, if the power to charge the battery will always be present, it doesn't make sense to run the Arduino off of the battery.

The issue I have is obviously the battery is powering the arduino, so when switching to the charging circuit, the battery will essentially be using its own power to charge itself if that makes sense? (Assuming no USB source is connected straight away when the battery needs charging!)

The issue I have is obviously the battery is powering the arduino, so when switching to the charging circuit, the battery will essentially be using its own power to charge itself if that makes sense?

It does not. The charging circuit is what should be providing power to charge the battery.

I suspect that your whole design needs rethinking.

PaulS:
I suspect that your whole design needs rethinking.

+1

You have not told us what type of, or voltage of battery you are using.

USB provides 5v power with a limited amount of current. Leaving aside all the complications about switching from one to the other, how will you charge the "undefined" battery with a 5v power supply?

...R