Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battery status #11

Open
mjs82 opened this issue Mar 18, 2019 · 9 comments
Open

Battery status #11

mjs82 opened this issue Mar 18, 2019 · 9 comments

Comments

@mjs82
Copy link

mjs82 commented Mar 18, 2019

It would be helpful to read the battery status/charge. But there does not appear to be a standard GATT battery service advertised.

The code reads characteristic b42e2a68-ade7-11e4-89d3-123b93f75cba and I see that bytes 2-3 and 16-19 are currently ignored.. could battery status be hidden in there perhaps?

@fireether
Copy link

I've been wanting this feature for the past 2-3 years. I brought 2 airthings CO sensors, and I loved that they had python code to get temp, humidity and co readings from the sensors. But the problem is that I have to poll my database readings to detect when a sensor falls offline. It would be very helpful if we could read the battery life, or at least get an alert when to replace the battery.

Its my fault for not implementing a server side polling of the database to detect when a sensor stops sending data, but if there is a way to read the battery status via bluetooth - please do that. It would save me running a process on my workstation.

@fireether
Copy link

Also I noticed that the app on the phone knows the battery life.

@AndySchroder
Copy link

yes, would like this, or a model that allows power to be hard wired.

@AndySchroder
Copy link

Also, does the SAMPLE-PERIOD impact battery life? This device seems to only update once every 5 minutes, but we don't know when that time period starts, so we need to sample at a rate greater than once every 5 minutes in order to get time accurate data, then throw out all duplicates from the 5 minute period.

@dinoact
Copy link

dinoact commented Apr 9, 2021

I would also love to know how to read the current battery percentage via bluetooth rather than having to rely on the app or to watch out for when the device stops reporting data.

@awilliam
Copy link

awilliam commented Jul 1, 2021

Me too please. These python scripts are the reason I chose to purchase an AirThings radon meter versus the alternatives. Battery status is the one thing missing. Please share how to decode it from the extra bits in the characteristic or update the firmware to support standard BLE battery reporting.

@singlepane-io
Copy link

I'm also interested in the battery status. As for polling frequency impacting battery, I haven't seen any significant difference between a sensor that is polled every few minutes and one polled every 30 seconds.

@arnerek
Copy link

arnerek commented Sep 28, 2021

I used the code from this page: https://sifter.org/~simon/journal/20191210.1.html

I added the following lines to the function query2_parse

    d = struct.unpack('<L12B6H', q2['raw'])
    
    q2['ambientlight'] = d[2]
    q2['measurement_periods'] =  d[5]
    q2['voltage'] = d[17] / 1000.0
    
    V_MAX=3.2
    V_MIN=2.2
    q2['battery']= max(0, min(100, round( (q2['voltage']-V_MIN)/(V_MAX-V_MIN)*100)))

The battery in percentage is available in q2['battery']. It is not identical to what is reported in the app, but quite close. Maybe someone has a better way of calculating battery capacity from voltage?

@singlepane-io
Copy link

@arnerek or @eddyg, were either of you able to find a way to get an exacting battery value and have it incorporated into the reader? I've been pulling my hair out how to incorporate that different struct into this reader so I can get the battery in the same output with the other metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants