-
Notifications
You must be signed in to change notification settings - Fork 38
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
plattform esp32-ble esphome - ENHANCEMENT #49
Comments
FYI it looks like bleak isn't supported for micropython yet: https://github.com/orgs/micropython/discussions/13215 It has this though: https://github.com/micropython/micropython-lib/tree/master/micropython/bluetooth/aioble |
I had another go at this project yesterday having learnt more about Modbus recently and I've managed to get a somewhat very basic implementation of Renogy BLE Battery support on ESPhome, at the moment it just reads the basics. Happy to share the code if this would meet your needs. |
Hi Thanks for sharing the code? Is it in git? |
@mateuszdrab that looks great! I'd love to see the code as well, so I could play around with it. Thanks! |
Hey guys, I dropped my existing code into https://gist.github.com/mateuszdrab/922c760582fce29d63608a1a405c541b for now. Feel free to play around with it, just ensure to change the As mentioned, it is nowhere near as functional as this repo as I was pretty much learning about interacting with the BT stack and Modbus as I was doing it but it does what I care about the most. I think ultimately, the goal would be to replicate the same depth of data retrieved as this repo does and perhaps make it into an esphome component. |
0x30 in renogy_battery_bc is your battery ID, right? So 48 in base 10? |
Yeah, it's the modbus slave id. It might be the same on your battery, or it might be different. I am not sure since I've only got one of those.
|
Perfect; thanks! I have three batteries daisy chained that I can access as
48, 49, and 50 via renogy-bt. Having the breakdown of the bytes is super
helpful.
…On Mon, Jul 29, 2024, 07:15 Mateusz Drab ***@***.***> wrote:
0x30 in renogy_battery_bc is your battery ID, right? So 48 in base 10?
Yeah, it's the modbus slave id. It might be the same on your battery, or
it might be different. I am not sure since I've only got one of those.
# unsigned char newVal[8] = {
# 0x30, // device 48
# 0x03, // 3 READ - 6 WRITE
# 0x13, 0xB2, // Register
# 0x00, 0x06, // Word
# 0x65, 0x4A // CRC
# };
—
Reply to this email directly, view it on GitHub
<#49 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABO65BDTTV2NGE545FND7MTZOYP3NAVCNFSM6AAAAABLC3VGL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJVGY2TMNBTGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Yeah, I think you'll need to recalculate the CRC though when you change them. Let me know how it goes for you. Definitely want to put this in a repo so we consolidate the improvements. |
Yep, I figured that. I'll play with it ASAP; possibly today. Thanks again!
…On Mon, Jul 29, 2024, 09:57 Mateusz Drab ***@***.***> wrote:
Perfect; thanks! I have three batteries daisy chained that I can access as
48, 49, and 50 via renogy-bt. Having the breakdown of the bytes is super
helpful.
On Mon, Jul 29, 2024, 07:15 Mateusz Drab *@*.***> wrote:
0x30 in renogy_battery_bc is your battery ID, right? So 48 in base 10?
Yeah, it's the modbus slave id. It might be the same on your battery, or
it might be different. I am not sure since I've only got one of those.
unsigned char newVal[8] = { 0x30, // device 48 0x03, // 3 READ - 6 WRITE 0x13,
0xB2, // Register 0x00, 0x06, // Word 0x65, 0x4A // CRC };
—
Reply to this email directly, view it on GitHub
#49 (comment)
<#49 (comment)>,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABO65BDTTV2NGE545FND7MTZOYP3NAVCNFSM6AAAAABLC3VGL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJVGY2TMNBTGU
.
You are receiving this because you commented.Message ID:
*@*.***>
Yeah, I think you'll need to recalculate the CRC though when you change
them. Let me know how it goes for you.
Definitely want to put this in a repo so we consolidate the improvements.
—
Reply to this email directly, view it on GitHub
<#49 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABO65BEPSLNFT75MMJTZRSLZOZC5VAVCNFSM6AAAAABLC3VGL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJWGAZDCMRQGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
thanks a lot, I am on traveling at the moment, will test when I am back. T |
I have played with the code a bit and pulled some of the logic into a function that can be reused per-battery. Sorry for the possibly-garbage code; I'm very rusty with C++, having only used it in college and here and there for Arduino stuff.
Where GetBatteryRequest is defined as such:
I haven't looked yet at how to push the data into different sensors for each battery (e.g. renogy_battery_30_esp32_current instead of renogy_battery_esp32_current) but making those generic is on my list. |
Well I found a way not to do it. Setting up three ble_clients is not the way to make it work. But as I think about it now, that's obviously not needed; the data passed back when querying includes the battery number. So we can just switch based on that to decide which entities to update. |
@cyrils is this something you want as part of this project, or should it be spun off? It's obviously related (and heavily influenced) by what you've done, but it's also a big departure from what you have built. |
Actually, that was easy and reliable:
Now I just need to change the parsing logic to update sensors for the correct battery |
BTW, huge thanks to @mateuszdrab for getting this moving; without what you shared, I wouldn't have been anywhere near getting this working. |
Oh, snap:
BTW these C++ functions (GetBatteryRequest and HandleBatteryData) are in a file I called renogy_utilities.h and refereced in the esphome config like so:
|
As soon as I get some more esp32s, I'm going to configure one for pulling Rover data. |
You're welcome, I'm happy to have been able to help you out - I've had this battery for a year and it's been bugging me constantly as I had power cuts due to my RCD tripping and wasn't able to get any insights into the battery. Now I can finally react to this situation and shut the server down gracefully. I think it might be better to have this code sanitized into an esphome component/library in its own repo for easy reusability. However, my C++ knowledge is way rustier than yours 😂 Next, I need to try connecting to the renogy inverter charger which has an actual rs485 connector. |
@mavenius Feel free to create a new repo. Just give a link back, I'll also add a link to your repo. |
Sounds good; that's what I figured you'd say. I'll let you know when it's
set up.
…On Thu, Aug 8, 2024, 22:41 Cyril Sebastian ***@***.***> wrote:
@cyrils <https://github.com/cyrils> is this something you want as part of
this project, or should it be spun off? It's obviously related (and heavily
influenced) by what you've done, but it's also a big departure from what
you have built.
@mavenius <https://github.com/mavenius> Feel free to create a new repo.
Just give a link back, I'll also add a link to your repo.
—
Reply to this email directly, view it on GitHub
<#49 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABO65BGSPGZJ47IM5HHR2CLZQQT6RAVCNFSM6AAAAABLC3VGL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZXGAZTSNRVGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I spun off https://github.com/mavenius/renogy-bt-esphome and made some of the config generic. It has some more work to go to make it easier to use, but it's out there for you all to play with and/or PR into. Thanks again for all that you all did to get this here; I truly couldn't have done it without you. |
I have updated the code in my fork https://github.com/mateuszdrab/renogy-bt-esphome with support for obtaining sensor temperatures and cell voltages (though did not add sensors for temperatures) I also updated the examples, but I have not tried the setup with multiple batteries as my yaml file is for a single battery and uses no prefixes in their naming. However, any changes I made should be backwards compatible. PS. All those hours invested, and I still don't know why the battery is self-discharging at 1 Ah 😁 |
Hi
as this is a perfect implementation for pulling data from the Renogy BT
I am wondering if this can be migrated to esphome esp32-ble as well.
Thanks for checking
The text was updated successfully, but these errors were encountered: