Introduction
I have been working on an upcoming project for over a year now. This upcoming project contains two Samsung 30Q 18650 batteries wired in series as a 2S1P configuration. I was previously estimating the battery percentage using a voltage divider connected to an ADC pin on my Xiao nRF52840 microcontroller. For the first couple months, it seemed like a solution that worked, up until I began having the reported battery percentage go up and down. This was strange behaviour, but it was entirely down to the super minimal method I was using for estimating the battery percentage.
I made it more complex by constructing a battery OCV–SOC curve map using the HPPC Dataset 2 obtained from a laboratory on GitHub (link) for these exact batteries. I built simulated tests to run against my curve maps and optimised them to better suit the operating conditions. I also implemented a smoothing algorithm to smooth out the voltage reading from my samples to prevent spikes and jumping readings. Unfortunately, with all the graphing and smoothing, the issue remained. The battery percentage kept jumping around. Turns out, reading only the battery voltage isn't enough to accurately predict the battery capacity. You also need to monitor all energy leaving and entering the batteries using a current sense resistor, this can provide a very accurate capacity prediction when paired with a well designed algorithm.
Here's some images from the simulations I performed.




To take it even further, there are integrated circuits like the MAX17261 from Analog Devices. This IC is an ultra-low-power fuel gauge and it uses the ModelGauge m5 EZ algorithm to estimate the mAh and state of charge. Instead of relying on the Xiao nRF52840 to record and estimate the batteries state of charge and remaining mAh, this little chip does it all for me. No more messing around with OCV-SOC curve maps, smoothing algorithms, and data sampling methods.
The Design
My PCB design is extremely basic.

This is my first time designing a PCB and using KiCad, so it may be messy and not to standard. Mind that, I am still learning and developing my skills. Anyways, this circuit has the MAX17261 chip as U1 in the centre. On the left of U1, we have the voltage divider circuit. This circuit contains the resistors with values 499k (R4), 300k (R3) and 200k (R2) which are used to drop the voltage down to a level the MAX17261 CELLX pin can measure without blowing up. Between R3 and R2 we have the mosfet BSS138K labelled as Q1 which prevents the voltage divider circuit from unnecessarily draining the battery. If you're wondering how much power it would consume without the mosfet, here's the answer:
I = 8.4V / (499k+300k+200k)
= 0.00840840841 mAThat's 8.4 µA of continuous current, around 0.20 mAh each day. Barely anything, but for a battery-powered device, every single mAh matters and minimising idle consumption is one of the top priorities.
On the right side of U1 we have the resistors R6 and R7 which are both 4.7k. These are used as pull-up resistors which connect SCL (clock) and SDA (data) lines to 3.3V. I²C devices pull these lines low when communicating, so these resistors bring them back HIGH when the device communicating over the lines releases them, rather than leaving them floating. If we left these communication lines floating when released, it would cause issues like corrupted data, false clock pulses, failed communication, and increased power consumption. By maintaining defined HIGH and LOW states, the pull-up resistors help ensure reliable communication.
At the top of U1 we have the capacitors C1 and C2, these are part of the recommended external circuitry. C1 is a decoupling or bypass capacitor which is used to stabilise the voltage supplied to the MAX17261 IC. If there was a brief voltage dip or some electrical noise, C1 will release some of its stored energy to help smooth out those fluctuations. And C2 is the internal regulator capacitor. The MAX17261 has its own 1.8V internal regulator which is exposed through the REG pin. This capacitor stabilises the internal regulator to keep supply to the chips internal electronics clean and consistent.
On the bottom left we have R1 which is a 10 mΩ shunt resistor. This shunt is rated for a max of around 1W, giving it a theoretical continuous current limit of around 10A under its rated operating conditions. I measured the start-up and stall currents of the motor used in my project and recorded a max of 2.5A. At this current, the shunt only dissipates around 0.063W which is well below its 1W rating.
This shunt resistor sits in series with the batteries negative connection. Any current flowing through it creates a tiny voltage difference. The MAX17261 measures the voltage difference using its CSN and CSP pins, allowing it to calculate how much current is flowing into or out of the battery. By monitoring this current over time, the chip can track how much charge the battery has lost or gained helping it calculate the battery's state of charge. This comes back to what I mentioned in the introduction when I pointed out the issue with my previous state of charge prediction method.
And finally, we have R5 on the very left side. This resistor is a pull-down resistor for Q1's gate which is controlled by the MAX17261 SW pin. When the MAX17261 isn't actively driving that pin, R5 keeps the gate LOW rather than allowing it to float. If we left it floating, Q1 may unintentionally switch on and draw current through the voltage divider which would defeat the entire purpose of the mosfet.
After designing the schematic, I laid out all the components and ran the traces on the 2-layer PCB.

