0
\$\begingroup\$

I'm using a custom-made power PCB with x2 18650 Li-Ion batteries to power Arduino/Teensy and my question is: Can I get the batteries voltage over I2C / SCK, SDA / so I can monitor the batteries on my IDE serial?

IC - IP5209T - currently we only have Chinese datasheet for IP5209T but we have english for IP5209 http://www.injoinic.com/wwwroot/uploads/files/20200221/e5285ef970d502a38b9466569d9487de.pdf <--- IP5209 Datasheet

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ For that you will need to use an ADC and a bit of code. Arduino boards have pins compatible with ADC. You will have to use a resistive divider bridge between the battery voltage and the ADC pin of the Arduino board so that the voltage on the pin doesn't go above 3V3 or 5V (depending on the Arduino board) \$\endgroup\$ Dec 26, 2022 at 21:24
  • 1
    \$\begingroup\$ According to the ip5209 datasheet you can read the voltage via I2C. Reaearch m5stack_powerc for driver code. \$\endgroup\$
    – Kartman
    Dec 26, 2022 at 23:36
  • \$\begingroup\$ Hi, Arthur Chassande, according to the datasheet this IC has built in ADC : The built-in 14bit ADC in IP5209 measures battery voltage and current accurately. ADC data are available on I2C interface \$\endgroup\$
    – Svet GEoff
    Dec 27, 2022 at 3:29

1 Answer 1

1
\$\begingroup\$

Thanks to Kartman, I was able to research IP5209 datasheet more carefully and read the M5Stack_Powerc datasheet.

getBatteryLevel()

Syntax:

int8_t getBatteryLevel()

Description:

This function gets the battery level.

Function argument

No argument.

Function return value

Battery remaining percentage. 0/25/50/75/100

Returns -1 if it can not communicate with the controller.

I connected the Power PCB to Teensy 4.1 and communicate via I2C, or at least get the I2C address via I2C Scanner. The address is 0x75, next step is to try the library for m5_stack_powerc and see if I can get the numbers :)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.