Exemplo n.º 1
0
def init_trig_with_BuzzandTemp(motion):
    """
    Waits up to 4 seconds until corresponding sensor is triggered.
    If sensor triggered and temperature sensor not been triggered prior,
    buzzer will go off.
    If had triggered prior, direction of movement sent as message to server.

    Parameters:
    motion(int): Second motion sensor pin
    """
    for x in range(40):
        # Loop for 40 iterations.
        time.sleep(0.1)
        # Delay for 10ms.
        if (GPIO.input(motion) == 1):
            # Determines if corresponding motion sensor is triggered.
            if (motion == 1) and (!tempSensor.scanned):
                # Determines if user enters without temp scan.
                GPIO.setup(buzzerPin, GPIO.OUT)
                # Set buzzerPin to output mode.
                GPIO.output(buzzerPin, GPIO.HIGH)
                # Set buzzerPin high.
                time.sleep(2)
                # Delay for 2 seconds.
                GPIO.output(buzzerPin, GPIO.LOW)
                # Set buzzerPin low.
                print("BUZZ")
                break
            else:
                TCP.client(str(motion))
                # Sends direction of motion as message to the connected server.
                tempSensor.scanned = False
                break
Exemplo n.º 2
0
def speed(time, distance):
    """
    Calculates and sends speed as a message to server.

    Parameters:
    time(float): Time given in seconds
    distance(float): Distance given in meters
    """
    speed = distance/time
    # Calculates speed in meters/second.
    TCP.client(str(speed))
Exemplo n.º 3
0
def init_trig(motion):
    """
    Waits up to 4 seconds until corresponding sensor is triggered.
    motion(int): Second motion sensor pin
    """
    for x in range(40):
        # Loop for 40 iterations.
        time.sleep(0.1)
        # Delay for 10ms.
        if (GPIO.input(motion) == 1):
            # Determines if corresponding motion sensor is triggered.
                TCP.client(str(motion))
                # Sends direction of motion as message to the connected server.
                break
Exemplo n.º 4
0
def feverScanner(maxtemp):
    """
    Determines if an individual is standing infront of the temperature sensor,
    waits a full second and reads the temperature value again to gain a more
    stable value. Also determines if temperature is above that of the norm.
    This data is relayed as a message to the server.
    """
    global init
    global scanned
    tempReading()
    if (tdata[0] > roomtemp) and (tdata[0] > 30):
        if (!init):
            init = True
            feverScanner()
        else:
            init = False
            scanned = True
            TCP.client(str(tdata[0]))
            if (tdata[0]) > maxtemp:
                scanned = False
                time.sleep(1)