Created
November 3, 2016 05:40
-
-
Save Sneezry/7453b31070c86a936c595411dc31fb14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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