mangoOH Red LTC2942 r_sense value

I am trying to get the battery charge sensor working on my Red (with a WP7702).

I have two questions:

  1. Do I need to do something like charge the battery completely and then tell it what the battery capacity is by writing /sys/devices/78b8000.i2c/i2c-4/i2c-6/6-0064/power_supply/LTC2942/charge_now? I suspect I do, but I’m not finding documentation on that either here or in general for Linux.

  2. More confusing than #1: The Linux code, which matches the LTC2942 datasheet, uses the value of r_sense in several computations. The units for r_sense in the comments say “mOhms” (this is in mangOH/linux_kernel_modules/ltc294x/ltc2941-battery-gauge.c:71). However, the value set in linux_kernel_modules/mangoh/mangoh_red.c:169 is “18”. The schematic says R828, which I believe is Rsense, is a 68mOhm resistor. Shouldn’t mango_red.c use 68, not 18?

  1. did you read the battery service on github? It explains what is being done. You set the battery capacity in the admin api. Then after the first charge is complete, the system is able to assign that capacity to the charged battery.
  2. Thanks for pointing this. The schematic was released before we did production. The final populated value is 18mohm. We will update the schematic.

Great - thanks for the clarification on #2. As for the battery service, there isn’t a lot of documentation on it. I’ll dig through the code and see what it’s doing. Are there prewritten commands that talk to that admin API or do I write them (obviously not too hard to write them), but if it’s already done…

you mean a sample app for the battery service?