Wenn ich folgenden Code verwende:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
HOST = "localhost"
PORT = 4223
UID = "HBp" # Change XYZ to the UID of your Accelerometer Bricklet 2.0
data_rate = 13
full_scale = 0
enable_x = True
enable_y = True
enable_z = True
resolution = 1
from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_accelerometer_v2 import BrickletAccelerometerV2
# Callback function for acceleration callback
def cb_acceleration(RawSensorData):
print(RawSensorData)
#print("Acceleration [X]: " + str(x/10000.0) + " g")
#print("Acceleration [Y]: " + str(y/10000.0) + " g")
#print("Acceleration [Z]: " + str(z/10000.0) + " g")
#print("")
if __name__ == "__main__":
ipcon = IPConnection() # Create IP connection
a = BrickletAccelerometerV2(UID, ipcon) # Create device object
ipcon.connect(HOST, PORT) # Connect to brickd
# Don't use device before ipcon is connected
a.set_configuration(data_rate, full_scale)
a.set_continuous_acceleration_configuration(enable_x, enable_y, enable_z, resolution)
# Register acceleration callback to function cb_acceleration
a.register_callback(a.CALLBACK_CONTINUOUS_ACCELERATION_16_BIT, cb_acceleration)
input("Press key to exit\n") # Use input() in Python 3
ipcon.disconnect()
----------------------------------------------------------------------------
Werden folgende Messwerte ausgegeben:
(-48, 764, 17064, 24, 698, 17034, 211, 718, 17071, 265, 761, 17123, 256, 833, 17078, 252, 832, 17041, 79, 798, 17006, 15, 782, 16870, 88, 791, 16841, 139, 864, 16964)
(78, 795, 17021, 15, 781, 16963, 70, 842, 16952, 63, 871, 16965, -43, 884, 17022, 44, 805, 17048, 203, 751, 17078, 108, 743, 17177, 12, 671, 17121, 86, 688, 17061)
Muss ich bei den Einstellungen noch etwas spezielles beachten?