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

Renogy Smart Shunt 300 Bluetooth #61

Open
tvan0076 opened this issue Mar 4, 2024 · 13 comments
Open

Renogy Smart Shunt 300 Bluetooth #61

tvan0076 opened this issue Mar 4, 2024 · 13 comments

Comments

@tvan0076
Copy link

tvan0076 commented Mar 4, 2024

My Renogy Rover 60A works like a champ! I thought I would try to use the same code for the Renogy Shunt 300 with Bluetooth, but that didn't work so well :-( It doesn't like the request payload.

DEBUG:root:create_request_payload 5000 => [33, 3, 19, 136, 0, 17, 6, 8]

I used the RNG_BATT in hopes they were close, but I guess not. I tried many device_IDs but couldn't get it to read.

Output Data:
INFO:root:Init BatteryClient: RTMShunt300xxxxxxxx => xx:xx:xx:xx:xx:xx
INFO:root:Adapter status - Powered: True
INFO:root:Starting discovery...
INFO:root:Devices found: 55
INFO:root:Found matching device RTMShunt3005xxxxxxxx => [(xx:xx:xx:xx:xx:xx)]
INFO:root:[xx:xx:xx:xx:xx:xx] Connected
INFO:root:[xx:xx:xx:xx:xx:xx] Resolved services
INFO:root:subscribed to notification 0000fff1-0000-1000-8000-00805f9b34fb
INFO:root:found write characteristic 0000ffd1-0000-1000-8000-00805f9b34fb
INFO:root:resolved services
DEBUG:root:create_request_payload 5000 => [33, 3, 19, 136, 0, 17, 6, 8]
INFO:root:characteristic_enable_notifications_failed
INFO:root:characteristic_write_value_succeeded
ERROR:root:on_read_timeout => please check your device_id!
INFO:root:Exit: Disconnecting device: RTMShunt300xxxxxxxx [(xx:xx:xx:xx:xx:xx)]

Is there a way to get past this easily and pull/read the data from this device? Seems you already built the rest out. Maybe just the right data feeds and added parser. Happy to assist!

Is there a wireshark ish app for Bluetooth on RPie4? I am happy to assist if you are open to the idea.

@cyrils
Copy link
Owner

cyrils commented Mar 5, 2024

Looks like Shunt works differently, characteristic_enable_notifications_failed is not a good sign. Is this the same response you get everytime?

Only way you can figure out the register values is by doing bluetooth snooping. You have to enable Bluetooth HCI snoop in android phone while using dc home app and open the file using wireshark (read).

@tvan0076
Copy link
Author

tvan0076 commented Mar 5, 2024

I have created the snoop file with iOS and XCode. Would you be open to looking at it to see what might need to be done to add the shunt to your program? If so, how should I send it. It has too much private info to add to the thread.

@tvan0076
Copy link
Author

tvan0076 commented Mar 5, 2024

Here is the ATT Attributes:
ShuntClient

@cyrils
Copy link
Owner

cyrils commented Mar 13, 2024

I briefly looked into it. Unfortunately the data sent back from Shunt looks very different from rest of the devices. There are some patterns but it will be really difficult to figure out the whole story without an actual device.

Repository owner deleted a comment from tvan0076 Mar 13, 2024
Repository owner deleted a comment from tvan0076 Mar 13, 2024
@cyrils
Copy link
Owner

cyrils commented Mar 22, 2024

Can you let me know what do you see when using this branch shunt?

Use device type RNG_SHUNT

@tvan0076
Copy link
Author

