Add battery charger circuit

Posted on
  • Hi,

    I love Espruino board and I'd like to embed Espruino together with Lithium Polymer battery into a case, with one opening for uUSB.

    I'd like to add battery charger circuit so that battery would be charged when uUSB on Espruino is connected to PC.

    Does anyone have recommendation which charger IC to use and how to connect?

    Reading Espruino document at
    http://www.espruino.com/EspruinoBoard
    http://www.espruino.com/Battery

    I understood that Espruino board does not have charging IC on board. "An unpopulated resistor that can trickle-charge a battery when fitted" sounds tempting but I feel better not to take risk after reading this tutorial.
    https://learn.adafruit.com/li-ion-and-li­poly-batteries?view=all

    Searching around, it seems easiest to put off-the-shelf charger board into the case.
    https://www.sparkfun.com/products/10401
    Or MAX1555 charger IC seems simple enough to put on SMD proto area.
    https://www.sparkfun.com/products/674

    Now my question is: how to wire the charger IC between the battery and Espruino, and how to get uUSB 5v supply to the charger IC.

    Checking the schematics of this product
    https://www.sparkfun.com/products/12711
    https://cdn.sparkfun.com/datasheets/Prot­otyping/USB_LiPolyCharger_SingleCell21.p­df
    It looks like I can just connect the battery and Espruino's BAT_IN in parallel to MAX1555's BAT pin. I guess it has to be BAT_IN rather than VBAT. (am I right?)
    I think I'd access BAT_IN by soldering a wire to JST PHR-2 2 Pin.

    Now how should I get power supply to the charger IC? MAX1555 takes 3.7v to 6v so Espruino's 3.3v pin is just under. Mmm, reading Espruino schematics again, VBAT seems to become uUSB's power when it is plugged-in. Then it's easy.

    As the conclusion, I think all I need is:

    • Mount MAX1555 on SMD proto area
    • Wire BAT (MAX1555) to BAT_IN (Espruino's JST PHR-2 2)
    • Connect USB (MAX1555) to VBAT

    Plugging-in uUSB and battery together is ok thanks for Gordon to implement MOSFET-P-0440210P1 switch. And it also enabled easy access to get uUSB's 5v supply to charger IC. Cool.

    I hope someone could confirm above is right before I give it a try and blow up my precious Espruino board...

    And I'd appreciate any extra advice ;-)

  • And of course I should connect GND (MAX1555) and GND (Espruino) !

  • Yes, that sounds good - my only worry would be that if you use VBAT, the charger will be powered when you're powered from the Battery too, so it may flatten the battery.

    Instead, you might be better going directly from USB. There isn't a pin for that, so the best bet would be to solder to the large diode near the USB connector.

    The only other suggestion to make the trickle charge safer is to add a 4.2v zener diode across the battery. That way, you can be sure that the battery won't be over-volted. All you'd have to do is solder an SMD zener across the JST connector, and then resistor for the trickly charge.

  • Thank you, Gordon!
    Hah, silly me. I completely overlooked the case when uUSB is not plugged in... I shouldn't try to charge the battery with its own power...

    OK here's updated list to do:

    • Mount MAX1555 on SMD proto area
    • Wire BAT (MAX1555) to BAT_IN (Espruino's JST PHR-2 2)
    • Wire USB (MAX1555) to USB_VBUS (access at D1 1N5819)
    • Connect GND (MAX1555) and GND (Espruino)
  • Looks good. Seems like a really neat chip. If I'd have known I'd have tried to put a footprint for it on-board!

  • Unpopulated pads for it would have been nice. Idea for ESPRUINO BOARD REV 2.0 !?

  • That's one hell of a neat chip - looks like it should be able to charge 18650 batteries too no problem (18650s rated at 4 Ah are $1.40 shipped - granted those are chinese amp hours, but they're still a far better deal than most of the Li battery packs).

    I agree with user6911 - unpopulated pads for a MAX1555 would be awesome in the next iteration of the Espruino board.

  • My MAX1555's arrived in the mail. I've got one soldered into the prototype area, but I was looking over the spec sheet...

    They cap USB charging at 100ma (as that's the cap on USB power, unless the device asks for the full 500ma). Does the Espruino ask for full power? I assume it does - if so, maybe I should connect to pin 4 (DC) instead of pin 1 (USB), that way it'll charge at 280ma.

    Also, I may put a mosfet between the USB in and the MAX1555, so I can turn charging on and off with a GPIO pin. I'm only now starting to appreciate that SMT prototyping area...

    Ooo... maybe I could wire the gate of the mosfet to the CHG pin (with a pullup and filter cap, ofc), and then I could pulse the pin low to initiate charging... and then the CHG pin would keep it low until it was done charging, then turn off the charger...

  • Espruino doesn't request the full 500mA - but in reality there is no need. While the idea was that power would be limited, I think in reality basically all computers just connect USB 5v direct to the computer's 5v rail (perhaps with a thermal fuse) so you can actually draw at least 500mAh without problems.

  • I wired it up to my "victim" espruino, and it seems to work.

    There's just one problem... The espruino doesn't actually work off of the battery (which is putting out 3.8-3.9v - it's a lithium cell). The espruino freezes the moment it's disconnected from power. I disconnected the MAX1555 (I had it connected via jumpers), and confirmed that this behavior was the same without that.

    The moment it tries to run off the battery, it freezes. I did a simple blink demo, and sure enough, the moment USB came off, it stopped blinking (but the light stayed on). But the battery voltage is 3.8~3.9 (the MAX1555 slows down charging past that), which should be enough to keep the Espruino alive. Gordon - any thoughts?

  • That's strange - what's the voltage on the 3.3v rail when you're running off the battery? Does anything happen when you plug USB in again?

    I do that pretty much every day though - Lithium cell connected via the battery connector, do something and then unplug USB. It always seems to work well for me...

  • I'll check 3.3 rail tonight. When plugging it in after having had it on battery, I can connect, but that's it - nothing I type does anything until I reset the espruino.

    Problem sorted, nothing to do with the battery stuff, except that I happened to do a lousy job of installing it.

    The key was when I tried connecting over the bluetooth links, and discovered that I could connect to bluetooth, but it endlessly complained about syntax errors. A brief investigation found a solder bridge between UART_RX and UART_TX on the HC-05 (I'd been working in that area), and fixing that has solved the problem.

    Seems to be working fine, and battery voltage is falling very slowly, as expected (measured by dividing VBAT with a pair of 10k resistors and running that to an ADC input)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Add battery charger circuit

Posted by Avatar for aerialist_user6911 @aerialist_user6911

Actions