The XIAO nRF52840 is equipped with a battery charging circuit and a battery voltage reading circuit. To read the battery voltage while charging or discharging, set P0.14 (VBAT_ENABLE) LOW to divide the voltage by about 1/3 and connect it to P0.31 (PIN_VBAT) on the ADC input. The voltage divider circuit consumes about 2.3 uA, so in applications where I want to minimize the sleep current, set P0.14 HIGH after reading the battery voltage to reduce the current.
SleepCurrent_VbatEnable.zip (1.8 KB)
However, the wiki contains the following statement.
Q3: What are the considerations when using XIAO nRF52840 (Sense) for battery charging?
A3: When P0.14 (D14) turns off the ADC function at a high level of 3.3V, P0.31 will be at the input voltage limit of 3.6V. There is a risk of burning out the P0.31 pin.
Currently for this issue, we recommend that users do not turn off the ADC function of P0.14 (D14) or set P0.14 (D14) to high during battery charging.
This precaution is SEEED’s view to prevent from failure and should be respected when integrating XIAO into a product.
Since my application is a hobby and I want to minimize the sleep current, I have considered the risk of setting P0.14 to HIGH.
The battery terminal VBAT reaches a maximum of 4.2 V not only when the battery is charged, but also when a fully charged battery is connected even if it is not charged. If P0.14 is driven HIGH at this time, P0.31 will be 3.604V with a voltage divider circuit of 1MΩ and 510kΩ, and there would be a risk of exceeding VDD+0.3=3.6V. However, IO ports usually have a protection diode that clamps the voltage to VDD+0.3V even if a voltage exceeding VDD is applied. If the diode can handle a current limited by a 1MΩ resistor, it is unlikely that P0.31 will burn out.
Since P0.14 and P0.31 are under the metal case and not directly accessible, I used D5 (instead of P0.14) and D0 (instead of P0.31), connected 1MΩ and 510kΩ voltage divider circuits externally, and measured voltage and current. PPK2 was used in place of the battery and measurements were taken up to 4.4V, 0.2V higher than the battery voltage.
Actual measurement shows that the resistors of the voltage divider circuit are 999kΩ and 508kΩ, and the VDD voltage is 3.277V.
When 4.2V, which is the maximum battery voltage, is applied, the voltage at D0/P0.31 has a margin of more than 100mV to VDD+0.3V.
Also, since the current is limited by 999kΩ, the current flowing into D0/P0.31 is 250nA, and although I do not know the long-term reliability, I suspect that the protection diode will not burn out.
Based on the above results, I want to minimize the sleep current, so I drive P0.14 to HIGH at my own risk, and I have used 6 XIAOs and have not experienced any particular problem so far.
If you decide to implement the same after reading this post, do so at your own risk.