Simple sample for measuring coin cell battery voltage with Zephyr and nRF52840

My project uses Zephyr and the nRF52840 with a CR2450 coin cell battery. All is working well, and now I am looking to add in battery level. I've downloaded and read the following samples.

zephyr/samples/boards/nrf/battery
zephyr/samples/drivers/adc

These samples seem to focus on particular hardware (like the Thingy) that use lithium batteries, and so they have a /vbatt voltage divider to bring the voltage down to a range the nRF52840 can read. There are some ifdef and devicetree mechanisms that imply they could work without a voltage divider, but I'm getting confused by the samples.

My board is powered directly by the CR2450, and so I believe I don't need a voltage divider. My board also has P0.02/AIN0 directly connected to the coin cell (3.3V nominal) in anticipation of using this pin for reading the voltage.

If I could read the voltage, I'll do the math to determine battery level.

My questions are as follows.

- From parts of the samples, I'm guessing that the nRF52840 has an internal way to measure VDD. (See "zephyr,input-positive = <NRF_SAADC_VDD>;" in the nRF52840DK devicetree overlay in the "add" sample.) Is this true? If so, how do I access it?

- If the above is not true, could my connection between P0.02/AIN0 and the coin cell be used to measure its voltage?

- Is there a sample, or some guidance within an existing sample, that you can give me to make this clearer?

Thanks,

Steve

Parents Reply Children
No Data
Related