Automatic power selection between USB, Lipo battery or solar panel

For my project I have a 3.3v arduino running on a lipo battery, currently it has a USB port to comunicate with the PC and charge the battery and it works just fine, I would like to add a solar panel to charge the battery if the usb is not connected, if the usb is connected it should have priotity over the solar panel.

  1. How should I connect the solar panel (6V 3W) so it can't cause any problem if the USB is plugged in to the computer ?
  2. Should I use a diode to prevent reverse voltage when sun is down?

Would you be willing to modify your rule so that the source with the highest voltage supplies the charger? If so, you could just put a diode in each line. You may have to do that anyway to prevent back-feed from the solar cells back into the USB line, as well as from USB back into the solar cells. This would be two diodes feeding into what is now the V_usb node. Nothing would change on the battery side. But be aware that if USB is not connected, and solar voltage is below battery voltage, your existing load sharing circuit for the battery (the P-channel mosfet) may not work properly.

With Schottky diodes you wouldn't lose much voltage.

And designing a circuit that would select USB even if solar voltage is higher could be a challenge.

Anyway, this is not a simple problem.

ShermanP:
Would you be willing to modify your rule so that the source with the highest voltage supplies the charger? If so, you could just put a diode in each line. You may have to do that anyway to prevent back-feed from the solar cells back into the USB line, as well as from USB back into the solar cells. This would be two diodes feeding into what is now the V_usb node.

Yes, selecting the power source with the highest voltage is perfectly fine too, could I use the same type Schottky diode I'm using B5819W or SS14 for that?

But be aware that if USB is not connected, and solar voltage is below battery voltage, your existing load sharing circuit for the battery (the P-channel mosfet) may not work properly.

This may happen, USB will be rarely used to charge the battery, if no sun is present for a few days and the battery discharges, but in that case the device will just power off by itself , right? no battery charge will be left to power it anyway.

You mean something like this?

Yes, but then you're running both USB and solar through one diode drop to power the charger, and two diode drops to power the load. I would be concerned that you'd end up with the mosfet turned off, but the battery still powering the load through the Q1 body diode. You would have to check the numbers and make sure that the lowest solar voltage (under load) going through two schottky diodes is still higher than the 4.2V battery going through the body diode.

Actually, you might look at the MCP73871 charger chip. I believe it's designed for solar as well as USB input, and even includes a load sharing circuit. There may even be a module with this chip available from the Far East.