iPhone Battery Charger / Tester Breakout and HDQ Gas Gauge Stats

Troubleshooting iPhone problems can be a daunting task sometimes considering how complicated they are. It’s easy to overlook the simple things and on occasion you may replace parts that don’t need replacing. Batteries are no exception. I have seen technicians often replace batteries when they may not necessarily need to be or ignore the fact that they could be the cause of the issue at hand. To remedy this I designed a basic iPhone battery charging breakout board system. The system can charge a battery, has the option for expansion to support newer/other batteries and breaks out the battery status pins which can be read from a microcontroller or some other means. It consists of 6 battery connector boards (iPhone 4, 4S, 5, 5S/C, 6, 6+) and a main charging board.

Use Cases

Sometimes a battery will show no voltage when tested with a multimeter. It is possible that the LiPo cell is in fact completely dead although this typically means the battery has gone into protection mode. This can be caused by various reasons including liquid damage short, over voltage/current lockout and under voltage lockout. My battery system can revive or re-activate a battery that has entered protection mode by simply connecting it to the main charging board.

From time to time I will get a phone in for repair with a (very) low battery and will not boot up because of that fact. The repair may be as simple as a screen replacement. With this battery system you can leave the battery in the case and connect it to the charger while you move the home button, front sensor flex to the new screen. You could even create a short extension cable from the battery board to the mainboard.

As a technician I have a set of test parts for the various common phones I repair. The batteries do not usually get a full charge during the testing process. With this system you can charge your test batteries without the need for an actual phone.

Battery Boards

A single battery board can be connected to the mainboard at a time. Battery boards connect to the mainboard via 6 pin header with 1 pin missing (keyed to prevent incorrect connection). Not all the pins are needed for every battery. For example, the 4, 4S and 5 batteries have NTC thermistor pins but newer iPhones do not and thus are not connected. All 5 pins are routed to a header on the mainboard for easy access. The purpose of the separated battery boards is to allow for additional (new) connectors. I have not yet ordered any iPhone 6S series battery connectors so I do not have boards designed for them. I have, however, designed some for other devices that worked with older revisions of this battery system. I may consider adding additional battery boards in the future (6S, 6S+, Samsung, etc).

Mainboard

The mainboard contains the charging circuitry, a MicroUSB power input port and 2.54mm header pins. The MCP73831 LiPo charging IC was chosen for it’s low part count and cost. It is designed for 3.7V nominal voltage batteries but can also be used to charge higher voltage batteries. Newer batteries are 3.8V nominal voltage and will not charge completely since the cutoff is 4.2V. Regardless, you can charge a dead 3.8V nominal battery to a usable state. Two LEDs provide charging status; red for charging and green for charged (or your colors of choice). If no battery is connected the charged LED will be lit. There is a 2A fuse for input over current protection from the MicroUSB port. The program resistor (R2) determines the maximum charge current. I chose 2K which provides the MCP73831 maximum of 500mA charge current. These are the pins available on the breakout header:

  • VBAT: Connected directly to the battery positive pin (and charging output of the MCP73831)
  • GND: Ground
  • 5V: 5V input from MicroUSB
  • GAS: Battery gas/fuel gauge pin. iPhone’s use TI HDQ protocol
  • NTC: Battery thermistor pin
  • STAT: Connected to MCP73831 status pin. Can be used to read charging status from microcontroller
  • PROG: Connected to MCP73831 program pin. Can be used to set charging current or disable charging from microcontroller

Part List

RefDes Specs Part #
PCB 2 layer Order from OSH Park
C1 4.7uF 6.3V 0603 -
C2 4.7uF 6.3V 0603 -
F1 32VDC 2A Fuse 0603 -
R1 1K ohm 0603 -
R2 2K ohm 0603 -
R3 1K ohm 0603 -
U1 MCP73831
SOT23-5
MCP73831T-2DCI/OT
LEDCHGD Green 0603 -
LEDCHG Red 0603 -
USB1 Amphenol/FCI
MicroUSB
10118194-0001LF
Batt Board Header 2.54mm Straight male -
Mainboard Batt Header 2.54mm Right
angle female
-
Plug for
Female Header
(fills NC pin on
mainboard battery header)
15-04-0292
iPhone Battery
Connectors
- eBay

