Skip to content

Instantly share code, notes, and snippets.

@Sneezry
Created November 3, 2016 05:40
Show Gist options
  • Save Sneezry/7453b31070c86a936c595411dc31fb14 to your computer and use it in GitHub Desktop.
Save Sneezry/7453b31070c86a936c595411dc31fb14 to your computer and use it in GitHub Desktop.
import binascii
import struct
import time
from bluepy.bluepy.btle import UUID, Peripheral
temp_uuid = UUID("ff51b30e-d7e2-4d93-8842-a7c4a57dfb07")
p = Peripheral("b8:27:eb:ab:c4:d6", "public")
try:
ch = p.getCharacteristics(uuid=temp_uuid)[0]
if (ch.supportsRead()):
while 1:
val = binascii.b2a_hex(ch.read())
val = binascii.unhexlify(val)
val = struct.unpack('f', val)[0]
print str(val)
time.sleep(1)
finally:
p.disconnect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment