- Code: Select all | TOGGLE FULL SIZE
code.py output:
scanning
{255: b"L\x00\x02\x15t'\x8b\xda\xb6DE \x8f\x0cr\x0e\xaf\x05\x995\xff\xe0\xff\xe1\xc5", 1: b'\x06'}
{2: b'\xe0\xff', 9: b'HMSensor\x00\x00\x00\x00\x00', 10: b'\xe9', 22: b'\x00\xb0\x00\x16\x00\x00'}
I feel like there is a library function out there I'm not aware of to turn the raw data into a useful temperature and humidity reading.
This was the code I found to at least make sure I was connecting and to the right thing. Now I just need to turn all ^ that into something useful.
- Code: Select all | TOGGLE FULL SIZE
from adafruit_ble import BLERadio
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
......
ble = BLERadio()
print("scanning")
found = set()
scan_responses = set()
# By providing Advertisement as well we include everything, not just specific advertisements.
for advertisement in ble.start_scan(ProvideServicesAdvertisement, Advertisement):
addr = advertisement.address
if advertisement.scan_response and addr not in scan_responses:
scan_responses.add(addr)
elif not advertisement.scan_response and addr not in found:
found.add(addr)
else:
continue
print(advertisement.data_dict)
print()
print("scan done")