Determining charged and charging on custom board with nrf5340

I'm still new to this but particularly in regards to battery. I have a custom board with a nrf5340 and have been working on reading the voltage. I used the battery sample for testing, which seems to be working, though I'm not sure I have it configured correctly and need to determine if the readings are what I should expect I wanted to understand how to deal with the other two pins for charging and charged as I don't see reference to them in the battery sample. Here are the pins:

  • P0.04 - BatADC - Battery Voltage divided to 7.666
  • P0.05 - ChargingADC - to see if charging while 5V connected
  • P0.06 - ChargedADC - to see if charger standby while 5V connected

I am using a voltage divider, btw.

How do I determine if the battery is charged or charging? Do I use ADC or GPIO?

I'm using 2.9.1 at the moment.

Parents
  • Your application can measure the battery voltage on P0.04 using the SAADC exactly as in the Zephyr battery sample. Your external divider scales the pack voltage down into the ADC range; after sampling, we multiply by 7.666 to recover the real battery voltage in millivolts.

    For charging status your application can tread the charger IC’s two pins, CHG and STAT as digital signals rather than analog inputs.The CHG pin lights up whenever your charger is actually pumping current into the battery. The STAT pin becomes on once the battery is full or the charger has gone idle. You just need to connect CHG to P0.05 and STAT to P0.06 on the nRF5340, add a pull-up to 3.3 V and set them up as normal digital inputs.

    In firmware, every sampling loop (e.g. once per 5 s):

    Read the SAADC channel on P0.04, convert the raw sample to millivolts (applying the divider ratio), and report “Battery: X mV.”
    Read P0.05 and P0.06 as digital inputs:

    If CHG is asserted, print “Charger: CHARGING.” Else if STAT is asserted, print “Charger: FULL/STANDBY.” Otherwise, print “Charger: NO POWER.”

    This way you keep your SAADC pipeline focused on the analog battery voltage.
    Use straightforward HIGH/LOW GPIO reads (and interrupts, if you like) for charger events.
    Avoid extra dividers or calibration on the CHG/STAT lines, since they’re inherently digital.
    You’ll need only minimal Zephyr DT overlays (to bind the two GPIOs) and standard gpio_pin_get() calls alongside your existing ADC setup.

Reply
  • Your application can measure the battery voltage on P0.04 using the SAADC exactly as in the Zephyr battery sample. Your external divider scales the pack voltage down into the ADC range; after sampling, we multiply by 7.666 to recover the real battery voltage in millivolts.

    For charging status your application can tread the charger IC’s two pins, CHG and STAT as digital signals rather than analog inputs.The CHG pin lights up whenever your charger is actually pumping current into the battery. The STAT pin becomes on once the battery is full or the charger has gone idle. You just need to connect CHG to P0.05 and STAT to P0.06 on the nRF5340, add a pull-up to 3.3 V and set them up as normal digital inputs.

    In firmware, every sampling loop (e.g. once per 5 s):

    Read the SAADC channel on P0.04, convert the raw sample to millivolts (applying the divider ratio), and report “Battery: X mV.”
    Read P0.05 and P0.06 as digital inputs:

    If CHG is asserted, print “Charger: CHARGING.” Else if STAT is asserted, print “Charger: FULL/STANDBY.” Otherwise, print “Charger: NO POWER.”

    This way you keep your SAADC pipeline focused on the analog battery voltage.
    Use straightforward HIGH/LOW GPIO reads (and interrupts, if you like) for charger events.
    Avoid extra dividers or calibration on the CHG/STAT lines, since they’re inherently digital.
    You’ll need only minimal Zephyr DT overlays (to bind the two GPIOs) and standard gpio_pin_get() calls alongside your existing ADC setup.

Children
No Data
Related