IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.6k stars 490 forks source link

Reading Accelerometer, Magnetometer and Gyroscope all within 100ms #318

Open ahasan016 opened 5 years ago

ahasan016 commented 5 years ago

Hello, I am using Sensortag2 and i have tried bluepy to read data from my sensortags. So far I can easily read data but it takes approx. (300+/-20)ms to read Accelerometer, Magnetometer and Gyroscope from one Sensortag to collect the sensors data.

def get_readings(tag):

try:
    readings = {}

    #accelerometer

    readings["accelerometerX"],readings["accelerometerY"],readings["accelerometerZ"] = tag.accelerometer.read()

    #gyroscope

    readings["gyroscopeX"], readings["gyroscopeY"], readings["gyroscopeZ"] = tag.gyroscope.read()

    #magnetometer

    readings["magnetometerX"], readings["magnetometerY"], readings["magnetometerZ"] = tag.magnetometer.read()

    # round to 2 decimal places for all readings

    readings = {key: round(value, 2) for key, value in readings.items()}

    return readings

except BTLEException as e:
    print("Unable to take sensor readings.")
    print(e)
    return {}

So, I was wondering if there's any way that can be implemented to get data faster from all three sensors together? (I have checked SensorTag android app where three sensors data are updated together within as less as 100ms) I am a newbie. Just correct me if the question raised in my mind is absurd.