MikroElektronika / HEXIWEAR

HEXIWEAR firmware
http://www.hexiwear.com
121 stars 90 forks source link

Hexiwear does not connect to Raspberry Pi via Bluetooth #30

Open VerenaSchmidt11 opened 4 years ago

VerenaSchmidt11 commented 4 years ago

Hi, Main Idea: I have problems with connection my Hexiwear IoT Device and bluetooth.

My main idea is to have the Hexiwear IoT Device connected via bluetooth to the Raspberry Pi. Then I want to record the sensor data from the IoT Device on the Pi and perhaps also send to a personal cloud (not NXP cloud!).

Hexiwear c-Programm I run on the Hexiwear the mbed example HEXI_BLE_Exmample which I changed in that way that it only sends constants. E.g. constant battery level = 1, light=2, temperature = 4.

Results on App I can see on my Gatt-App on my Smartphone that I can read out the parameters battery, light and temperature. The only difference I see on the GattApp is that battery While the light and temperature: Value is free but the Hex value is given and it is the correct one.

Python Programm for Reading Bluetooth signal Now I have a small python programme running. I can get the battery level without problems. However, when I want to read out the register values of e.g. the temperature the programme hangs on. I already checked that the UUID is readable. However, I don't get any data.

All works well for the battery, however I don't get any data when reading the temperature value. The programm just hangs up (depending on comments both lines can hang up). No results are shown.

My code is: `import binascii import struct import time from bluepy import btle from bluepy.btle import Peripheral from struct import unpack

print ("Connecting...") dev = btle.Peripheral("xx:xx:xx:xx:xx:xx")

Get handles for 2. Variant

characteristics = dev.getCharacteristics() handles = {} for characteristic in characteristics: if characteristic.uuid == "00002a29-0000-1000-8000-00805f9b34fb": handles["manufacturer"] = characteristic.getHandle() if characteristic.uuid == "00002012-0000-1000-8000-00805f9b34fb": handles["temp"] = characteristic.getHandle() if characteristic.uuid == "00002a19-0000-1000-8000-00805f9b34fb": handles["battery"] = characteristic.getHandle()

Read out Battery

battery_handle= dev.getCharacteristics(uuid="2a19")[0] print("Battery Handle: ", battery_handle) battery_readable=battery_handle.supportsRead() print("Battery readable: ", battery_readable) battery_value = battery_handle.read() print("Battery Value via read: ", battery_value) battery_value2=dev.readCharacteristic(handles["battery"]) print("Battery Value via readCharacteristic: ", battery_value2)

Read out Temperature (in the same way)

temp_handle= dev.getCharacteristics(uuid="2012")[0] print("Temp Handle: ", temp_handle) temp_readable=temp_handle.supportsRead() print("Temperature readable: ", temp_readable) temp_value = temp_handle.read() #--> hangs on - nothing works print("Temperature Value via read: ", temp_value) temp_value2=dev.readCharacteristic(handles["temp"]) # hangs on - nothing workds print("Temperature Value via readCharacteristic: ", temp_value2)

dev.disconnect`

So my question is: What do I have to change in order to read out my personal data from the hexiwear IoT e.g. temperature to my raspberry pi running with my Python Script?

Thanks a lot