Have you ever thought about a speaker which can be controlled by your voice!!! What if we can control our home appliances this way and make these appliances smarter? Voice assistants are becoming more popular as we are heading towards an era of AI and IoT based systems. You have heard about Google Assistant, Apple Siri and Amazon Alexa. These all are Voice based AI systems, what makes these different from each other is their ecosystems, and this is where Amazon Alexa stands out the most. Google, Apple and Amazon, all these companies already launched their smart speakers but Amazon was first to introduce them. Amazon echo, Echo Dot Spot, etc. are the smart speakers which are available in the market.

Amazon provides the API for using its much popular voice service, Alexa. It is open source and available on Github. Further you can install or integrate Alexa on custom devices like Raspberry Pi and get the full Amazon Echo functionality in that device.

Using Alexa voice service, we can play music, get information about weather, book tickets and many more. All you have to do is ask. In a previous tutorial we have controlled Raspberry Pi GPIO using Amazon Alexa. In this tutorial, let’s see how to build a voice controlled home automation system using Amazon Alexa and Raspberry Pi. We will see how we can use Raspberry Pi to run the Alexa Voice Service and control a Light Bulb.

Parts List:

  1. Raspberry Pi 3 [Recommended] or Raspberry Pi 2 Model B [Supported] and SD Card (8GB or more)
  2. External Speaker with 3.5mm AUX cable
  3. Any Webcam or USB 2.0 Microphone
  4. Relay module
  5. LED/ AC Bulb
Webcam as USB microphone

Software Apps and Web Requirements:

  1. Register an account with Alexa Voice Services
  2. Register an account with PubNub
  3. Register an account with IFTTT

5 parts:

  1. Setting up Raspberry Pi with SSH and VNC, also check the USB Microphone connectivity.
  2. Set up Amazon Developer and installing Alexa on Raspberry Pi
  3. Setting up PubNub and IFTTT for Alexa Home Automation
  4. Hardware connection
  5. Python code for Alexa Pi Home Automation

Project Demo:

Part 1: Setting up the Raspberry Pi with SSH and VNC

First, I will connect Raspberry Pi with SSH and VNC. 

For SSH: SSh link

For VNC : VNC link

Part 2: Setting up Amazon Developer Account and Configure Alexa Voice Services on Raspberry Pi:

To test Alexa, just wake her up by saying her name.

You can ask her about the temperature of your city to check if it is working or not.

Part 3: Setting up PubNub and IFTTT for Alexa Pi Home Automation:

For building a home automation system using this Alexa Pi, I need the help of PubNub python SDK and IFTTT. I will give commands to IFTTT through Alexa, and PubNub gives signal to RPi to On/Off the light. So I will first install the PubNub on Raspberry Pi. IFTTT is a free web-based service that allows users to create chains of simple conditional statements, called “recipes”, which are triggered based on changes to other web services such as Gmail, Facebook, Instagram, and Pinterest. IFTTT is an abbreviation of “If This Then That”.

For this project, IFTTT is used to trigger the light switch on/off commands based on the speech command received by the Alexa service running on RPi.

Part 4: Hardware connections and Circuit Diagram:

For this project, I need a Relay Module and AC bulb or any other AC component or you can use a simple LED for testing purposes. Below is the circuit diagram and Hardware connections to control the AC Appliance with Amazon Alexa.

I will use GPIO18 in the python script, so connect relay to GPIO 18. I can change this in python script.

Circuit diagram for Voice controlled Home automation using Amazon Alexa on Raspberry Pi
Circuit Hardware for Voice controlled Home automation using Amazon Alexa on Raspberry Pi

Part 5: Python Code for Controlling the Light:

To give any command you need to wake up Alexa service by calling “Alexa” each time you want to send a command. You will hear a beep sound. Once you hear the beep, say “Alexa Trigger Turn on the Light.” You can see the light turns ON within a moment. And then if you say “Alexa Trigger Turn off the Light”, the light should turn OFF.

Categories: Uncategorized

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

css.php