Ever imagined building a hands-free speaker that you can control with your voice. Wouldn’t it be even better if we could also control home appliances this way? In this blog series, let’s see how to build a voice controlled home automation system using Amazon Alexa and Raspberry Pi. I will show you how we can use Raspberry Pi to run the Alexa Voice Service and control a Light Bulb.
Alexa Voice Service provides us the facility to play music, provide information, news, sports scores, weather, and more—instantly. All you have to do is ask.
In this first post of the series, we will setup Amazon Alexa on Raspberry Pi.
Note: The supply of 230v is country specific. Make sure to check this and choose the relays and light fixture as per your country specific settings.
And here is how the voice controlled home automation demo will function.
Once you are ready with the hardware setup, let’s work on the software side of the Project. But first, we will setup the VNC Server and Viewer for accessing Raspberry Pi from a laptop. I have followed the official Github Repo for setting up the Alexa and customized for installation steps for this demo.
Initially start with Raspberry Pi connected to a Monitor and install SSH Server with the following command.
$ sudo apt-get install openssh-server
On the latest Raspian OS, SSH Server is enabled by default. If you run into problems with getting the SSH to work, use the raspian-config utility to check it is enabled.
So, now let’s SSH into Raspberry Pi to get rid of Keyboard, Mouse, and Monitor with Rpi. To do that, you need to know the IP address of your Raspberry Pi.
Type this command into the terminal:
$ hostname -I > 192.168.1.133 //this is an example Raspberry Pi’s IP - it would be different for you
If you’re on a Windows PC, follow the instructions here to SSH Using Windows
Now that you know the IP address of your Pi, you are ready to connect to it remotely using SSH. To do this, open the terminal utility on the computer you would like to connect from and type the following:
ssh [email protected]<YOUR Raspberry Pi IP ADDRESS>
It will prompt you for your password, enter default password for the user pi is raspberry. Now, we are ready to setup the VNC.
For setting up the VNC server, we have to install
tightvncserver on the Raspberry Pi. Open the Serial Terminal and install using the following command,
sudo apt-get install tightvncserver
Once Installation is completed to run the VNC Server, type the following command on terminal
Make sure that tightvncserver is running otherwise, the remote access to Raspberry Pi using VNC Viewer will not work.
Autostart and run VNCServer at Startup
To auto start the application on the bootup, type the following in the terminal:
cd /home/pi cd .config
Note the ‘.’ at the start of the folder name. This makes it a hidden folder that will not show up when you type ‘ls’.
mkdir autostart cd autostart
Create a new configuration by typing the following command:
Edit the contents of the file with the following text:
[Desktop Entry] Type=Application Name=TightVNC Exec=vncserver :1 StartupNotify=false
Type ctrl-X and then Y, and then press Enter to save the changes to the file.
That’s it. The next time you reboot, the VNC server will restart automatically.
First download VNC Viewer on your laptop and then,
In this section, let’s setup the Alexa with Raspberry Pi
To install Alexa on Raspberry Pi, follow the official link for installation, Setting up Alexa RPi.
In the end, you will have three terminals on Raspberry Pi.
So this will be our complete setup with Alexa. In a subsequent blog post, we will see how to setup the IFTTT and other components of hardware to complete the project. See you soon !!
Surya is a hardware buff and tinkerer who loves all the stuff around IoT. He is a specialist in building proof-of-concepts around electronic hardware and conceptualizing use cases and solutions for Internet of Things. When not working with hardware, Surya can still be found fiddling with some crazy hardware design, trying to bring out an idea out of a raw circuit.
This Alexa Powered Dictionary Bot Can Expedite Your Vocabulary Buildup
Voice Controlled Home Automation using Alexa – Part 2
Voice Activated Trading Bot Powered By IBM Watson Text-to-Speech Service
Worrying About Rising Energy Bills? Realtime IoT Energy Management Is At Your Disposal
Please log in again. The login page will open in a new window. After logging in you can close it and return to this page.