Manufacturing & Assembly
I got this PCB manufactured by JLCPCB with a stencil for $14 after having coupons applied. Basically just paid for the shipping. The minimum order is 5 boards, so I was going to order 5 lots of components to populate each of those boards. I was going to get JLCPCB to assemble the boards for me, but unfortunately, the MAX17261 was not in stock. I went to DigiKey and attempted to order them from there, but was told that I am not allowed to order them due to restrictions from Analog Devices. I then discovered Element14 which had all my components in stock and when I submitted my order, there were no restrictions and I received all the components a few days later. The total price for all the components from Element14 was $70 AUD.
To assemble these PCBs, I needed a way to hold the stencil in the dead centre of the PCB without it shifting or lifting as I applied the solder paste. I ended up designing a holder for the PCB and stencil with cutouts to make removal easy and then 3D printing it. At first, I applied solder paste around 10 or so times and each time I failed. I found a forum discussing how to apply solder paste and one of the methods was to pass over the surface once rather than multiple times. That was it, a single pass worked sufficiently. Every now and then I had to make a small touch up, but other than that, it went rather smoothly after my initial failed attempts. The holder for the stencil and PCB made repeating the assembly extremely easy without any alignment issues at all. After placing all the tiny components, I then had to preheat each of the PCBs and reflow them, for that, I ordered a FNIRSI hot plate which basically did all the work for me with the heat and reflow modes. Just placed one board at a time on the hot plate, heated it to 100˚C left it there for around 60 seconds, then changed to the reflow mode where it slowly increased the temp in increments to 235˚C to then let it cool down to around 40˚C.




Testing the Boards
Once the boards were complete, I conducted electrical checks before connecting them to power and before connecting my 2S1P battery. Very important to do electrical checks prior to make sure there's no short circuits or design issues. Very strangely, all 5 of my boards passed and the final step was to check if the MAX17261 chip on each of the boards could function correctly. I created a test circuit with the 2S1P battery configuration, BMS, CC/CV charger, an LED strip and a Xiao nRF52840. Loaded a ZephyrOS template that I use for my embedded projects, adjusted the device overlay to enable the Xiaos I²C controller and wrote firmware for communicating with the MAX17261 and logging the output to the debugger.
The MAX17261 has a few register addresses such as these below:
| Register | Address | Purpose |
| STATUS | 0x00 | Battery gauge status |
| VCELL | 0x09 | Battery voltage |
| CURRENT | 0x0A | Battery current |
| DEVNAME | 0x21 | Device identification |
We first start by addressing the MAX17261 using its I²C address 0x36. We then select which register we want the data for, such as 0x09 for battery voltage. The MAX17261 will then send back two bytes containing the requested 16-bit register value. These bytes are then combined in their correct order (MAX17261 sends the least significant byte first) and the raw value is converted into a meaningful measurement using the datasheet's conversion formula.
This is the output from the the first version of my logs (before I added more data to the reading):
MAX17261 detected at 0x36
Device ID: 0x4033
Status: 0x8082
Power-on reset: YES
Voltage register: 0xC4D8
Current register: 0x0004Later after adding conversions, the logged information looked like this:
Pack voltage: 7.812 V
Current: -0.625 mA
State of charge: 68.63%
Remaining capacity: 2059 mAh
Temperature: 21.726°C
Valid samples: 81
Failed reads: 0
Resets: 0At this point, I was happy with the output and moved onto testing the remaining 4 boards. All passed my checks and each board could successfully read the voltage difference from the shunt resistor.
Pinout

| PACK- | Connect to the negative output of your BMS |
| SYS- | The negative power supply for your entire circuit (including CC/CV charger) |
| BAT+ | Connect to the positive output of your BMS |
| 3v3 | From your 3v3 rail or microcontroller 3v3, either way, the MAX17261 and microcontroller must share this same rail. |
| GND | Connect to the same GND used to power the microcontroller, the system GND. |
| SCL | This pin goes to the SCL pin on your microcontroller (D5 for Xiao nRF52840 and nRF54L15) |
| SDA | This pin goes to the SDA pin on your microcontroller (D4 for Xiao nRF52840 and nRF54L15) |
Conclusion
This PCB was my first PCB and I am very happy with the outcome. I will have to design a new version in the future that doesn't use the MAX17261 due to the purchasing restrictions, but until then, these boards will be sufficient for my projects.
Licence
Open Community License v1.1 + GAtt v1 + Micro v1
OCL v1.1 + GAtt v1 + Micro v1
Adds creator attribution to OCL v1.1 and limits business use to organisations whose combined annual gross revenue, including affiliates, does not exceed EUR 1,000,000 without a separate licence.
This is a practical summary, not legal advice. The linked licence text controls.