# Reading battery level from mmbasic

**URL:** <https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433>\
**Category:** PicoCalc\
**Tags:** tinkering\
**Created:** [April 1, 2025, 3:55am UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433 "2025-04-01T03:55:34Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![adcockm](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/adcockm/32/1664_2.png) [@adcockm](https://forum.clockworkpi.com/u/adcockm)\
**Post date:** [April 29, 2025, 5:51am UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/21 "2025-04-29T05:51:23Z")

</div>

Has anyone managed to use the i2c commands in PicoMite to get that battery register value? Or is that really not possible in MMBasic? I’ve tried a few things, but I’m not sure I really understand how to use the i2c commands properly.

If it’s not possible with MMBasic itself, maybe I could look into adding a custom command to PicoMite (for PicoCalc only) to get the battery value and pass it through based on [guu’s code here](https://github.com/clockworkpi/PicoCalc/blob/master/Code/picocalc_helloworld/i2ckbd/i2ckbd.c). I imagine the same could be done for setting the backlight as well. Actually, that’s something I’d personally use more, as I find it annoying to have to always turn the keyboard backlight on and it would be nice if it was saved (as an OPTION?) and always used the last saved value on startup. I’ll add it to my todo/wish list. 😉

---

<div class="post-metadata">

**Author:** ![adcockm](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/adcockm/32/1664_2.png) [@adcockm](https://forum.clockworkpi.com/u/adcockm)\
**Post date:** [May 14, 2025, 12:46am UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/22 "2025-05-14T00:46:51Z")

</div>

Just to follow up… Forgot about this thread, but saw it linked from discord today.

It’s possible to get battery info from MMBasic now, with the most recent releases. (It went in for RC21, but is still there for RC23 and whatever I end up releasing next.) 🙂 A number of other bugs have been fixed (like keyboard handling), and this contains the latest from the mainline MMBasic releases as well.

> **[Releases · madcock/PicoMiteAllVersions](https://github.com/madcock/PicoMiteAllVersions/releases)**
>
> This contains files to build MMbasic to run on both RP2040 and RP2350 for the PicoCalc from Clockwork - madcock/PicoMiteAllVersions

You’ll need to update your keyboard firmware though, but more information on that is provided in the release notes. Here’s a screenshot showing the new commands, for reference.

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/clockworkpi/original/2X/f/f89697cc2d058971d5c2c85224ef348e2f390851.png)

---

<div class="post-metadata">

**Author:** ![Oldric](https://avatars.discourse-cdn.com/v4/letter/o/74df32/32.png) [@Oldric](https://forum.clockworkpi.com/u/Oldric)\
**Post date:** [May 14, 2025, 9:24am UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/23 "2025-05-14T09:24:20Z")

</div>

I defined F9 key to show the batt info, very practical !

---

<div class="post-metadata">

**Author:** ![pkr](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/pkr/32/6084_2.png) [@pkr](https://forum.clockworkpi.com/u/pkr)\
**Post date:** [May 14, 2025, 5:31pm UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/24 "2025-05-14T17:31:52Z")

</div>

I put a battery bar/line on the right side. Extra practical 😆  
Though it’s micropython…

 ![pc](https://canada1.discourse-cdn.com/flex029/uploads/clockworkpi/original/2X/3/3c35caf348c1a408a86cbae1cafaeff6ef481db8.png)

---

<div class="post-metadata">

**Author:** ![Astrox](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/astrox/32/13039_2.png) [@Astrox](https://forum.clockworkpi.com/u/Astrox)\
**Post date:** [May 20, 2025, 9:47am UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/25 "2025-05-20T09:47:58Z")

</div>

how did you do this?

---

<div class="post-metadata">

**Author:** ![Oldric](https://avatars.discourse-cdn.com/v4/letter/o/74df32/32.png) [@Oldric](https://forum.clockworkpi.com/u/Oldric)\
**Post date:** [May 20, 2025, 3:38pm UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/26 "2025-05-20T15:38:13Z")

</div>

```auto
option f9 "? "+chr$(34)+"Battery level"+chr$(34)+"mm.info(battery)"+chr$(34)+"%"+chr$(10)+chr$(13)
```

---

<div class="post-metadata">

**Author:** ![Astrox](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/astrox/32/13039_2.png) [@Astrox](https://forum.clockworkpi.com/u/Astrox)\
**Post date:** [June 12, 2025, 10:07am UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/27 "2025-06-12T10:07:04Z")

</div>

as a MMBasic file, would this always work, or does it have to be flash saved?

---

<div class="post-metadata">

**Author:** ![Oldric](https://avatars.discourse-cdn.com/v4/letter/o/74df32/32.png) [@Oldric](https://forum.clockworkpi.com/u/Oldric)\
**Post date:** [June 12, 2025, 1:55pm UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/28 "2025-06-12T13:55:34Z")

</div>

Just have to type it once and it stays as long as you don’t modify the F9 key again. Try it.

---

<div class="post-metadata">

**Author:** ![M57](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/m57/32/12528_2.png) [@M57](https://forum.clockworkpi.com/u/M57)\
**Post date:** [June 12, 2025, 3:03pm UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/29 "2025-06-12T15:03:10Z")

</div>

Any idea why it spams that?

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/clockworkpi/original/2X/2/279ac9c01c5bc84677907a0604c48da5345eb664.png)

---

<div class="post-metadata">

**Author:** ![adcockm](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/adcockm/32/1664_2.png) [@adcockm](https://forum.clockworkpi.com/u/adcockm)\
**Post date:** [June 12, 2025, 3:46pm UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/30 "2025-06-12T15:46:49Z")

</div>

Which version of MMBasic are you running? Older versions had a bug with the I2C timing, but as far as I know this has been fixed in recent builds.

> **[Release PicoCalc PicoMite V6.00.02RC26 · madcock/PicoMiteAllVersions](https://github.com/madcock/PicoMiteAllVersions/releases/tag/V6.00.02RC26)**
>
> Updated to the latest RC26 revision. There were fixes on TheBackShed for CHAIN and MM.TOPIC$, as mentioned here.

---

<div class="post-metadata">

**Author:** ![Astrox](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/astrox/32/13039_2.png) [@Astrox](https://forum.clockworkpi.com/u/Astrox)\
**Post date:** [June 13, 2025, 4:50am UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/31 "2025-06-13T04:50:07Z")

</div>

when I try to run the code it comes up with an error

---

<div class="post-metadata">

**Author:** ![Nick\_Stevens](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/nick_stevens/32/8839_2.png) [@Nick\_Stevens](https://forum.clockworkpi.com/u/Nick_Stevens)\
**Post date:** [June 13, 2025, 5:58am UTC](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433/32 "2025-06-13T05:58:11Z")

</div>

You need to update the keyboard firmware. I had the exact same issue before updating

[Previous page](https://forum.clockworkpi.com/t/reading-battery-level-from-mmbasic/16433.md?page=1)
