Smart Home Project

By: Roy Ben Moshe And Sergey Elishaev

The goal:

  • Build an “Amazon echo” with Raspberry Pi
  • Make it invoke by the voice command “Alexa” (As the original echo)
  • Use voice commands to turn a light on/off

The difficulties of the project:

One of the difficulties was to understand the communication between all Amazon services, in order to insert our functions in the right places and make it work properly.

In addition, it was not easy, and very interesting to build the electrical circuit; it was the first time we did something like this.

The needed equipment:

  • Raspberry pi (recommended: 3)
  • SD Card (at least 8GB, for the OS)
  • Keyboard and Mouse
  • Screen and HDMI cable (which can be connected to it)
  • USB microphone (or 3.5m microphone with an external USB sound-card)
  • Speaker (to hear the answers from Alexa)


Building the circuit:

All you need for it is a power-supply, relay (one or more, as the number of the devices you want to control) and the devices you want to connect (we used one relay and an AC power plugs and sockets, so that we could connect to it whatever we want).

You can look at the pictures of how we connected it.

  • Now you should add your “circuit” to the amazon developer console, go to:

Sign in to AWS Management console and from the “Services” select “AWS IoT”.

Create a “thing” and a “certificate” (When creating a certificate you will get links to download “public key”, “private key”, “certificate”, “rootCA”. Download and save them all for future).

After finish creating the certificate go to the certificate, and activate it, then “attach a thing” to it (from the Actions menu).

  • Now we can connect the RPI to the AWS IoT.

At the same window, go to “Services” → “Lambda” → “Create a Lambda function” → “Configure triggers”

Smart Home Project 001

Click the rectangle box to choose trigger source and select “Alexa Skills Kit”, and then choose the function name

Install node.js and npm on your RPI → create a directory and Install aws-iot-device-sdk module to the directory using the following commands:

mkdir awssdk

npm install –prefix ./awssdk aws-iot-device-sdk


Make a zip file and integrate all certificate files you got from AWS IoT thing and the previous command:

Smart Home Project 002

In order to send messages from your lambda function to the RPI you should install MQTT client.

Use the command:

sudo pip install paho-mqtt

Now you can run your code on the RPI, which responds to the received messages from Lambda function:

sudo python


Proposal for future projects:

  • Install a microphone on a drone and send the commands from the drone to the RPI
  • Add more commands to the created skill, e.g. play music from the RPI, read an e-book, etc.




Editing the given code:

Lambda function (index.js)

Edit the following variables:

deviceName is the thing name from AWS IoT

host is the address here:

app_id is the Application Id from Alexa skill

region: use “us-east-1” and make sure it’s the chosen region on, it should be N. Virginia

Client code (

Place the path of your certificates at the line:









Close Close