mkjanke / ThornwavePy

Python scripts to read data from Thornwave battery monitor
GNU General Public License v3.0
5 stars 0 forks source link

bluezero module #2

Open N7FMH opened 9 months ago

N7FMH commented 9 months ago

Greetings,

Edited:

I found sudo pip3 install bluezero at: https://ukbaz.github.io/howto/ubit_workshop.html

Running through various parameters, I am getting no results. The -v parameter returns "Read failed".

PowerMon: Hardware Build: rev. 2.3 Current Firmware: v2.33

Using char-read-hnd I get a shorter string most of the time compared to your results. One time, I received a longer string but it appeared to be once.

`CC:03:E6:5D:EE:52][LE]> char-read-hnd 0x15 Characteristic value/descriptor: 00 08 33 02 23 7b 79 6b 65 01 01 01 14 2b 82 55 41 1f 3e 8e

[CC:03:E6:5D:EE:52][LE]> char-read-hnd 0x15 Characteristic value/descriptor: 00 08 33 02 23 84 79 6b 65 01 01 01 14 6c 78 55 41 3f e1 4d`

[bluetooth]# scan on Discovery started [CHG] Device CC:03:E6:5D:EE:52 RSSI: -63 [CHG] Device CC:03:E6:5D:EE:52 ManufacturerData Key: 0x04c9 [CHG] Device CC:03:E6:5D:EE:52 ManufacturerData Value: 33 02 23 65 6b 7a 71 1a 10 00 04 00 03 2c 1a d3 3.#ekzq......,.. c5 ef 8c 7c b1 61 4b 27 ff f0 00 ...|.aK'...

Thank you!

Best regards, Fred

N7FMH commented 9 months ago

I noticed in DCPMRead.py: if args.PowermonX: ch = my_Sensor.add_characteristic("ec7c0000-2c7b-1539-172f-29d041beab3e", "ec7c0001-2c7b-1539-172f-29d041beab3e") else: ch = my_Sensor.add_characteristic("7a95ce00-0ea8-1bcc-71a2-fc7539b81c9c", "7a95ce01-0ea8-1bcc-71a2-fc7539b81c9c")

From gatttool, interrogation of my PowerMon returns a different uuid than in the Python code. handle: 0x0015, uuid: ec7c0001-2c7b-1539-172f-29d041beab3e handle: 0x0016, uuid: 00002902-0000-1000-8000-00805f9b34fb handle: 0x0017, uuid: 00002803-0000-1000-8000-00805f9b34fb handle: 0x0018, uuid: ec7c0002-2c7b-1539-172f-29d041beab3e handle: 0x0019, uuid: 00002902-0000-1000-8000-00805f9b34fb

I will try the different uuid later and see if there is a better result. I messed up my latest install and will start fresh.

Thanks!

mkjanke commented 9 months ago

My memory is fuzzy, but you might either have to run as root or adjust permissions for your non-root user. Try bluetoothctl. If it works, permissions should be OK.

Also, the two UUIDs in the function call are Service & Characteristic. The new firmware might not use the same handle. My dump from the last time I messed with this suggests handle 0x14.

Not sure though, and I'm not able to test right now.

N7FMH commented 9 months ago

I solved a piece. I ran bluetoothctl, typed "scan on" then selected the device of interest and exited. I had always enter scan off. Now, I can read the PowerMon. Data is wonky though. Some is correct, some is wrong.

I finally am able to read a second PowerMon after repeating the scan on, select device, then exiting. Data is wonky on the second unit as well.

V1, V2, and Temperature are correct. The rest are questionable. Pct is half. It is at 100%. I will work on this more.

Time:               12/14/23 15:06:47
Device:             D0:31:25:88:2B:A9
Pct Charged:                      50%
V1 Volts:                      14.23V
V2 Volts:                      23.98V
Current:                        0.00A
Power:                             1W
Temperature:                    23.1C
Power Meter:      360570548989941.1Wh
Charge Meter:     288512954951873.9Ah
Uptime:                       0:00:00
Device Time:               1702566405
Peak Current:                   0.0Ah

I realize you are currently unavailable. This is posted to record my findings for later. :)

Thank you!

Best regards, Fred