All the parts should be available from most of the major distributors (Digikey, Mouser, Newark/Farnell) except the battery connectors. Apple does not sell parts so your only option for the connectors is to get aftermarket parts. They are easily found on eBay or Aliexpress. After soldering the header pins on the battery connectors, remove the single pin without a solder pad using pliers. On the mainboard, plug up the “NC” pin hole header with the plug linked above. This allows the battery board to connect in one direction only and prevents short circuits.

HDQ Battery Stats

iPhone batteries use TI’s HDQ 1 wire protocol for communicating statistics to the phone. Some useful information such as Temperature, Remaining Capacity, Charge Cycle Count and more can be read out from the battery. The various iPhone batteries use different models of TI fuel gauge IC’s and Jason’s RipItApart blog has a cumulative list of them. He has a wealth of information regarding iPhone batteries and the HDQ Protocol including a utility for communicating with them.

I wrote a very basic Arduino sketch that prints out some battery stats over serial. My example sketch was tested on the Arduino Nano but should be compatible with any of the common Arduino boards. First, install the HDQLib into your Arduino IDE. Connect the GND pin to Arduino ground. Connect the GAS pin to Arduino pin 7. Use a 4.7k-10k pull-up resistor from Arduino pin 7 (or from GAS pin) to 5V. Connect the Arduino to your computer and upload the compiled sketch. Open the Arduino serial monitor and set the baud rate to 57600. The sketch attempts to detect which iPhone battery is connected based on the chip detected and the firmware version and will display some battery stats similar to:

iPhone 5S / 5C Battery Detected
Device: bq27545
Firmware: v3.10
Hardware: 0xA7
Remaining Capacity: 482 mAH
Full Charge Capacity: 971 mAH
Design Capacity: 1430 mAH
Time to empty: N/A, not discharging
Time to full: 0 minutes
State of Charge: 50%
Battery Voltage: 3.90V (3904mV)
Temperature: 29.00*C / 85.28*F / 3026 raw
Charge Cycle Count: 1138 times

Older Revisions

This is my first post specific to my battery charging board(s). There was a brief mention about an older version in my post Troubleshooting & Reviving Single Cell Batteries. The first version was made back in January 2015 and at the time there was no product on the market for testing iPhone batteries that I could find, hence I built my own. A search today found a few products made in China, here and here, that are similar to my system but contain all the battery connectors on a single board. I won’t go into detail about my older versions, but here you can see the progression in pictures.

v1 v2 v2.2

If you have any ideas or recommendations for this board, please leave a comment below.

