Andreas Kopp
Published © CC BY-SA

IFTTT Buzzer with IFTTT Do Button and Raspberry Pi

How do build a really easy door buzzer with the DO Button App, on your phone , IFTTT, Raspberry Pi and python and the MQTT Broker Device

IntermediateWork in progress11,879
IFTTT Buzzer with IFTTT Do Button and Raspberry Pi

Things used in this project

Hardware components

Raspberry Pi 2 Model B
Raspberry Pi 2 Model B
×1
GrovePi+
×1
Grove Relay
×1
Grove LED
×1
Grove Buzzer
×1

Software apps and online services

DeviceHub Cloud Service - Free package
DeviceHub.net DeviceHub Cloud Service - Free package
Maker service
IFTTT Maker service
Do Button

Story

Read more

Schematics

Schematic

Code

iot_button

Python
#!/usr/bin/env python

from devicehub.devicehub import Sensor, Actuator, Device, Project

import threading

from time import sleep

import RPi.GPIO as GPIO

import json

import grovepi

PROJECT_ID     = ''  #projekct_id

DEVICE_UUID    = '' #device_uuid

API_KEY        = '' #api_key

ACTUATOR_NAME1 = '' #do_button

# init pin

button = 2

relay = 4

led = 3

buzzer = 8

grovepi.pinMode(button,"INPUT")

grovepi.pinMode(relay,"OUTPUT")

grovepi.pinMode(buzzer,"OUTPUT")

grovepi.pinMode(led,"OUTPUT")

def switchRelay(state):

  grovepi.digitalWrite(relay,1)

  grovepi.digitalWrite(buzzer,1)

  sleep(1)

  grovepi.digitalWrite(relay,0)

  grovepi.digitalWrite(buzzer,0)

  grovepi.digitalWrite(led,1)     # Send HIGH to switch on LED

  sleep(1)

  grovepi.digitalWrite(led,0)     # Send LOW to switch off LED


    print "PIN ", relay, " state: ", state



def act1_callback(payload):

    """

    :param payload: payload sent to actuator

    """

    # handles message arrived on subscribed topic

    msg = str(payload)

    act_state = ACT1.state

    print "act1", act_state

    switchRelay(act_state)

project = Project(PROJECT_ID)

device = Device(project, DEVICE_UUID, API_KEY)

ACT1 = Actuator(Actuator.DIGITAL, ACTUATOR_NAME1)

device.addActuator(ACT1, act1_callback)

try:

    while True:

        pass

except KeyboardInterrupt:

    GPIO.cleanup()

Credits

Andreas Kopp

Andreas Kopp

1 project • 3 followers
Big thoughts and small actions make a difference

Comments