I want to use Rpi3 and bluepy read sensor data from Arduino Uno with HM-10. I write program like this :
import bluepy.btle as btle p = btle.Peripheral("D8:A9:8B:7C:01:EB") while True: # Get data, change bytes to int s = p.getServiceByUUID("0000ffe0-0000-1000-8000-00805f9b34fb") services = p.getServices() c = s.getCharacteristics() dataBytes = c.read() dataInt = int.from_bytes(dataBytes, byteorder = 'big') print(dataInt)
However, the print data is always 238222701232619. Could anyone tell me how can I modify the code?
I found a method that can print sensor data in Rpi3 terminal. The method is found from website. The url is https://www.raspberrypi.org/forums/viewtopic.php?t=193923
import bluepy.btle as btle class ReadDelegate(btle.DefaultDelegate): def handleNotification(self, cHandle, data): print(data.decode("utf-8")) p = btle.Peripheral("AA:BB:CC:DD:EE:FF") p.withDelegate(ReadDelegate()) while True: while p.waitForNotifications(1): pass p.disconnect()
Even though we don't use device UUID, still can connect to HM-10 and get sensor data.