# batteryService on mangOH Red

**URL:** <https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937>\
**Category:** mangOH Red\
**Created:** [November 27, 2017, 12:21pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937 "2017-11-27T12:21:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [November 27, 2017, 12:21pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/1 "2017-11-27T12:21:45Z")

</div>

Hi,

I am having trouble getting API for battery charger working. I have looked at:  
[https://github.com/mangOH/BatteryService](https://github.com/mangOH/BatteryService)  
[https://github.com/mangOH/BatteryClient](https://github.com/mangOH/BatteryClient)  
(Since batteryClient is dependent on batteryService)

There are some issues on batteryService though, I cannot find `/sys/devices/i2c-0/i2c-2/2-0064/power_supply/LTC2942` anywhere. Is this only for the Green board? If so, is there a working API available or should I configure the existing one?

Or do you even need to run anything for battery to charge on Red? Or is it enough to have a chargeable battery connected and board connected to PC for example? Thanks!

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [November 27, 2017, 10:12pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/2 "2017-11-27T22:12:06Z")

</div>

If all you want to charge the battery, then pull pin 5 of SW401 high. This will enable charging using battery charger.  
Only Single Li-Po battery supported.

Once you connect a battery, you should be able to see the LTC2942 in the /sys/device. For now, I would recommend not using the BatteryService api itself.

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [November 28, 2017, 5:35am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/3 "2017-11-28T05:35:42Z")

</div>

Hi @asyal,

Thanks for the answer! Sorry I was probably a little unclear in my question. I would like to run the board on battery (removed the jumper from CN804) and recharge battery when connected to a power source (pin 5 is on). From the docs I also understood that you can recharge using the API, but maybe it is not needed?  
And from what power source can you charge it, can you use both CF3 USB and Console USB?

Oh only Li-Po batteries are supported. I have a Li-Ion in use. Maybe this is why I cannot find LTC2942 under /sys/device. According to the batteryService API both Li-Po and Li-Ion batteries are supported, but only Li-Po for the Red I suppose?

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [November 28, 2017, 6:13am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/4 "2017-11-28T06:13:58Z")

</div>

Lithium Ion should be ok. Check the specs of bq24296 charger.

Did you plug your battery in and then see that Ltc is not detected?

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [November 28, 2017, 6:18am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/5 "2017-11-28T06:18:19Z")

</div>

Yes, could only find the paths:  
/sys/devices/i2c-0/i2c-2/2-006b/power\_supply/bq24190-charger  
/sys/devices/i2c-0/i2c-2/2-006b/power\_supply/bq24190-battery

but there is no `/sys/devices/i2c-0/i2c-2/2-0064` path available, or any other with `LTC2942`.  
Do you need jumper on CN804 for it to charge though?

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [November 28, 2017, 8:02am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/6 "2017-11-28T08:02:44Z")

</div>

Update: Charging battery works when jumper used on CN804, I just misunderstood the docs.  
But I can still not find LTC

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [November 28, 2017, 10:40am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/7 "2017-11-28T10:40:01Z")

</div>

Do you have the latest git repo?

Do you see the driver loading when you do dmesg?

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [November 29, 2017, 6:51am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/8 "2017-11-29T06:51:40Z")

</div>

Which git repo are you referring to? Legato? I have legato 17.09 installed, I guess a newer has just recently become available.

I am not exactly sure what I am looking for in dmesg, but grepped i2c and got this:

> [0.186113] unmatched machine ID in register\_i2c\_devices  
> [0.959987] swimcu\_i2c\_init: start  
> [0.963253] swimcu\_i2c\_probe: start 1  
> [0.975644] qup\_i2c qup\_i2c.0: QUP: I2C status flags :0x1343c8, irq:187  
> [0.981931] qup\_i2c qup\_i2c.0: I2C slave addr:0x3a not connected  
> [1.957881] wm8944\_i2c\_init  
> [1.957942] wm8944\_i2c\_probe  
> [1.988310] i2c-core: driver [tabla-i2c-core] using legacy suspend method  
> [1.994079] i2c-core: driver [tabla-i2c-core] using legacy resume method  
> [2.726781] i2c /dev entries driver  
> [16.177079] qup\_i2c qup\_i2c.0: QUP: I2C status flags :0x1363c8, irq:187  
> [16.182847] qup\_i2c qup\_i2c.0: I2C slave addr:0x3a not connected  
> [25.566000] i2c i2c-0: Added multiplexed i2c bus 1  
> [25.586052] i2c i2c-0: Added multiplexed i2c bus 2  
> [25.628200] i2c i2c-0: Added multiplexed i2c bus 3  
> [25.653502] i2c i2c-0: Added multiplexed i2c bus 4  
> [114.556600] qup\_i2c qup\_i2c.0: QUP: I2C status flags :0x1300c8, irq:187  
> [114.562734] qup\_i2c qup\_i2c.0: I2C slave addr:0x3a not connected  
> [928.615199] qup\_i2c qup\_i2c.0: QUP: I2C status flags :0x1300c8, irq:187  
> [928.621394] qup\_i2c qup\_i2c.0: I2C slave addr:0x3a not connected

And it just continues with 0x3a not connected.

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [November 29, 2017, 7:09am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/9 "2017-11-29T07:09:40Z")

</div>

Can show result of dmesg?

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [November 29, 2017, 7:38am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/10 "2017-11-29T07:38:30Z")

</div>

Attached a file of dmesg  
[dmesg](https://mangoh.discourse.group/uploads/short-url/hLDmLU2oRZAqWvCzjj8m8OpWtX4) (32.0 KB)

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [November 29, 2017, 10:14am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/11 "2017-11-29T10:14:48Z")

</div>

I built the .sdef file from mangOH git (mangOH\_Red.sdef), and just checked it again. Found this:

> // Disabled until Release 15 is released due to bug in power supply kernel support  
> // $MANGOH\_ROOT/apps/BatteryService/batteryService

Is there a issue on mangOH red and the PS kernel support?

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [November 29, 2017, 11:45am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/12 "2017-11-29T11:45:07Z")

</div>

There is an issue with the kernel, but it should only affect the validity of the data in sysfs. The device should still be present. Can you confirm that the mangOH Red you have says revision 5.0 on the PCB?

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [November 30, 2017, 6:49am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/13 "2017-11-30T06:49:06Z")

</div>

Yes @dfrey, it says Revision 5.0 on the PCB.  
Could it have something to do that I built it from the mangOH\_Red.sdef?

I am using a Varta Microbattery. 2030mAh, 3,7V, 7,5Wh

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [November 30, 2017, 7:32am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/14 "2017-11-30T07:32:59Z")

</div>

Does the system power up when you only connect the battery?

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [November 30, 2017, 8:16am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/15 "2017-11-30T08:16:53Z")

</div>

Yes, it powers up with only battery connected. And battery also charges.

---

<div class="post-metadata">

**Author:** ![basti](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@basti](https://mangoh.discourse.group/u/basti)\
**Post date:** [January 4, 2018, 7:39am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/16 "2018-01-04T07:39:36Z")

</div>

Hi @asyal and @dfrey,

Do you have any ideas on how to solve this. Tried now on another mangOH Red with WP8548 (same as the other) and cannot find `/sys/devices/i2c-0/i2c-2/2-0064/power_supply/LTC2942`

When installing batteryService app, and starting. I get error:

`Jan 6 17:37:24 | supervisor[3788]/supervisor T=main | app.c CreateFileLink() 1478 | Could not stat file at '/sys/devices/i2c-0/i2c-2/2-0064/power_supply/LTC2942/charge_counter'. No such file or directory Jan 6 17:37:24 | supervisor[3788]/supervisor T=main | app.c CreateFileLink() 1581 | Failed to create link at '/sys/devices/i2c-0/i2c-2/2-0064/power_supply/LTC2942/charge_counter' in app 'batteryService'.`

Again, is there perhaps something wrong with the kernel on Revision 14 firmware for this module? Thanks!

---

<div class="post-metadata">

**Author:** ![Xeset](https://avatars.discourse-cdn.com/v4/letter/x/db5fbb/32.png) [@Xeset](https://mangoh.discourse.group/u/Xeset)\
**Post date:** [January 20, 2018, 9:27am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/17 "2018-01-20T09:27:49Z")

</div>

I would like to use the battery API, and I am getting the same errors as well. After inserting the battery and ls of the LTC2942 folder, I get the following. Is there no way to find out the charge level?

```
ls -l /sys/devices/i2c-0/i2c-2/2-0064/power_supply/LTC2942/
-rw-r--r-- 1 root root 4096 Jan 6 00:07 charge_avg
-r--r--r-- 1 root root 4096 Jan 6 00:07 constant_charge_current
lrwxrwxrwx 1 root root 0 Jan 6 00:07 device -> ../../../2-0064
drwxr-xr-x 2 root root 0 Jan 6 00:07 power
-r--r--r-- 1 root root 4096 Jan 6 00:07 scope
lrwxrwxrwx 1 root root 0 Jan 6 00:07 subsystem -> ../../../../../../class/power_supply
-r--r--r-- 1 root root 4096 Jan 6 00:07 temp_alert_min
-rw-r--r-- 1 root root 4096 Jan 6 00:05 uevent
-r--r--r-- 1 root root 4096 Jan 6 00:07 voltage_avg

```

Thanks

---

<div class="post-metadata">

**Author:** ![Xeset](https://avatars.discourse-cdn.com/v4/letter/x/db5fbb/32.png) [@Xeset](https://mangoh.discourse.group/u/Xeset)\
**Post date:** [February 13, 2018, 2:56pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/18 "2018-02-13T14:56:58Z")

</div>

Hi @asyal

Do you perhaps have an idea when this feature would be implemented? It is difficult to create IoT solutions when I cannot run them on battery.

Thanks

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [February 15, 2018, 4:36am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/19 "2018-02-15T04:36:49Z")

</div>

Hi Xeset,

At this moment, you will need to rebuild yocto to make LTC driver work with WP76. If you can do so, we can provide you the steps.

Regards,  
Ashish

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [March 13, 2018, 6:09pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/20 "2018-03-13T18:09:58Z")

</div>

Hey @asyal,

Is this required for the WP85 as well? I can see the module is loaded by running `lsmod` (it shows `0_ltc294x 5520 0 - Live 0xbf168000 (O)`), but I’m still not seeing the device (`Failed to create link at '/sys/devices/i2c-0/i2c-2/2-0064/power_supply/LTC2942/charge_counter' in app 'batteryService'.`). If this is required I would really appreciate some instructions on how to go about this.

Thanks!

[Next page](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937.md?page=2)
