connect@howdiyworld.com
|

Alexa IoT (Voice Command) Home Automation

What is Needed?

LED
Alexa Device
Jumpers
HowDIY

BLOCK DIAGRAM

Procedure

  1. Alexa Device, LED
  2. Connections
  3. Program
  4. Output

Procedure

LED

A LED or Light Emitting Diode is a Semiconductor  two terminal(Pin) component, the two terminals are (+)Positive and (-)Negative. The voltage is applied to positive terminal and negative terminal should be ground light is emitted. Here we are using 12V LED so the maximum Voltage for positive terminal is 12V and minimum is 3V. If we use anything above 12V the LED will get short circuit.

Setting up Alexa

Download Alexa Mobile Application.

  • Sign in, scan and add new device(Alexa Dot) in Alexa App.
  • Connect alexa to wifi.
  • Alexa and HowDIY must be connected same wifi.

Amazon Alexa

Amazon Echo is a smart speaker that responds to voice commands using Alexa, its artificially intelligent personal assistant. All Echo models can answer questions, research the internet, command smart home devices, and stream music.

Connections

  • Connect LED’s Positive(+) to 3rd pin
  • Connect LED’s Negative(-) to 14th pin

Program

import time
import sys
import RPi.GPIO as GPIO ## Import GPIO library
GPIO.setwarnings(False) #Set Warnings Initial False
GPIO.setmode(GPIO.BOARD) # Set BOARD Mode
GPIO.setup(3,GPIO.OUT) # Set Output Device
from debounce_handler import debounce_handler

logging.basicConfig(level=logging.DEBUG)

class device_handler(debounce_handler):
#TRIGGERS = {str(sys.argv[1]): int(sys.argv[2])}
#TRIGGERS = {“Light": 52000}
TRIGGERS = {“LED": 52000,"FAN":51000}

def act(self, client_address, state, name):
print(“State", state, “from client @", client_address)
print(state)
if state==True: # Check the State True
GPIO.output(3,True) # If its True
if state==False: # Check the State False
GPIO.output(3,False)
if name=="kitchen":
GPIO.output(int(7), state) ## State is true/false
elif name =="living room":
GPIO.output(int(11), state) ## State is true/false
else:
print(“Device not found!")

return True

if __name__ == “__main__":
# Startup the fauxmo server
fauxmo.DEBUG = True
p = fauxmo.poller()
u = fauxmo.upnp_broadcast_responder()
u.init_socket()
p.add(u)

# Register the device callback as a fauxmo handler
d = device_handler()
for trig, port in d.TRIGGERS.items():
fauxmo.fauxmo(trig, u, p, None, port, d)

# Loop and poll for incoming Echo requests
logging.debug(“Entering fauxmo polling loop")
while True:
try:
# Allow time for a ctrl-c to stop the process
p.poll(100)
time.sleep(0.1)
except Exception as e:
logging.critical(“Critical exception: “+ e.args )
break

Output

Now, you can control your Light or Fan Using Voice command.

To stop the IoT Home Automation press Ctrl + C.

Social media & sharing icons powered by UltimatelySocial
Facebook
Twitter
YouTube
LinkedIn
Instagram