Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Battery Service reading adc value from other GPIO

Hi everyone,

I have connected a potentiometer to a GPIO pin (AIN2) and would like to show the varying values in the battery service.

I was wondering if there's any way for me to amend the battery service so that the service can read other ADC/voltage value from other GPIO pins.

Tools:

  • nRF52832
  • nRF52DK
  • nRF5_SDK_17.1.0
  • 132 softdevice

Thanks,

Zachary

  • Hi,

    Zachary16 said:
    Is there a way that I can omit the 100% and allow the DK to show the accurate value immediately after connection. 

    The sampling in your application is started by the saadc timer, you can do a sample right after a connection by calling nrf_sample() in the BLE_GAP_EVT_CONNECTED event in the ble event handler. 

    Zachary16 said:
    Thank you for sharing this link. I've watched this video hence, I've assume that the debugger will only stops if there's an error in the code. Whereas, during my trial of debug of my own code, the callstack will keep running and do not stop at the breakpoint. 

    The debugger should stop at the breakpoint. Are you sure the program reach the breakpoint? Try to output a log in the handler and see if it's printed out in the terminal. 

    regards

    Jared 

  • Hi Jared,

    The sampling in your application is started by the saadc timer, you can do a sample right after a connection by calling nrf_sample() in the BLE_GAP_EVT_CONNECTED event in the ble event handler. 

    Thank you for this advice. I no longer see 100% in the nRF Connect App.

    The debugger should stop at the breakpoint. Are you sure the program reach the breakpoint?

    Sorry if this may sound silly, but how do I tell if the program reach the breakpoint. In other program that I've run, the debugger will reach the breakpoint within seconds. Was I supposed to let it run for a couple of mins or hours?

    Regards,

    Zachary

  • Hi,

    If the program never stops at the set breakpoint within reasonable time, you can assume that the program never reaches that breakpoint. How long depends on your application, and when you start sampling. You can try to pause the program and see where it's currently at. In the code that you shared I see that you have commented out the line which starts the SAADC timer, have you remembered to include this line when you test?

    regards

    Jared 

Related