working streaming of raw accel/gyro data. must restart firmware after run of test_basic.py
This commit is contained in:
39
python/test_basic.py
Normal file
39
python/test_basic.py
Normal file
@ -0,0 +1,39 @@
|
||||
# %% imports
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
from bleak import BleakClient, BleakScanner
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
# %%
|
||||
devices = await BleakScanner.discover()
|
||||
for d in devices:
|
||||
print(d)
|
||||
|
||||
|
||||
# %%
|
||||
address = "D7:FC:DA:4B:02:D7"
|
||||
MODEL_NBR_UUID = "2A24"
|
||||
SENSORS_UUID = "99b594745570464bbe3764465aa050fd"
|
||||
|
||||
|
||||
timeseries = list()
|
||||
async with BleakClient(address) as client:
|
||||
# model_number = await client.read_gatt_char(MODEL_NBR_UUID)
|
||||
# print("Model Number: {0}".format("".join(map(chr, model_number))))
|
||||
start_time = time.time()
|
||||
print("Starting capture...")
|
||||
while time.time() < start_time + 20:
|
||||
buffer = await client.read_gatt_char(SENSORS_UUID)
|
||||
sensor_values = np.frombuffer(bytes(buffer), dtype=np.double)
|
||||
timeseries.append(sensor_values)
|
||||
print("DONE")
|
||||
|
||||
timeseries = np.array(timeseries)
|
||||
|
||||
# %%
|
||||
plt.plot(timeseries)
|
||||
plt.show()
|
||||
|
||||
# %%
|
Reference in New Issue
Block a user