How to switch between a solar panel and battery?
Just use some low-voltage-drop diodes, such as Schottky diodes, to ensure that the battery will not try to energize the solar cell.







simulate this circuit &ndash; Schematic created using CircuitLab

Here, the solar cell is represented using the photodiode symbol D1, which is the closest thing available in the schematic editor.  Current can flow from the photocell only if it develops a voltage which exceeds that of the battery by at least about 0.25V, a difference that is needed to forward-bias the Schottky diode D2.  When this condition does not exist (for instance, the light is too low), then the Schottky is not forward biased and prevents the reverse current flow from battery to D1.

Here is a version of the above schematic which incorporates a more detailed discrete component model of the cell:







simulate this circuit