def main(): print("Connecting to the SensorTag") #Connect to Sensortag tag=sensortag.SensorTag(sensortagAddress); print("Connected!") #Enableing Sensors tag.accelerometer.enable() tag.IRtemperature.enable() tag.keypress.enable() tag.setDelegate(MyKeypressDelegate()) time.sleep(1.0) counter=120 while True: accData=tag.accelerometer.read() print("Accelerometer: ",accData) tempData=tag.IRtemperature.read() print("Temp: ",tempData) x=accData[0]; y=accData[1]; z=accData[2]; counter+=1 #120s do write temp to database if counter>120: #write temp data writeTemp(tempData) counter=0 #Fall Detect if math.sqrt(x*x+y*y+z*z)>2 : print("FALL!!!") #push notification os.system('curl -X POST \ -H \"X-Bmob-Application-Id: 718cb7645ebfcd11e7af7fc89230d1ce\" \ -H \"X-Bmob-REST-API-Key: 7c42e568f537207d6beb3e38a0c4c5dc\" \ -H \"Content-Type: application/json\" \ -d \'{\"data\": {\"Alert\": "Warning!! Fall detected!!!.\"}}\' \ https://api.bmob.cn/1/push') #write sensor history os.system('curl -X POST \ -H \"X-Bmob-Application-Id: 718cb7645ebfcd11e7af7fc89230d1ce\" \ -H \"X-Bmob-REST-API-Key: 7c42e568f537207d6beb3e38a0c4c5dc\" \ -H \"Content-Type: application/json\" \ -d \'{\"type\": \"motion sensor\",\"content\":\"fallen over\",\"sensor\":{\"__type\":\"Pointer\",\"className\":\"Sensor\",\"objectId\":\"a6a263407f\" } }\' \ https://api.bmob.cn/1/classes/SensorDataHistory') time.sleep(0.5) db.close() tag.disconnect()
def __init__(self, mac, cache_timeout): """Initialize the sensor.""" self.tag = None self.mac = mac try: self.tag = sensortag.SensorTag(mac) except BTLEException as bterror: _LOGGER.info('Coonection error %s, MAC %s', bterror, mac) self._registered = [] self._cache = {} self._cache_timeout = timedelta(seconds=cache_timeout) self._last_read = None self.lock = Lock()
def __init__(self, mac='BC:6A:29:AC:53:91'): ''' Constructor ''' print "* Connecting to sensor..." self._tag = sensortag.SensorTag(addr=mac) print "* Connected: ", self._tag self._tag.magnetometer.enable() self._tag.IRtemperature.enable() self._tag.humidity.enable() self._tag.IRtemperature.enable() self._tag.barometer.enable() self._tag.accelerometer.enable() self._tag.gyroscope.enable() time.sleep(2.0) print "* Sensors enabled" self._temp_value = 0.0
def init(self): global tag try: util.log( 'SENSORTAG: You might have to press the side button to connect.' ) tag = sensortag.SensorTag(self.mac) util.log('SENSORTAG Connected!') pool = Pool(1) pool.apply_async(self.always_on, [tag]) # ao = threading.Thread(target=always_on()) # ao.daemon = True # ao.start() util.log('AlwaysOn feature activated') return True except BTLEException as bte: util.log(bte.message) return False
SENSORTAG_MAC = 'A0:E6:F8:AF:3E:06' systemd_notifier = sdnotify.SystemdNotifier() with open(expanduser('~') + '/.config/trashtalk/device_id') as file: device_id = file.read().strip() post_url = API_PREFIX + device_id + '/status' post_headers = {'Content-Type': 'application/json'} serial_devices = [ '/dev/' + file for file in os.listdir('/dev') if file.startswith('ttyUSB')] serial_connections = [ serial.Serial(device, BAUD_RATE) for device in serial_devices] tag = sensortag.SensorTag(SENSORTAG_MAC) tag.IRtemperature.enable() tag.accelerometer.enable() arduino_readings = { 'distance1': 0, 'distance2': 0, 'flame': 0, 'weight': 0 } def worker(): for conn in serial_connections: conn.flushInput()
def main(): scanner = Scanner().withDelegate(ScanDelegate()) devices = scanner.scan(10.0) tags = [] for dev in devices: completeLocalName = dev.getValueText(COMPLETE_LOCAL_NAME) if completeLocalName == "CC2650 SensorTag": print("Connecting to {0} {1} ({2}), RSSI={3} dB".format( completeLocalName, dev.addr, dev.addrType, dev.rssi)) tags.append(sensortag.SensorTag(dev.addr)) for i in range(0, len(tags)): tags[i].magnetometer.enable() time.sleep(3.0) endTime = time.time() + 10 data = len(tags) * [[]] ''' while time.time() < endTime: #for i in range(0, len(tags)): data.append(tags[0].magnetometer.read()) ''' print('Calculating Offsets...') pos_dict = cali_funcs.parse_input(CALI_FILE) pos_m = [] h = [] for i in range(CALI_MAG_POSITION): for p in range(CALI_POS_SAMPLES): pos_m.append(pos_dict['MagPos' + str(i)]) h.append(pos_dict['MagOrien' + str(i)]) #print(pos_m) while i < CALI_OFFSET_SAMPLES: for index in range(len(tags)): data[index].append(tags[index].magnetometer.read()) #data[index].append([20,20,20]) i = i + 1 offsets = len(tags) * [[0, 0, 0]] for i in range(len(tags)): offsets[i] = cali_funcs.cali_offset(data[i]) print('Calibrating...') data = [] for i in range(len(tags)): data.append([]) for pos in range(CALI_MAG_POSITION): print('Place Mag at position ', pos) tmp = input('Press Enter to continue') for index in range(len(tags)): for i in range(CALI_POS_SAMPLES): data[index].append(tags[index].magnetometer.read()) #data[index].append([20+(index+i)*10,20+(index+i)*10,20+10*(index+i)]) cali_para = [] #print(pos_m) for i in range(len(tags)): cali_para.append([]) pos_l = pos_dict['Sensor' + str(i)].copy() cali_para[i] = cali_funcs.calibrateSensor(data[i], pos_m, h, pos_l, CALI_ITER, offsets[i]).copy() print('Calibration Finished') print('Calibration Parameters: ') print(cali_para) tmp = input('Press Enter to continue') '''
def main(): import time import sys import argparse parser = argparse.ArgumentParser() parser.add_argument('host', action='store', help='MAC of BT device') parser.add_argument('-n', action='store', dest='count', default=0, type=int, help="Number of times to loop data") parser.add_argument('-t', action='store', type=float, default=5.0, help='time between polling') parser.add_argument('-T', '--temperature', action="store_true", default=False) parser.add_argument('-A', '--accelerometer', action='store_true', default=False) parser.add_argument('-H', '--humidity', action='store_true', default=False) parser.add_argument('-M', '--magnetometer', action='store_true', default=False) parser.add_argument('-B', '--barometer', action='store_true', default=False) parser.add_argument('-G', '--gyroscope', action='store_true', default=False) parser.add_argument('-K', '--keypress', action='store_true', default=False) parser.add_argument('-L', '--light', action='store_true', default=False) parser.add_argument('--all', action='store_true', default=False) arg = parser.parse_args(sys.argv[1:]) print('Connecting to ' + arg.host) tag = sensortag.SensorTag(arg.host) # Enabling selected sensors if arg.temperature or arg.all: tag.IRtemperature.enable() if arg.humidity or arg.all: tag.humidity.enable() if arg.barometer or arg.all: tag.barometer.enable() if arg.accelerometer or arg.all: tag.accelerometer.enable() if arg.magnetometer or arg.all: tag.magnetometer.enable() if arg.gyroscope or arg.all: tag.gyroscope.enable() if arg.keypress or arg.all: tag.keypress.enable() tag.setDelegate(sensortag.KeypressDelegate()) if arg.light and tag.lightmeter is None: print("Warning: no lightmeter on this device") if (arg.light or arg.all) and tag.lightmeter is not None: tag.lightmeter.enable() # Some sensors (e.g., temperature, accelerometer) need some time for initialization. # Not waiting here after enabling a sensor, the first read value might be empty or incorrect. time.sleep(1.0) counter = 1 while True: if arg.temperature or arg.all: print('Temp: ', tag.IRtemperature.read()) if arg.humidity or arg.all: print("Humidity: ", tag.humidity.read()) if arg.barometer or arg.all: print("Barometer: ", tag.barometer.read()) if arg.accelerometer or arg.all: print("Accelerometer: ", tag.accelerometer.read()) if arg.magnetometer or arg.all: print("Magnetometer: ", tag.magnetometer.read()) if arg.gyroscope or arg.all: print("Gyroscope: ", tag.gyroscope.read()) if (arg.light or arg.all) and tag.lightmeter is not None: print("Light: ", tag.lightmeter.read()) if counter >= arg.count and arg.count != 0: break counter += 1 tag.waitForNotifications(arg.t) tag.disconnect() del tag
def main(): #add parse arguement parser = argparse.ArgumentParser() parser.add_argument('host', action='store', help='MAC of BT device') parser.add_argument('-f', '--filepath', action='store', help='path/to/output_csv_file', default='./') #parser.add_argument('-n', action='store', dest='count', default=0, type=int, help="Number of times to loop data") parser.add_argument('-t', action='store', type=float, default=1.0, help='time between polling') parser.add_argument('-T', '--temperature', action="store_true", default=False) parser.add_argument('-A', '--accelerometer', action='store_true', default=False) parser.add_argument('-H', '--humidity', action='store_true', default=False) parser.add_argument('-M', '--magnetometer', action='store_true', default=False) parser.add_argument('-B', '--barometer', action='store_true', default=False) parser.add_argument('-G', '--gyroscope', action='store_true', default=False) #parser.add_argument('-K','--keypress', action='store_true', default=False) #parser.add_argument('-L','--light', action='store_true', default=False) parser.add_argument('--all', action='store_true', default=False) #parse arguments arg = parser.parse_args(sys.argv[1:]) #connect to sensor tag print('Connecting to ' + arg.host) tag = sensortag.SensorTag(arg.host) print('Connection Successful') # Enabling selected sensors if arg.temperature or arg.all: tag.IRtemperature.enable() print('IRtemperature Sensor Enabled') if arg.humidity or arg.all: tag.humidity.enable() print('Humidity Sensor Enabled') if arg.barometer or arg.all: tag.barometer.enable() print('Barometer Sensor Enabled') if arg.accelerometer or arg.all: tag.accelerometer.enable() print('Accelerometer Sensor Enabled') if arg.magnetometer or arg.all: tag.magnetometer.enable() print('Magnetometer Sensor Enabled') if arg.gyroscope or arg.all: tag.gyroscope.enable() print('Gyroscope Sensor Enabled') #if arg.keypress or arg.all: # tag.keypress.enable() # tag.setDelegate(sensortag.KeypressDelegate()) #if arg.light and tag.lightmeter is None: # print("Warning: no lightmeter on this device") #if (arg.light or arg.all) and tag.lightmeter is not None: # tag.lightmeter.enable() #wait for sensor initialization time.sleep(1.0) n = datetime.now() print('Start Measuring...') #store pid pid_filename = arg.filepath + str(n.year) + '-' + str(n.month) + '-' + str( n.day) + '_raw_data.pid' pid_file = open(pid_filename, 'w') pid_file.write(str(os.getpid())) pid_file.close() #create new csv file filename = arg.filepath + str(n.year) + '-' + str(n.month) + '-' + str( n.day) + '_raw_data.csv' file = open(filename, 'w') #write csv headers file.write('Time,') file.write('Ambient Temperature (degC),') file.write('Object Temperature (degC),') file.write('Humidity (RH),') file.write('Barometer (millibars),') file.write('Accelerometer-x (g),') file.write('Accelerometer-y (g),') file.write('Accelerometer-z (g),') file.write('Magnetometer-x (uT),') file.write('Magnetometer-y (uT),') file.write('Magnetometer-z (uT),') file.write('Gyroscope-x (deg/sec),') file.write('Gyroscope-y (deg/sec),') file.write('Gyroscope-z (deg/sec)\n') while True: file.write(str(datetime.now()) + ',') if arg.temperature or arg.all: file.write(str(tag.IRtemperature.read()[0]) + ',') file.write(str(tag.IRtemperature.read()[1]) + ',') if arg.humidity or arg.all: file.write(str(tag.humidity.read()[1]) + ',') if arg.barometer or arg.all: file.write(str(tag.barometer.read()[1]) + ',') if arg.accelerometer or arg.all: file.write(str(tag.accelerometer.read()[0]) + ',') file.write(str(tag.accelerometer.read()[1]) + ',') file.write(str(tag.accelerometer.read()[2]) + ',') if arg.magnetometer or arg.all: file.write(str(tag.magnetometer.read()[0]) + ',') file.write(str(tag.magnetometer.read()[1]) + ',') file.write(str(tag.magnetometer.read()[2]) + ',') if arg.gyroscope or arg.all: file.write(str(tag.gyroscope.read()[0]) + ',') file.write(str(tag.gyroscope.read()[1]) + ',') file.write(str(tag.gyroscope.read()[2]) + '\n') file.flush() tag.waitForNotifications(arg.t) file.close() tag.disconnect()
def main(): #add parse arguement parser = argparse.ArgumentParser() parser.add_argument('host', action='store', help='MAC of BT device') path_to_curr = os.path.dirname(os.path.abspath(__file__)) + '/' parser.add_argument('-f', '--filepath', action='store', help='path/to/output_csv_file', default=path_to_curr) #parser.add_argument('-n', action='store', dest='count', default=0, type=int, help="Number of times to loop data") parser.add_argument('-t', action='store', type=float, default=1.0, help='time between polling') parser.add_argument('-T', '--temperature', action="store_true", default=False) parser.add_argument('-A', '--accelerometer', action='store_true', default=False) parser.add_argument('-H', '--humidity', action='store_true', default=False) parser.add_argument('-M', '--magnetometer', action='store_true', default=False) parser.add_argument('-B', '--barometer', action='store_true', default=False) parser.add_argument('-G', '--gyroscope', action='store_true', default=False) parser.add_argument('-K', '--keypress', action='store_true', default=False) parser.add_argument('-L', '--light', action='store_true', default=False) parser.add_argument('--all', action='store_true', default=False) #parse arguments arg = parser.parse_args(sys.argv[1:]) print(str(datetime.now()) + ' ' + 'Starting...') time.sleep(3.0) #connect to sensor tag print(str(datetime.now()) + ' ' + 'Connecting to ' + arg.host) tag = sensortag.SensorTag(arg.host) print(str(datetime.now()) + ' ' + 'Connection Successful') enableSensors(arg, tag) sys.stdout.flush() #wait for sensor initialization time.sleep(1.0) n = datetime.now() print(str(datetime.now()) + ' ' + 'Start Measuring...') #store pid #pid_filename=arg.filepath+str(n.year)+'-'+str(n.month)+'-'+str(n.day)+'_raw_data.pid' pid_filename = arg.filepath + 'sensor.pid' pid_file = open(pid_filename, 'w') pid_file.write(str(os.getpid())) pid_file.close() #create new csv file filename = arg.filepath + str(n.year) + '-' + str(n.month) + '-' + str( n.day) + '_raw_data.csv' file = open(filename, 'a') ''' #write csv headers header_buffer='' header_buffer+=('Time,') if arg.temperature or arg.all: header_buffer+=('Ambient Temperature (degC),') header_buffer+=('Object Temperature (degC),') if arg.humidity or arg.all: header_buffer+=('Humidity (RH),') if arg.barometer or arg.all: header_buffer+=('Barometer (millibars),') if arg.accelerometer or arg.all: header_buffer+=('Accelerometer-x (g),') header_buffer+=('Accelerometer-y (g),') header_buffer+=('Accelerometer-z (g),') if arg.magnetometer or arg.all: header_buffer+=('Magnetometer-x (uT),') header_buffer+=('Magnetometer-y (uT),') header_buffer+=('Magnetometer-z (uT),') if arg.gyroscope or arg.all: header_buffer+=('Gyroscope-x (deg/sec),') header_buffer+=('Gyroscope-y (deg/sec),') header_buffer+=('Gyroscope-z (deg/sec),') if (arg.light or arg.all) and tag.lightmeter is not None: header_buffer+=('Light (lux),') file.write(header_buffer[:-1]) file.write('\n') ''' if os.stat(filename).st_size == 0: #first time create file print(str(datetime.now()) + ' ' + 'Writing CSV Header...') write_csv_header(file, arg, tag) #create connection to analyzer server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((ANALYZER_IP, analyzer.PORT)) while True: file = update_file_des(file, arg, tag) line_buffer = '' try: #file.write(str(datetime.now())+',') #Update connected reponse = req.post(CONNECTED_URL, data='ON') line_buffer += (str(datetime.now()) + ',') #create new dataPoint for analysis newPoint = dict() if arg.temperature or arg.all: #file.write(str(tag.IRtemperature.read()[0])+',') #file.write(str(tag.IRtemperature.read()[1])+',') line_buffer += (str(tag.IRtemperature.read()[0]) + ',') line_buffer += (str(tag.IRtemperature.read()[1]) + ',') try: s.sendall(str(datetime.now())) s.sendall(str(tag.IRtemperature.read()[0])) s.sendall(str(tag.IRtemperature.read()[1])) except: #reconnect s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((ANALYZER_IP, analyzer.PORT)) reponse = req.post(AMBIENT_TEMP_URL, data=str( round(tag.IRtemperature.read()[0], 1))) reponse = req.post(OBJECT_TEMP_URL, data=str( round(tag.IRtemperature.read()[1], 1))) if arg.humidity or arg.all: #file.write(str(tag.humidity.read()[1])+',') line_buffer += (str(tag.humidity.read()[1]) + ',') reponse = req.post(HUMIDITY_URL, data=str(round(tag.humidity.read()[1], 1))) if arg.barometer or arg.all: #file.write(str(tag.barometer.read()[1])+',') line_buffer += (str(tag.barometer.read()[1]) + ',') reponse = req.post(BAROMETER_URL, data=str(round(tag.barometer.read()[1], 1))) if arg.accelerometer or arg.all: #file.write(str(tag.accelerometer.read()[0])+',') #file.write(str(tag.accelerometer.read()[1])+',') #file.write(str(tag.accelerometer.read()[2])+',') line_buffer += (str(tag.accelerometer.read()[0]) + ',') line_buffer += (str(tag.accelerometer.read()[1]) + ',') line_buffer += (str(tag.accelerometer.read()[2]) + ',') reponse = req.post(ACCELEROMETERX_URL, data=str( round(tag.accelerometer.read()[0], 1))) reponse = req.post(ACCELEROMETERY_URL, data=str( round(tag.accelerometer.read()[1], 1))) reponse = req.post(ACCELEROMETERZ_URL, data=str( round(tag.accelerometer.read()[2], 1))) if arg.magnetometer or arg.all: line_buffer += (str(tag.magnetometer.read()[0]) + ',') line_buffer += (str(tag.magnetometer.read()[1]) + ',') line_buffer += (str(tag.magnetometer.read()[2]) + ',') reponse = req.post(MAGNETOMETERX_URL, data=str( round(tag.magnetometer.read()[0], 1))) reponse = req.post(MAGNETOMETERY_URL, data=str( round(tag.magnetometer.read()[1], 1))) reponse = req.post(MAGNETOMETERZ_URL, data=str( round(tag.magnetometer.read()[2], 1))) if arg.gyroscope or arg.all: line_buffer += (str(tag.gyroscope.read()[0]) + ',') line_buffer += (str(tag.gyroscope.read()[1]) + ',') line_buffer += (str(tag.gyroscope.read()[2]) + ',') reponse = req.post(GYROSCOPEX_URL, data=str(round(tag.gyroscope.read()[0], 1))) reponse = req.post(GYROSCOPEY_URL, data=str(round(tag.gyroscope.read()[1], 1))) reponse = req.post(GYROSCOPEZ_URL, data=str(round(tag.gyroscope.read()[2], 1))) if (arg.light or arg.all) and tag.lightmeter is not None: line_buffer += (str(tag.lightmeter.read()) + ',') reponse = req.post(LIGHT_URL, data=str(round(tag.lightmeter.read(), 1))) file.write(line_buffer[:-1]) file.write('\n') file.flush() tag.waitForNotifications(arg.t) except bluepy.btle.BTLEException as exception: #Update connected reponse = req.post(CONNECTED_URL, data='OFF') print( str(datetime.now()) + ' ' + str(type(exception).__name__) + 'caught') print(str(datetime.now()) + ' ' + 'RECONNECTING...') tag = sensortag.SensorTag(arg.host) enableSensors(arg, tag) #file.flush() #tag.waitForNotifications(arg.t) file.close() tag.disconnect()
import os import sys import time from bluepy import sensortag #tag = sensortag.SensorTag('24:71:89:07:84:03') tag = sensortag.SensorTag(str(sys.argv[1])) count = 0 time.sleep(1.0) tag.lightmeter.enable() tag.humidity.enable() while True: tag.waitForNotifications(1.0) os.system( "mosquitto_pub -h localhost -t \'IoT-Gateway01/ble/status\' -m \'SensorTag Connected\'" ) lightdata = tag.lightmeter.read() tempdata = tag.humidity.read() print lightdata print tempdata[0] #print humidata[1] os.system( "mosquitto_pub -h localhost -t \'IoT-Gateway01/ble/lightdata\' -m \'" + str(lightdata) + "'") os.system( "mosquitto_pub -h localhost -t \'IoT-Gateway01/ble/tempdata\' -m \' " + str(tempdata[0]) + "\'")
import EV3BT import serial import time from bluepy import sensortag as sensortag # Since we could not find our sensor tag # after running bluetooth scans, we don't have # its' MAC address. The code below requires a an actual MAC address sensor_tag_mac = 'OUR_SENSOR_TAG_MAC_ADDRESS' sensor_tag = sensortag.SensorTag(sensor_tag_mac) # Function that reads light data from the sensortag def getLightData(): sensor_tag.lightmeter.enable() lightData = sensor_tag.lightmeter.read() return lightData EV3 = serial.Serial(port='/dev/rfcomm0', baudrate=9600, timeout=None) print(EV3.name) print(EV3.is_open) try: while (1): lightData = getLightData() print(lightData) send = EV3BT.encodeMessage(EV3BT.MessageType.Numeric, '1231413', lightData) EV3.write(send)
import paho.mqtt.client as mqtt import time from bluepy import sensortag # message callback def onMessage(client, obj, msg): print(str(msg.topic) + str(msg.payload)) mqttC = mqtt.Client() mqttC.connect("test.mosquitto.org", 1883) # connect to server mqttC.subscribe("temperature") # topic/sensorTag readings(replace with actual data) mqttC.subscribe("humidity") mqttC.on_message = onMessage # callback mqttC.loop_start() tag = sensortag.SensorTag('BC:6A:29:AC:53:D1') # sensor address time.sleep(1.0) tag.IRtemperature.enable() tag.waitForNotifications(1.0) while(1): # get sensorTag data here time.sleep(1) # rate of updates mqttC.publish("temperature", tag.IRtemperature.read()) # publish temperature(replace with actual data) mqttC.publish("humidity", 20.1) # publish humidity(replace with actual data)
plt.ylabel("std dev") fig_tags = {} # holds the plots of repective tags fig = plt.figure() ax = fig.add_subplot(111) fig.show() j = 0 x, y = [], [] tags = {} # tags will have the sensortags objects queue = { } # queue is a dictionary which holds deque of the tags(will have the same keys) #for loop to enable the sensor tags and create respective deque and store the addresses in tags and queue dictionary var for future use for key in mysensors.keys(): try: tag = sensortag.SensorTag(mysensors[key]['tag_address']) print("Connected to sensortag", mysensors[key]) tag.lightmeter.enable() mysensors[key]['isAlive'] = True print("hello") tags[key] = tag # creating queue for the tag len_q_test = 4 d1 = collections.deque([], len_q_test) queue[key] = d1 except: print("not connected to ", mysensors[key]) continue #publishing initial info to the broker
# -*- coding: utf-8 -*- import time import json from bluepy import sensortag as sensortag import paho.mqtt.publish as mqtt my_sensor = "B8:27:EB:C2:86:A3" tag = sensortag.SensorTag(my_sensor) print("Connected to SensorTag", my_sensor) base_topic = "all" while True: tag.IRtemperature.enable() tag.humidity.enable() tag.barometer.enable() tag.accelerometer.enable() tag.magnetometer.enable() tag.gyroscope.enable() msgs = [] ambient_temp, target_temp = tag.IRtemperature.read() acc_x, acc_y, acc_z = tag.accelerometer.read() ambient_temp, rel_humidity = tag.humidity.read() ambient_temp, pressure_millibars = tag.barometer.read() mag_x, mag_y, mag_z = tag.magnetometer.read() gyr_x, gyr_y, gry_z = tag.gyroscope.read()