time.sleep(1)
board.output(200)
time.sleep(1)

# create folder to store data
timestr = time.strftime("%Y%m%d-%H%M%S")
path = '/home/pi/Desktop/Data/' + timestr + '/'
if not os.path.exists(path):
    os.makedirs(path)

try:
    while True:
        t1 = Thread(target=turn_on, args=(pin1, ))

        force = board.custom()  # force sensor data
        float_list = data_function.round_floatlist(
            lsm6ds33.get_accelerometer_g_forces(), 3)  # accel data
        float_list.append(data_function.rss_floatlist(float_list))
        float_list.append(force)
        print("Local L data:", float_list)
        client_sock.send("100")  # request sensor data from client

        #time.sleep(0.01)

        recv_data = client_sock.recv(100).decode("utf-8")  #1024 in example
        print("received R data: [%s]" % recv_data)
        recv_data = data_function.convert_data(recv_data)
        #print("received R data:", recv_data)

        # model prediction
        if (recv_data[-1] >= 3):
            board.output(200)  # turn on LED on ADDA board
Exemplo n.º 2
0
while (1):
    ##    print("%s: control:%d light:%d temp:%d custom:%d" % (time.asctime(),
    ##                                                         board.control(),
    ##                                                         board.light(),
    ##                                                         board.temperature(),
    ##                                                         board.custom()))
    value = board.custom()
    accel_g_force_L = lsm6ds33.get_accelerometer_g_forces()

    print("%s: force_sensor:%d" % (time.asctime(), value))
    #print(type(value))
    print("Accel_g_force:", accel_g_force_L)
    #print(type(accel_g_force_L))
    float_list = accel_g_force_L
    float_list = data_function.round_floatlist(float_list, 3)
    float_list.append(data_function.rss_floatlist(float_list))
    float_list.append(value)
    print(float_list)
    #print("Roll_Pitch:", lsm6ds33.get_accelerometer_angles())
    #print("Accel_3_angles:", lsm6ds33.getAccelerometer3Angles())

    if (value >= 3):
        board.output(200)  # turn on LED on ADDA board
        #GPIO.output(pin, (GPIO.LOW if state == 0 else GPIO.HIGH))
        GPIO.output(pin1, (GPIO.HIGH))
    #else:
    #GPIO.output(pin2, (GPIO.HIGH))
    #sleep(0.05)

    # save data