Read voltage pins on Arduino Nano 33 BLE

Context for project: Developing a wearable device using the Arduino Nano 33 BLE and I intend to transmit the battery level as a part of the bluetooth payload. It is powered by a 3.7V LiPo battery, and needs to be relatively low-power.

How can I measure the battery level in a connected LiPo battery? Can I read the voltage of the power line and use that and the expected voltage curve to find how much it has discharged, or should I connect the power line with one of the analog pins that I can read?

Any tips or resources would be appreciated :slight_smile:

Welcome to the forum.

You need to use a voltage divider to get the maximum voltage of the battery just below the maximum voltage of the ADC.

When you design the voltage divider you need to look at the requirements of the ADC. Have a look at the nRF52840 datasheet (see Arduino store under TECH SPECS).

  • Section 6.23.10 SAADC Electrical specification

  • Section 6.23.1 Acquisition time

The datasheet says for the slowest acquisition time the source resistance must be smaller than 800kOhm. So, this is the resistor from Vcc to the ADC pin. Now use the maximum voltage of your battery, the maximum voltage at the pin (3.3V), the resistor you picked and then calculate the second resistor.

You will need to change the analogRead library to change the setting for the ADC acquisition time because I do not think there is a function for that.

If that is not an option, you can use smaller resistor (see datasheet) but this will increase the current trough the divider or alternatively you can add a buffer capacitor parallel to the second resistor e.g. between the ADC pin and ground.

The size of the capacitor depends on the resolution you want and the sampling capacitor. e.g., 10 bits = 1024 values, you want 1/2LSB so the capacity of the external capacitor should be more than 2048 times the sampling C (2.5pF for the nRF52840 see datasheet).

Just in case you need to remind yourself:


Thanks Klaus, that was a really good explanation.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.