15 comments

  1. Hi mozzwald,

    I would like to know if you have breakout board for iPhone 6S/6S+ battery. If so, how can I order these? How much?

    — Veni Rigel Ballesteros Sun, 28 Aug 2016

  2. @Veni, I have not made breakouts for the 6S series yet. If I ever get the opportunity I will add them to this post and link to the oshpark project.

    mozzwald Mon, 29 Aug 2016

  3. Hi mozzwald,

    Thanks for the prompt reply, I would like to have your project improved to a 1A charger if possible. I have the MCP73833 in mind.

    — Veni Rigel Ballesteros Mon, 29 Aug 2016

  4. @Veni, The MCP73833 looks like a good replacement for the MCP73831. It would require a redesign of the main Lipo board to incorporate the IC's extra pins and the new IC's footprint. I like the DFN10 package since it has a thermal pad.

    mozzwald Tue, 30 Aug 2016

  5. Hey mozzwald,

    I'm trying to get library and sketch to work on arduino mega, but i can't get any readings. It work perfect on Uno. Do you have any ideas?

    Thx, Radu

    — Radu Wed, 21 Sep 2016

  6. @Radu,

    Looks like the HDQ library was written specifically for the atmega328 chip and the Arduino Mega uses atmega2560. I've never used the Arduino Mega boards so I can't be of much help (and I didn't write the library). Some quick searching leads me to believe the library will need to be modified to support the atmega2560 ports/timers/bitmask (http://forum.arduino.cc/index.php?topic=133439.10). The folks in the arduino forum can probably provide some better tips or try getting a hold of the library author (https://matth.lalonde.me/). If you do get it working, please let me know and I can update the library for others to use.

    mozzwald Wed, 21 Sep 2016

  7. Hello.

    How I can to buy the boards?

    — Ronaldo Wed, 21 Sep 2016

  8. @Ronaldo,

    You can buy the bare board from OSH Park at https://oshpark.com/shared_projects/EaKHhvnp and the other parts from the links provided in the post (assembly required).

    I am not selling assembled boards at this time.

    mozzwald Wed, 21 Sep 2016

  9. Dear mozzwald
    I got new iPhone 5S battery.
    But battery pcm(protect circuit module) is not working well
    So I took off and replaced original pcm from my old iPhone battery to the new battery
    New iPhone battery is 3.9v but original pcm output is almost 0v.

    new battery
    +-------+ +-----+ +--------+
    | 3.9v |-->| pcm | -> | iphone | -> 0v
    +-------+ +-----+ +--------+
    original pcm

    How to activate original pcm with new battery?
    original pcm is protection lock when it takes off original battery?
    If protection lock in pcm how to unlock?

    YB Sun, 11 Dec 2016

  10. Is it possible to revive my battery with this product below?

    https://www.aliexpress.com/item/2016-New-Battery-Charge-Activation-Circuit-Board-Cable-for-iPhone-4-4S-5-5C-5S-6/32737484791.html

    YB Sun, 11 Dec 2016

  11. @YB: I haven't actually tried swapping the battery gauge board from one to another so I don't know for sure how to 'reactivate' the battery gauge. Have you tried to just charge the battery normally? I have been able to "jump start" batteries in protection mode by applying ~4V to the pcb power pin.

    @Lane: I don't make/sell the boards assembled. You can purchase the boards and parts to build your own if you like.

    @uğur Kırçıl: I have not delved into changing the battery gauge settings at all. You would need the unseal key to unlock the flash for programming. Jason's RipItApart blog (https://ripitapart.com/2014/09/15/so-phone-me-maybe-a-list-of-iphone-batteries-with-gas-gauge-functionality/) has some available. The datasheet should have the proper commands to unlock and reprogram the chips.

    mozzwald Wed, 14 Dec 2016

  12. Will the order link take me to where I can buy one that is assembled?

    — Lane Tue, 13 Dec 2016

  13. Hello , i tested library and sketch , they are perfect.
    But i wonder can you add dataflash writing/reading function to sketch ? like changing cycle count or design capacity ETC.
    i been working for few days on this but i couldnt make it work.

    — uğur Kırçıl Wed, 14 Dec 2016

  14. i wrote this part for unlocking
    HDQ.write(0x0414, 0x00);
    HDQ.write(0x3672, 0x01);
    HDQ.write(0xFFFF, 0x00);
    HDQ.write(0xFFFF, 0x01);
    According to status bits it has unlocked.
    then tried to read some dataflash blocks
    HDQ.write(0x00,0x61);
    HDQ.write(0x30, 0x3e);
    delay(500);
    HDQ.write(0x11,0x3f);
    delay(500);
    int mydata= HDQ.read(0x4F);
    Serial.println(mydata);
    mydata= HDQ.read(0x53);
    Serial.println(mydata);
    but i got same or weird values even i change block or class.
    i'll keep researching...

    — uğur Kırçıl Wed, 14 Dec 2016

  15. Dear Mozzwald
    I assembled real iphone5S and connected usb cable with power.
    But It was not charged.
    So I decided to buy iphone battery charger($2.68 cheap board) without iphone.
    https://www.aliexpress.com/item/Professional-Battery-Charge-Charging-Activation-Plate-Panel-Board-Suitable-for-iPhone-6-6s-6-6s/32774660296.html?spm=2114.13010608.0.0.Mp0yo1
    This product can be activate battery button on the board.
    If it is not working I took iphone 5s lipo battery to my power bank module. That is not big deal.

    YB Wed, 14 Dec 2016

Please insert the result of the arithmetical operation from the following image:

Please insert the result of the arithmetical operation from this image. =

Archives By Month

Tags