try: #print('connection from', client_address) while True: cmd = connection.recv(8) if cmd == b'get_ori': t = sense.get_temperature() p = sense.get_pressure() h = sense.get_humidity() data = [{ "name": "acceleration", "data": sense.get_accelerometer(), "unit": "deg" }, { "name": "magnetic", "data": sense.get_compass_raw() }, { "name": "gyroscope", "data": sense.get_gyroscope(), "unit": "deg" }] dataJSON = json.dumps(data) msg = dataJSON.encode('utf-8') connection.sendall(msg) if cmd == b'get_env': data = [{ "name": "TemmperatureFromHumidity", "data": sense.get_temperature_from_humidity(), "unit": "C" }, { "name": "TemmperatureFromPressure",
# The Hardware I'm using are Raspberry pi and a SenseHat from sense_emu import SenseHat import time s = SenseHat() # Get the raw information of the compass raw = s.get_compass_raw() # Assign the compass values to x, y, and z x = raw["x"] y = raw["y"] z = raw["z"] # Dispaly the result on the screen s.show_message("coord" + str(int(x))) time.sleep(1) s.show_message("coord" + str(int(y))) time.sleep(1) s.show_message("coord" + str(int(z)))