/alexa-pi-furniture-control

🎤 Use Alexa & Raspberry Pi to control convertible furniture

Primary LanguagePythonMIT LicenseMIT

Alexa Pi Furniture Control

Summary

This demo moves convertible furniture up and down using Alexa, a Raspberry Pi, and a motor driver. With a few small modifications you could control anything using GPIO on the Raspberry Pi.

Diagram

Entire system

Setup

Alexa

Use skills JSON in alexa/ to create skills for your use case. Endpoints should be the ones from ngrok.

ngrok

Use ngrok to serve as a message passer between the Alexa service and the Raspberry Pi.

You will need to subscribe to get reserved endpoint addresses. Follow the instructions on the website to setup the endpoints, and to connect it to the Raspberry Pi.

Raspberry Pi

This is an extremely manual process because I was in a rush when I initially wrote this up. It can be put into a simple bash script to run on firstboot. Sorry.

sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install rpi.gpio -y
sudo apt-get install python3-pip -y
wget -q https://raw.githubusercontent.com/himalayanelixir/alexa-pi-furniture-control/master/raspberry-pi/requirements.txt /home/pi/
pip3 install -r /home/pi/requirements.txt
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip
unzip /path/to/ngrok.zip
./ngrok authtoken <YOUR_AUTH_TOKEN>
# change port depending on what you setup flask-ask with
./ngrok http 80 (other port)
# create services (copied and pasted from raspberry-pi/services/)
sudo nano /etc/systemd/system/alexamotor.service
sudo nano /etc/systemd/system/ngrok.service
sudo systemctl start alexamotor.service
sudo systemctl enable alexamotor.service
sudo systemctl start ngrok.service
sudo systemctl enable ngrok.service
sudo systemctl daemon-reload
# make sure services are enabled
sudo systemctl list-unit-files | grep enabled
wget -q https://raw.githubusercontent.com/himalayanelixir/alexa-pi-furniture-control/master/raspberry-pi/motor_control.py /home/pi/
sudo chmod +x /home/pi/motor-control.py

Motor Driver

To control the furniture you will just need a driver to communicate with from the Raspberry Pi to the motor. I used a simple Pololu G2 High-Power Motor Driver 24v13. If you are using a different one, just modify the GPIO pins that are turned on and off in raspberry-pi/motor-control.py.

Example

Got this code working with a convertible bed. The full video can be found here: https://youtu.be/vljLdq9bu4k.