Opening your garage door with just your voice may sound like something out of a sci-fi movie, but it's easier to accomplish than you think thanks to the Raspberry Pi. With a few components and some basic coding, I was able to create my own voice controlled IoT garage door opener.

In this comprehensive guide, I will walk through the entire process step-by-step. I will cover everything from selecting the right hardware, to installing the operating system, to coding the application logic. By the end, you will have the knowledge to build your own voice controlled garage door opener.

Hardware Needed

To build this project, you will need the following components:

Raspberry Pi

The brain of this project is the Raspberry Pi. This single board computer packs decent processing power in a small form factor.

I recommend getting the latest Raspberry Pi 4 model for this project. The 4 GB RAM version provides enough memory to run everything smoothly.

MicroSD Card

The Raspberry Pi boots from a MicroSD card, so you'll need one with at least 8 GB of storage. A 16 GB or 32 GB card provides room to grow. The SanDisk Extreme line offers good performance.

Power Supply

Get a 5V 3A USB-C power supply to deliver adequate power to the Pi. The official Raspberry Pi USB-C power supply works great.

Speaker and Microphone

A speaker and microphone are needed to interact with the voice assistant. The USB microphone from UGREEN provides good sound quality.

Any set of powered desktop speakers will work. Logitech and Creative Labs make quality options.


To open and close your garage door, you need a relay that can handle the current flowing to the motor. The Songle SRD-05VDC-SL-C 5V relay is a good choice.

Jumper Wires

Jumper wires make connecting components easy. Premium jumper wires from WINGONEER are my go-to.

Breadboard (Optional)

A solderless breadboard provides a simple way to prototype the circuit without soldering. Consider adding one.

Software Required

On the software side, you will need the following:

Raspberry Pi OS

The Raspberry Pi OS is the official operating system for Raspberry Pi. I recommend the 32-bit version with desktop and recommended software.

Python 3

The code will be written in Python. Version 3.7 or higher is required.

gpiozero Library

The gpiozero library for Python makes interfacing with GPIO pins simple. It gets installed with Raspberry Pi OS by default.

Speech Recognition and TTS

The excellent SpeechRecognition and pyttsx3 Python libraries provide speech recognition and text-to-speech capabilities.


IFTTT integrates with many Internet services. Here, it will enable voice control through Google Assistant.

Assembling the Hardware

With all the components ready, it's time to assemble the hardware. Here are the steps:

  1. Insert the MicroSD card loaded with Raspberry Pi OS into the Raspberry Pi.

  2. Connect the speaker and microphone to the USB ports on the Pi.

  3. Connect the relay module to the 5V and GND pins on the Pi header to power it.

  4. Wire the control pin on the relay to GPIO 4 on the Pi using a jumper wire.

  5. Supply power to the Pi with the official power supply.

At this point, your hardware setup should be complete. It's time to move on to the software portion.

Installing Required Software

With Raspbian OS running on the Raspberry Pi, open a terminal window to install the required software:

sudo apt update
sudo apt install python3-pip
pip3 install SpeechRecognition
pip3 install pyttsx3
pip3 install gpiozero

This will install the latest Python 3, the pip package manager, the SpeechRecognition and pyttsx3 libraries, and the gpiozero module.

Creating an IFTTT Applet

IFTTT provides the glue to enable Google Assistant integration. Here are the steps:

  1. Sign up for an IFTTT account if you don't already have one.

  2. Create a new applet with the "Google Assistant" service as the trigger.

  3. Select the "Say a simple phrase" trigger and customize it with your desired phrase like "Open the garage door".

  4. Add the Webhooks service as the action.

  5. Enable the "Make a web request" action.

  6. Configure it to do a POST request to the webhook URL you will create later.

That's it! Now your Google Assistant is ready to interface with your Pi.

Coding the Application Logic

Here is how to code the application logic in Python to enable voice control:

Import Required Modules

import speech_recognition as sr
import pyttsx3
from gpiozero import OutputDevice
import requests

Initialize Text-to-Speech

engine = pyttsx3.init()

Initialize Voice Recognition

recognizer = sr.Recognizer()
mic = sr.Microphone()

Define Variables

relay = OutputDevice(4)

Create Speech Recognition Function

def listen():
with mic as source:
audio = recognizer.listen(source)
response = recognizer.recognize_google(audio)
return response

Main Application Loop

while True:
response = listen()
if response == "Open the garage door":
engine.say("Opening garage door")

This main loop constantly listens for voice commands usingSpeechRecognition. When the programmed phrase is heard, it activates the relay to open the garage door!

Testing It Out

The moment of truth has arrived. Follow these steps to test out your creation:

  1. Run the Python application on your Raspberry Pi.

  2. Say "OK Google" and then your custom phrase "Open the garage door" into the microphone.

  3. The relay should turn on, opening the garage door!

  4. Say the phrase again to close the door once more.

That's it! You now have your own voice controlled IoT garage door opener thanks to Raspberry Pi. Enjoy the convenience of saying a simple phrase to open your garage instead of clicking a remote.

Closing Thoughts

Building an IoT voice controlled garage door opener is an achievable weekend project with Raspberry Pi. This guide provided detailed steps to assemble the hardware, program the software, and get it working. The skills gained create a foundation to expand the project over time.

Some ideas include adding a webcam to view the garage, sending mobile notifications, or controlling other appliances and lights. The possibilities are endless when you tap into the IoT with Raspberry Pi.