The first output was this:
INFO:root:Init SmartShuntClient: RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx]
INFO:root:Adapter status - Powered: True
INFO:root:Starting discovery...
INFO:root:Devices found: 21
INFO:root:Found matching device RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx]
INFO:root:[xx:xx:xx:xx:xx:xx] Connected
INFO:root:[xx:xx:xx:xx:xx:xx] Resolved services
ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/dbus/connection.py", line 218, in maybe_handle_message
self._handler(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/gatt/gatt_linux.py", line 398, in properties_changed
self.services_resolved()
File "/home/pi/renogy-bt-main/renogybt/BLE.py", line 73, in services_resolved
self.resolved_callback()
File "/home/pi/renogy-bt-main/renogybt/BaseClient.py", line 58, in __on_resolved
self.poll_data() if self.config['data'].getboolean('enable_polling') == True else self.read_section()
File "/home/pi/renogy-bt-main/renogybt/BaseClient.py", line 105, in read_section
request = self.create_generic_read_request(self.device_id, 3, self.sections[index]['register'], self.sections[index]['words'])
TypeError: create_generic_read_request() takes 1 positional argument but 5 were given
INFO:root:characteristic_enable_notifications_failed

After the first output I kept getting this:
INFO:root:Init SmartShuntClient: RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx]
INFO:root:Adapter status - Powered: True
INFO:root:Starting discovery...
INFO:root:Devices found: 21
INFO:root:Found matching device RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx]
INFO:root:[xx:xx:xx:xx:xx:xx] Connected
INFO:root:[xx:xx:xx:xx:xx:xx] Resolved services
ERROR:root:Exception occured: create_generic_read_request() takes 1 positional argument but 5 were given

I hope this helps.

@cyrils
Copy link
Owner

cyrils commented Mar 22, 2024

Updated, please check again.
Doo you always get this error characteristic_enable_notifications_failed?

@tvan0076
Copy link
Author

The test above I didn't get the characteristic_enable_notifications_failed. I don't think it made it that far.

Updated test I get this:
INFO:root:Init SmartShuntClient: RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx]
INFO:root:Adapter status - Powered: True
INFO:root:Starting discovery...
INFO:root:Devices found: 15
INFO:root:Found matching device RTMShunt30053001400 => [xx:xx:xx:xx:xx:xx]
INFO:root:[xx:xx:xx:xx:xx:xx] Connected
INFO:root:[xx:xx:xx:xx:xx:xx] Resolved services
INFO:root:subscribed to notification 0000fff1-0000-1000-8000-00805f9b34fb
INFO:root:found write characteristic 0000ffd1-0000-1000-8000-00805f9b34fb
INFO:root:resolved services
INFO:root:characteristic_enable_notifications_failed
INFO:root:characteristic_write_value_succeeded
ERROR:root:on_read_timeout => please check your device_id!
INFO:root:Exit: Disconnecting device: RTMShunt30053001400 [xx:xx:xx:xx:xx:xx]

@cyrils
Copy link
Owner

cyrils commented Mar 22, 2024

That means the shunt has totally different ble characteristics. You might have to use a ble scanner app to figure out which one is write characteristic and which one is notification and update in BaseClient

@tvan0076
Copy link
Author

Here is the output for both the controller and the shunt. The shunt doesn't use the subscribed to notification like the controller.
Device (new): xx.xx.xx.xx.xx.xx (public), -36 dBm
Flags: <06>
Incomplete 16b Services: <0000ffd0-0000-1000-8000-00805f9b34fb>
Manufacturer: <6cb2fd859e6a>
Tx Power: <00>
Complete Local Name: 'BT-TH-FD859E6A '
Device (new): xx.xx.xx.xx.xx.xx (public), -30 dBm
Flags: <06>
Manufacturer: <4ce1744c9298001e0001>
Appearance: <0000>
Tx Power: <00>
Complete Local Name: 'RTMShunt30053001400'

@tvan0076
Copy link
Author

I tried running sensortag --all xx.xx.xx.xx.xx.xx and I got this back:
raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral xx.xx.xx.xx.xx.xx, addr type: public

@tvan0076
Copy link
Author

sudo gatttool -b xx:xx:xx:xx:xx:xx -I
[xx:xx:xx:xx:xx:xx][LE]> connect
Attempting to connect to xx.xx.xx.xx.xx.xx
Error: connect: Connection refused (111)

@tvan0076
Copy link
Author

I sent pic of the BLE scanner to the email address above. Lots of good data :-)

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

2 participants