# 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:** 2

<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:** [March 13, 2018, 9:45pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/21 "2018-03-13T21:45:27Z")

</div>

You dont need this for WP85.  
However, you need to fix a file in release 15 and rebuild yocto. That bug is related to a mismatch in naming in the kernel

---

<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 14, 2018, 4:01pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/22 "2018-03-14T16:01:06Z")

</div>

Thanks for info @asyal. How much ground work has already been done here in terms of figuring this out? I was having a read through this [https://source.sierrawireless.com/resources/legato/linuxoverview/](https://source.sierrawireless.com/resources/legato/linuxoverview/) and digging around on the forums a bit.

---

<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:** [March 14, 2018, 4:36pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/23 "2018-03-14T16:36:22Z")

</div>

We can provide you info on exact file you need to change. You will need to rebuild Yocto

---

<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 14, 2018, 4:54pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/24 "2018-03-14T16:54:03Z")

</div>

Thanks @asyal! Maybe this is worth putting on the MangOH GitHub somewhere since battery monitoring is such a desirable feature.

---

<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:** [March 14, 2018, 4:56pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/25 "2018-03-14T16:56:19Z")

</div>

The idea is WP85 Release 16 will have this fix. So while we wait for it, we can show what needs to be done for battery service to work. However, opening up for Yocto rebuilding is something that a lot of the community doesnt want to do.

---

<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:** [March 14, 2018, 9:46pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/26 "2018-03-14T21:46:34Z")

</div>

If you’re feeling ambitious, this is the change that @asyal was referring to:

```auto
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 44420d1e909..71bbaacdd4d 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -139,6 +139,7 @@ static struct device_attribute power_supply_attrs[] = {
        POWER_SUPPLY_ATTR(health),
        POWER_SUPPLY_ATTR(present),
        POWER_SUPPLY_ATTR(online),
+ POWER_SUPPLY_ATTR(charging_enabled),
        POWER_SUPPLY_ATTR(authentic),
        POWER_SUPPLY_ATTR(technology),
        POWER_SUPPLY_ATTR(cycle_count),

```

---

<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 14, 2018, 9:49pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/27 "2018-03-14T21:49:55Z")

</div>

Thanks @dfrey. I’m usually feeling ambitious unless it’s a particularly seg-faulty day. I’ll give this a try and report back.

---

<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:** [April 13, 2018, 11:39pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/28 "2018-04-13T23:39:20Z")

</div>

Hey all,

I’m still struggling to get the LTC2942 working after rebuilding Yocto and making my own firmware image with `swicwe`. I was also sure to enable the kernel module for the LTC in my system definition file and in the C code for the MangOH kernel module. I can see the name of the device at `/sys/bus/i2c/devices/0-0064/name` but it does not contain a value. The logs also show the system failing to load the LTC:

```auto
[21.038547] LTC2941 0-0064: ltc2941 read_reg failed!
[21.038577] LTC2941 0-0064: Could not read status register
[21.038638] LTC2941: probe of 0-0064 failed with error -107

```

Is this a sign I still have a problem with my kernel or does this look like something else? I’ve also been sure to test this with a charged battery connected.

Cheers!

---

<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:** [April 14, 2018, 12:22am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/29 "2018-04-14T00:22:18Z")

</div>

Try using `i2cdetect` to check what devices are visible on the bus. From memory, I think the command is `i2cdetect -y -r 0` where 0 is the bus number.

---

<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:** [April 14, 2018, 12:26am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/30 "2018-04-14T00:26:41Z")

</div>

> <https://gist.github.com/nvandoorn/3b99dc32305930458b081915af50515f>

Looks like nothing is present at `0x0064`.

---

<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:** [April 14, 2018, 1:02am UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/31 "2018-04-14T01:02:50Z")

</div>

Are there devices on there that you don’t expect? I’m wondering if it’s at another address. I don’t recall if that chip has a configurable address based on pull-up/down resistors.

---

<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:** [April 14, 2018, 1:38pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/32 "2018-04-14T13:38:12Z")

</div>

Do you have a battery connected to your device?

---

<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:** [April 14, 2018, 8:20pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/33 "2018-04-14T20:20:30Z")

</div>

We have a fully charged battery 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:** [April 15, 2018, 2:20pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/34 "2018-04-15T14:20:38Z")

</div>

If you use a release 15 with no yocto changes but load kernel drivers , what do you see? Can you see the LTC device?

---

<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:** [April 16, 2018, 5:43pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/35 "2018-04-16T17:43:51Z")

</div>

These are all accounted for:

- 0x003a: `swimcu`
- 0x0068: `bmi160` (accelerometer)
- 0x006b: `bq24190` (battery charger)
- 0x0076: `bme280` (temperature/pressure/humidity)

---

<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:** [April 16, 2018, 9:03pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/36 "2018-04-16T21:03:14Z")

</div>

Hey @asyal,

I gave this a go and found the exact same results (logs in a gist: [https://gist.github.com/nvandoorn/1baaaaa6b0270b2686f1e1590eb090fc](https://gist.github.com/nvandoorn/1baaaaa6b0270b2686f1e1590eb090fc)).

---

<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:** [April 16, 2018, 9:04pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/37 "2018-04-16T21:04:06Z")

</div>

What happens when you run this on a Red?

---

<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:** [April 16, 2018, 9:05pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/38 "2018-04-16T21:05:30Z")

</div>

Hehe it seems you read my mind. Trying this now.

---

<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:** [April 16, 2018, 9:41pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/39 "2018-04-16T21:41:56Z")

</div>

Tried on the MangOH Red with release 15 of the firmware followed by a custom Yocto image and neither worked (same errors). I was also sure to load all the correct kernel modules for the MangOH Red (I just built these directly [https://github.com/mangOH/mangOH/tree/master/linux\_kernel\_modules](https://github.com/mangOH/mangOH/tree/master/linux_kernel_modules)).

---

<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:** [April 16, 2018, 10:07pm UTC](https://mangoh.discourse.group/t/batteryservice-on-mangoh-red/937/40 "2018-04-16T22:07:19Z")

</div>

what revision of mangoh red are you using?

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

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