#!/usr/bin/python3
import iot
import time


# Kuuntele sanaa "hello", ja vastaa "Hello, world!"
@iot.subscribe("data_Aapo")
def testi(message):
    print(message)
    distance = float(message)
    if distance < 20.0:
        iot.say("Obstacle warning!")
        time.sleep(4)


iot.run("vastaanottaja_Aapo", "aalto-shiftr-testi", "aalto-shiftr-testi")

while True:
    pass
Example #2
0
@iot.listen("right")
def said_right():
    iot.publish("messages","right")
    iot.say("Asking the car to move right")

@iot.listen("green")
def said_green():
    iot.publish("messages","green")

@iot.listen("red")
def said_red():
    iot.publish("messages","red")
    
@iot.listen("animation")
def said_animation():
    iot.publish("messages","animation")

@iot.listen("no light")
def said_nolight():
    iot.publish("messages","nolight")

@iot.listen("How are you")
def said_How_are_you():
    iot.say("I'm good. Thank you for asking ")
    
'''@iot.listen("Tell me a joke")
def said_Tell_me_a_joke():
    iot.say("What is red and bad for your teeth?,, a brick. hehehe ")
'''
iot.run("voice1","shiftr-key","shiftr-secret")
Example #3
0
        car.stop()
    elif (message == "movebackward"):
        car.backward(100, 100)
        sleep(2)
        car.stop()
    elif (message == "moveright"):
        car.backward(100, 25)
        sleep(2)
        car.stop()
    elif (message == "moveleft"):
        car.backward(25, 100)
        sleep(2)
        car.stop()


iot.run("Raspberryauto", "shiftr-key", "shiftr-secret")
'''
car.stop()
car.forward(100, 100)
print("forward")
sleep(2)
car.stop()
car.backward(100,100)
print("back")
sleep(2)
car.forward(25,100)
print("Left")
sleep(1)
car.stop()
car.forward(100,25)
print("Right")
Example #4
0
#!/usr/bin/python3
import iot


@iot.listen("It's too hot")
def full_speed():
    iot.say("OK, turning the fan on")
    iot.publish("tuuletin","full")


@iot.listen("half power")
def half_speed():
    iot.say("OK, turning the fan off")
    iot.publish("tuuletin","half")


@iot.listen("It's too cold")
def off():
    iot.say("OK, turning the fan off")
    iot.publish("tuuletin","off")


iot.run("puheohjaus","aalto-shiftr-testi","aalto-shiftr-testi")


Example #5
0



BOT_API_TOKEN =<Insert Your Api token>
GROUP_ID = <insert your group id>
TG_URL = 'https://api.telegram.org/bot'+ BOT_API_TOKEN



@iot.listen("selfie")
def selfie():
    take_pic()

def take_pic():
    iot.say("Taking a selfie!")
    with picamera.PiCamera():
        with open("image.jpg", 'wb') as capture_file:
            camera.hflip = True # kaanna vaaka-akselin suhteen
            camera.vflip = True # peilikuva
            camera.resolution = (1296, 972)
            camera.capture(capture_file)
    
    with open(filename, 'rb') as capture_file:
        url = TG_URL + '/sendPhoto'
        files = {"photo": capture_file}
        res = requests.post(url, files=files, params={'chat_id': GROUP_ID})
iot.run()