Battery Diagnostics with Espruino

Posted on
  • I'm going to test a few of these ultra high capacity batteries with espruino, I figured it would be a straightforward process of just monitoring the voltage with the ADC and for charging I would adjust the output on the DAC, but specifically for the external battery charging circuit, I've attached a picture of something I found while looking at solar panels and was curious if anybody has any additional pointers... Conceptually (as a layman), there doesn't seem like much else that would be needed... Obviously I would first try adjusting the DAC with the recommended values provided by http://www.digikey.com/en/articles/techz­one/2012/sep/a-designers-guide-to-lithiu­m-battery-charging


    1 Attachment

    • BatteryChargerCircuit.png
  • What voltage are the high capacity batteries?

    If they're the standard single cell (3.7v) ones I'd really consider just using a dedicated IC like the MAX1551/MAX1555 (in fact if you have a rev 1.4 original Espruino board, there are pads on the board where you can solder one). In reality it's probably cheaper/easier than getting a constant current and constant voltage source.

    The issue is that Espruino's ADC and DAC only handle voltages between 0 and 3.3v. When reading voltages you can just use a potential divider to step the voltage down, but for the DAC things become a lot more complicated (it also can't supply much current - so it'd take a long time to charge a battery from it).

    In terms of measuring condition, perhaps you could measure the battery voltage, and the current flowing into it (using a low value resistor between the charger's GND and battery's GND). You could then get a much better idea of how much power was going into the battery.

  • I think I'm going to be able to get around the DAC issue (thanks for the heads up).

    Conceptually I don't understand how any battery can be charged without using some beafy diode to prevent current flowing out of the positive terminal (otherwise all what would happen would be similar to adding batteries in series) but still having a complete circuit so electricity will flow at all... I don't want to use a dedicated IC, I would like to build something myself and everything I'm finding on the internet is pointing me to these IC's...

  • I'm not sure I understand you - If you're putting a higher voltage on the input to the battery then it'll charge, even without a diode. If you're leaving the charger plugged in when the charger's power is off, you may have to think about how to make it work though.

    Assuming you're charging a single cell battery, you could use two PFETs to charge the battery up:

    • One between 5v and the battery, via a resistor - this will be the 'constant current' (ish) source for charging the battery
    • One from 4.1v (maintained via a voltage regulator) - which will be the 'constant voltage' source

    You'd need to put high value resistors between the source and gate, but then as long as you use 5v tolerant pins on Espruino you can turn the PFETs on and off from Espruino. digitalWrite(pin,0) will turn them hard on, and digitalRead(pin) will make the pin open circuit, which will turn the FET off.

    Charging more than a single cell is harder, because then the voltage on the PFET's gate needs to be above 5v, and so it can't be connected straight to the Espruino. You'd then have to use a normal n channel FET to get the voltage swing you need for the PFET.

    ... but if you're using multiple cells then you also ought to think about cell balancing, as you don't want to overcharge one cell while undercharging another... and then it gets a lot more interesting!

  • Do I need a pull down resistor or something for the digitalRead(pin)? I'm getting unexpected results with this... I'm trying to read from pin B0 and B1, when I set A2 HIGH, sometimes the reading on B0 is actually effected, even when the two aren't connected... at first I thought it was the breadboard, but I tried on another and it's still not behaving as expected...

    Btw, digitalWrite is working as expected

  • If the input is floating, you always need a pullup or pulldown. Without that, reads will be unpredictable. See pinMode() in reference. But I'm not sure why it would be floating if you're measuring a voltage, unless you didn't connect the grounds....

  • See pinMode() in reference.

    Thanks :-), pinMode(B1, "input_pulldown"); did the trick

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

Battery Diagnostics with Espruino

Posted by Avatar for user52526 @user52526

Actions