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 sorry for the late reply. We are vert short staffed during Easter Holidays, so I will have to see whether I can either get time to test this myself (with my limited nRF91 knowledge), or if I can find anyone else who can test it and try to reproduce what you are seeing. 

      Just wanted to let you know that this case is not forgotten. I will get back to you as soon as I can.

      Best regards,

      Edvin

    Reply
    • Hello,

      I am sorry for the late reply. We are vert short staffed during Easter Holidays, so I will have to see whether I can either get time to test this myself (with my limited nRF91 knowledge), or if I can find anyone else who can test it and try to reproduce what you are seeing. 

      Just wanted to let you know that this case is not forgotten. I will get back to you as soon as I can.

      Best regards,

      Edvin

    Children
    • Any luck here?

    • Hello,

      Sorry for the late reply. It was a bit much to do the week after Easter. 

      I tried to build your project, but I got a lot of build errors. 

      Where did you find the sample with the vbatt module? And what board do you build it for? And does it need to be built from some specific location? Can you try to build it in an unmodified SDK to check that you didn't change any SDK files that are outside the project folder?

      Best regards,

      Edvin

    • Edit:
      I added the an overlay file with the vbatt structure that you mentioned in your original post, and then it compiled. I'll continue working on this. 

    • The sample came from zephyr/samples/boards/nrf/battery and as you have already figured out, you need to add the necessary overlay.

    • Hello,

      Can you please specify what you mean by changing VDD from 1.8 to 3.6V? Do you mean toggling the switch on the DK, or do you do this from SW? Are you using a standard DK?

      BR,

      Edvin