Nrf9160: Battery ADC measurement off by ~100 mv

I'm getting a strange amount of error when trying to measure the battery for a custom PCB based on the nrf9160.

Details

  • My VCC_IO is 1.8V
  • My max battery voltage is 4.2V
  • I am using a slightly modified version of the battery sample from zephyr/samples/boards/nrf/battery.
    • I'm using a switch controlled voltage divider, where R1 is 3.01k and R2 is 2.0k

    • I am measuring the analog levels on adc line, the battery voltage going into the divider, and the battery voltage going into the switch.

    • I am using the internal reference of 600 mv.
    • I am using ADC_GAIN_1_3 
      • 600mv * 3 = 1800 mv (Within VCC_IO + 300 mv)
      • An analog value of 145 mv should result in a value of around 3630 mv to be reported from the device.
    • The device is reporting battery voltage of ~3570 mv. 

     This isn't necessarily useful information, but I have another custom PCB with an almost identical measurement circuit but VCC_IO is 3.0V. The device always reports an acceptable value.

    Am I missing something here?

    Parents
    • Hello,

      I am a bit confused regarding what I am looking at.

      An analog value of 145 mv should result in a value of around 3630 mv to be reported from the device.

      Is this a typo? 145mV should be 145mV*3*(5/2) = 1087mV, right?

      Can you please explain to me what your input value is (what you are measuring), and please try to measure the voltage on the ADC GPIO. What is that compared to what you are reading out from your ADC?

      Best regards,

      Edvin

    Reply
    • Hello,

      I am a bit confused regarding what I am looking at.

      An analog value of 145 mv should result in a value of around 3630 mv to be reported from the device.

      Is this a typo? 145mV should be 145mV*3*(5/2) = 1087mV, right?

      Can you please explain to me what your input value is (what you are measuring), and please try to measure the voltage on the ADC GPIO. What is that compared to what you are reading out from your ADC?

      Best regards,

      Edvin

    Children
    • Sorry for the confusion, let me try again. There was a typo: 145 mv should actually be 1450 mv. Here are some new measurements from today:

      • The voltage I'm trying to measure is 3634 mv.
      • The ADC GPIO voltage going into the nrf9160 is measuring 1442 mv.
      • The ADC readout from adc_raw_to_millivolts() is 1409 mv.
      • This results in the measured voltage to be 3529 mv (Off by 105 mv)
    • Hello,

      Since I see that you have an oscilloscope, do you see a dip in the voltage measured on the pin when you try to read out the voltage using the nRF9160? 

      And you say that the issue is not present when you use the VDD_IO = 3.0V, is that correct?

      sheldon_b said:
      The ADC readout from adc_raw_to_millivolts() is 1409 mv.

      What does this event look like, and what are the corresponding parameters?

      sheldon_b said:
      This results in the measured voltage to be 3529 mv

      That is 1409 * 5010 ohm/2000 ohm, right? What accuracy do you have on your R1 and R2? Did you measure them yourself? 

      I am not familiar with the details, but where did you find the vbatt config? Is that from the thingy52 sample?

      Is it possible to zip the project so that I can have a look?

      Best regards,

      Edvin

    • Edvin, 

      Thanks for getting back to me, sorry for the delay.

      I haven't seen any dips in the battery voltage when a measurement takes place. I will run tests again to verify.

      My 3.0V variant board is working as expected. I just measured a battery to be 4.098V with my DMM and the nrf9160 reports the voltage as 4.102V. 

      The resistors are 0.1% tolerance. I removed them from the board and measured their resistances. Note they are 0402, so my probing was a little wobbly and I only used Ω2W.

      • Spec 2000 Ohm = Measured ~1996 Ohm
      • Spec 3010 Ohm = Measured ~3005 Ohm

      My battery measurement logic came from the following sample app: zephyr/samples/boards/nrf/battery. If you are referring to the device tree node, that came from the readme of that sample. 

      I would be happy to share my project. I'm currently using my production application to run these tests (which I cannot share publicly). I will try to replicate this behavior on the battery sample app and share it. 

      New Discovery: The nrf9160 has the ability to measure the battery voltage internally. I typically don't use this feature because it first requires initializing the modem which uses more energy for my use case. Anyway, I put the device in a loop that measures the battery with my circuit and the internal circuit. The internal circuit was measuring the battery voltage with better accuracy. 

      1. Internal: 4109 [mv]
      2. External: 3972 [mv]
      3. Actual: 4088 [mv]
    • Hello,

      Is there some way for me to reproduce this? Can you please send me the application that you are using to test? I don't have the exact voltage divider that you are using, but I can use a generator to generate the desired input voltage.

      BR,

      Edvin

    Related