Show Battery life on oled expansion display

Hello,
I am using onion omega 2+ and an oled expansion display. I am having trouble displaying battery percentage. I found this site

Onion Omega2: Battery Level and Current date Indicator - Hackster.io

and I followed every step but did not work. Is there someone on the forum that knows how to display battery life and can help please.

1 Like

Hi Anthony,

Welcome to the forum!!

Iā€™m not familiar with the Onion Omega 2+ myself but might be able to help out if you have access to a REPL, with all of the dependencies installed and running the code:

import os, datetime, time
from OmegaExpansion import oledExp
from subprocess import Popen, PIPE

# find current time
currentTime = datetime.datetime.now()

# measure and format battery voltage
program = Popen("power-dock2", stdin=PIPE, stdout=PIPE, stderr=PIPE)
output, err  = program.communicate()

Then using a REPL to print: print(output)

Let us know how you go!
Liam.

1 Like