-
Notifications
You must be signed in to change notification settings - Fork 145
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
Report battery percentage in ble #187
Comments
Hey @jrhbcn, Currently the BLE payload only carries the battery voltage. This info is encoded here. This uses the BTHome encoding, and it supports encoding the battery percentage just as easily as the voltage. We can't simply append that info though, as we would require more than the number of bytes we have available in the BLE packet. So we have at least three choices:
Solution 3 may actually work. For example, now we use 3 bytes for humidity. BTHome supports using either 3 or 2: ![]() Our humidity sensor anyway has 2% accuracy, so it's really no use to use 3 bytes. We can save one byte here. Similarly for soil moisture. We currently use 3 bytes. Our resolution is definitely over 1%, and we can also save up one byte there: ![]() This would free up 2 bytes, which we can use to encode the battery percentage: ![]() The batt percentage is already available in the The caveat is that the battery percentage estimation is very rough, but likely a good first approximation. If you'd like to take a stab at contributing these changes, please do so. Otherwise let me know and I will see if I can get it to work. |
Many thanks for the fast answer @rbaron, Your solution 3 seems indeed perfect, as having so much resolution reported in the humidity or moisture does not make sense if the accuracy is above 1%. My coding skills are quite rusty, so it might take a while for me to figure out how to modify the protocol. If you find the time to make a quick try in a branch it'll be for sure much quicker 0:) I can surely pick up from there and test/tune the protocol in my end. Again, thanks for this fantastic little thing. |
I am actually trying take the dust out of my coding skills (so long ago :) and I am trying to understand the protocol. It seems actually something I can do. Would something like this work to change the humidity values? from:
to:
similar thing the moisture, and then add something like this for battery?
If you think it makes sense, I can update the firmware and check if it works... |
OK, after reading a little bit more, I have settled for this:
Looks good so I am going to try it! :) |
OK, first test and humidity seem to report values between 0-100% correctly with 1 byte. However, battery and moisture have both gone to 0%. :? Is it needed to also multiply by 100* the Sorry for the multiple comments |
Tks for trying your hand at this. I think it's well in the right direction. I believe the new object IDs and offsets you changed are correct ( They seem to be encoded as a percentage in [0, 100]:
I think this should do the trick. |
Yep, it does! ;) I've got it working correctly here now. Many thanks. I am happy to make a PR for this if you want. Should I just replace the current protocol for this? |
Awesome! I would claim this change is backward compatible enough that we can just update it. The only chance of breaking I think is if the receiving end doesn't understand the object ids |
PR done! Thanks. |
Hi,
Is it possible to report battery percentage in BLE firmware (as zigbee firmware does)? I can only see battery voltage reported in home assistant. I did not find any option in Kconfig so I guess it is intended?
Regards,
The text was updated successfully, but these errors were encountered: