MagTag Battery Monitor
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 7
- Joined: Sun Mar 06, 2022 11:39 am
MagTag Battery Monitor
I have several MagTag devices, They show me the data from my ecowitt sensors. Everything is working nicely. But I like to know in advance, when the time has come to load again the 3.7V 2000mAH LiPo (LP803860). I am using the often proposed function from the magtag library “magtag.peripherals.battery” it always shows something above 5 Volt on all MagTag devices. The value does not change over the time, after weeks of running the display remains blank, as the power needed for the next refresh of the display is no more available. Then I am going to use the USB-C connector to charge the LiPo and as soon a the yellow charging LED switches off, I distribute the device again in the house. I am pretty sure there is some bug within the library, as also the documentation explains how the value will change and how to recognize a soon power outage. Could someone explain what is going wrong?
- dastels
- Posts: 15831
- Joined: Tue Oct 20, 2015 3:22 pm
Re: MagTag Battery Monitor
The first thing is to ensure that CircuitPython and all libraries are up to date.
Dave
Dave
-
- Posts: 7
- Joined: Sun Mar 06, 2022 11:39 am
Re: MagTag Battery Monitor
Thanks Dave
It was and it is adafruit-circuitpython-adafruit_magtag_2.9_grayscale-en_US-7.2.5
Any other ideas?
It was and it is adafruit-circuitpython-adafruit_magtag_2.9_grayscale-en_US-7.2.5
Any other ideas?
- dastels
- Posts: 15831
- Joined: Tue Oct 20, 2015 3:22 pm
Re: MagTag Battery Monitor
What do you see in terms of data if you read AnalogIn(board.BATTERY) over time?
Dave
Dave
-
- Posts: 7
- Joined: Sun Mar 06, 2022 11:39 am
Re: MagTag Battery Monitor
This is the code I am executing
I do have 5 magtag devices, so the result varies a little bit, I do see 5.11 or 5.35
The point is this value never changes over the time, where the real battery voltage gets lower and lower
Thanks for support
Code: Select all
from adafruit_magtag.magtag import MagTag
.. .. ..
magtag = MagTag(
url=...,
json_path=...,
)
.. .. ..
voltage = magtag.peripherals.battery
print(f'battery: {voltage:.2f} V')
The point is this value never changes over the time, where the real battery voltage gets lower and lower
Thanks for support
-
- Posts: 7
- Joined: Sun Mar 06, 2022 11:39 am
Re: MagTag Battery Monitor
I have added this part
The result over the serial line is
magtag.peripherals.battery and AnalogIn(board.BATTERY)
return a similar value
Code: Select all
from analogio import AnalogIn
batt_Monitor = AnalogIn(board.BATTERY)
battV = (batt_Monitor.value / 65535.0) * 3.3 * 2
batt_Monitor.deinit()
print(f'battery: {battV:.2f} V')
Code: Select all
code.py output:
battery: 5.11 V
battery: 5.11 V
return a similar value
-
- Posts: 7
- Joined: Sun Mar 06, 2022 11:39 am
Re: MagTag Battery Monitor
And if I do not do the "mathematics" it look like this
code.py output:
battery: 50739.00 V
battery: 5.11 V
so AnalogIn(board.BATTERY) returns 50739
code.py output:
battery: 50739.00 V
battery: 5.11 V
so AnalogIn(board.BATTERY) returns 50739
- dastels
- Posts: 15831
- Joined: Tue Oct 20, 2015 3:22 pm
Re: MagTag Battery Monitor
I've asked internally to get some more eyes on it.
Dave
Dave
- adafruit_support_carter
- Posts: 29483
- Joined: Tue Nov 29, 2016 2:45 pm
Re: MagTag Battery Monitor
This may be related to this:
https://github.com/adafruit/circuitpython/pull/6246
Try updating to the 7.3.0 release which *should* fix that behavior:
https://circuitpython.org/board/adafrui ... grayscale/
Here's a simple battery voltage monitor program you can try testing with:
https://github.com/adafruit/circuitpython/pull/6246
Try updating to the 7.3.0 release which *should* fix that behavior:
https://circuitpython.org/board/adafrui ... grayscale/
Here's a simple battery voltage monitor program you can try testing with:
Code: Select all
import time
from adafruit_magtag.magtag import MagTag
magtag = MagTag()
magtag.add_text(
text_position=(
10,
(magtag.graphics.display.height // 2) - 1,
),
text_scale=3,
)
while True:
magtag.set_text("Battery = {:4.2f}V".format(magtag.peripherals.battery))
time.sleep(60)
-
- Posts: 7
- Joined: Sun Mar 06, 2022 11:39 am
Re: MagTag Battery Monitor
Yes, this is more or less what I doing, getting some Information from web services AND add the battery status and display everything
Update every 5 minutes
As far as I understood, I should do not grap the battery voltage at the beginning but after log into WIFI and web queries
Update every 5 minutes
As far as I understood, I should do not grap the battery voltage at the beginning but after log into WIFI and web queries
-
- Posts: 7
- Joined: Sun Mar 06, 2022 11:39 am
Re: MagTag Battery Monitor
The approach to read out the battery voltage as late as possible, while still running on version 7.2.5 returns a reasonable result.
After updating to 7.3.0, both readings, the one at the beginning and the one after web access return the same good result
Thank you !
After updating to 7.3.0, both readings, the one at the beginning and the one after web access return the same good result
Thank you !
Please be positive and constructive with your questions and comments.