I have a trinket that I'm going to be powering off of a small lithium ion battery. I was also considering adding a small solar panel to the mix, and using the solar panel to charge the battery. I'm wondering if I can use the trinket itself as a smart charge controller to charge and monitor the battery.
If you are going to design your own battery management system here are a few issues you will need to deal with:
You need to understand the methods to determine the End Of Charge (EOC). This could be monitoring cell temperature, measuring cell voltage or current for patterns, or integrating current over time (coulomb counter). Different battery chemistries usually dictate which approach to take.
You need to check with the specific battery manufacturer to determine what charge rate you should use for this specific battery. Knowing the chemistry is good. But it is usually best to use the charge rate data from reputable manufactures.
Some batteries can not be completely drained. If not already part of the LION battery, you will need to design a protection circuit to cut the battery off before this happens.
For such batteries, you need to add a trickle charging circuit in case the battery has been overly discharged. Such a circuit only allows a small amount of current in. The current is usually so small that normal monitoring is not necessary. This is a last resort procedure built into most good chargers to recover overly discharged LION batteries.
...this is not a complete list. These are some of the issue which might be considered when designing a secondary battery charger. There is a lot more good information about batteries here if you would like to research this subject in greater depth.
If you have a small solar panel, you probably don't have to worry about limiting the charge current (as the battery will be able to handle more that the solar panel can supply).
So the only thing left to do is prevent over-charge (i.e. disconnect the solar panel if the voltage on the battery goes above 4.2V).
Protected cell can do this for you. I'm not knowledgeable enough to know if it's a good idea to rely on this.
Also make sure the solar panel isn't connected when it's dark, as the solor panel will use current when it's not generating it. Though a simple diode will do this trick. But you'd get a 0.6V drop on the diode, so you might want to get some extra efficiency by detecting output and switching the solar panel using the Arduino.
The last problem is overdischarge, unless you have a protected cell. But that's a problem you have, even without the charging bit.
Try this. It's the Adafruit PowerBoost 1000 Charger - Rechargeable 5V Lipo USB Boost @ 1A - 1000C.
It's designed for Lipo, but I think it should work for Li-ION