I have wanted batteries in so many different ways, that it would be hard to have a 1 size fits all configuration.
If you aren't aware of it, a forum member (or previous forum member) designed a charger that is made to solder on to the bottom or top of a Teensy and provide charging:
- https://www.tindie.com/products/oneh...ttery-charger/
- You need to cut the solder pad between VIN and VUSB. The switch on the front controls whether the Teensy gets powered. If the USB has power, it will charge the battery if needed, even if the power switch to the Teensy is cut. Usually this is what I want, since I often make cosplay units, and I can charge the battery overnight without having the unit running all of the time.
- You can choose via solder pads whether you want to charge the batteries at 300mA, 500mA, or 800mA. Smaller batteries need smaller charge current, while bigger batteries won't be fully charged over night with a small current.
- The JST plug is not connected by default. You have to solder it into place. In practice, I have to be real careful in attaching and removing the battery, as I have ripped the JST plug off of the unit.
- If you have the Teensy in a stacked setup, it can be hard to fit in the charger.
If you are using the Teensy 4.0 or 3.2, you can use the Adafruit Teensy feather adapter, which include a charger, and it uses A7 with a voltage divider to allow you to crudely measure how battery capacity is left. You can also use the Teensy 4.1/3.5/3.6, if you use stacking headers, or mount the Teensy underneath the feather adapter.
Adafruit also has two other chargers that aren't made directly for Teensy, but you can use them with the appropriate wiring:
Seeed makes a combination battery charger and voltage booster. You plug a USB C cable into the USB socket, and it recharges the battery. You use a standard USB A to micro-B cable to provide power to the Teensy. This is nice for times when you want 5 volts. However, because it is boosting the power, you do get less runtime.
I also like the little chargers I get from ebay. They are the right size for gluing to the back of the bigger batteries. I often will also solder in a switch so I can turn off the battery. I keep meaning to attach these to more batteries. Then I can charge the battery with the USB plug on the battery, and I don't have to worry about getting power from the Teensy.
Over the years, some issues that I've seen with built-in charging:
- As I mentioned earlier, you have to balance how much current is used to charge the batteries based on the batteries you intend to use. Most units are fixed, and a lot are on the low side (100mA or 200mA). That is great if you want to use 500mAh batteries or smaller, but I often times start at 1,200mAh batteries.
- Not every place wires batteries the same way. I tend to use the Adafruit standard for wiring, but several batteries I've ordered from Amazon have the ground and power wires switched ports. I have to cut the battery cable and re-solder in a more standard connector.
- I've come to hate the JST connector. I find it hard to remove (but hey, it is less likely to come out, like DuPort jumper wires might). If I've attached a JST plug by soldering, the force of removing and attaching the battery can over time yank the socket out of the board. Sometimes I just switch to use DuPont stacking headers (using scotch tape to keep things connected). I've also thought about using audio cables or 5.5mm x 2.1mm cables for connecting the battery.
- I've had to rewire batteries every so often, as the solder connecting the wires comes out. A big reason is sooner or later, the battery will fall out the board and be hanging by the cable.
- If you use something like a AA/AAA battery holder with 3-5 batteries, you have to make sure this never gets connected to a circuit that tries to recharge the battery.