Introduction
Mechanical switches are a common way of controlling home appliances, requiring the user to press the switch to turn the device ON or OFF. However, with the advent of automation, we now have the ability to control devices wirelessly, eliminating the need for traditional mechanical switches.
In this article, we’ll explore a home automation project using a mobile application running on an Android device. This app connects to an HC05 Bluetooth module, which in turn is connected to a Raspberry Pi Pico board. The Raspberry Pi Pico is equipped with a controlling circuit board and a relay driver to manage the ON and OFF states of various devices.
In a previous tutorial, we built a Bluetooth-controlled home automation system. In this tutorial, we will extend its capabilities by incorporating voice commands to control the devices. This project follows a similar approach to the Bluetooth-controlled home automation tutorial, so you can choose whichever method suits you best.
Project Overview
For this home automation project, we will use a Raspberry Pi Pico board, an HC05 Bluetooth module, and a 5V relay driver, among other components. The goal is to control the ON/OFF sequence of home appliances using voice commands over a wireless communication protocol. The HC05 Bluetooth module will facilitate this wireless communication. An Android application will serve as the control interface for all the appliances.
I have designed an Android application for this project, which you can download from the download section. If you’re interested in learning how to build the application, you can follow a complete guide on my YouTube channel. The video tutorial will help you design your own mobile application.
We will use MicroPython to complete this project. MicroPython is a lightweight version of Python that runs on low-memory devices, allowing for faster execution of statements. Let’s start building our home automation project using the Raspberry Pi Pico and enjoy the benefits of automated control.
Hardware Requirements
Notice: There might be affiliate links to Amazon on this page. which implies that I may receive a tiny commission from the sale. This may be your way of indirectly assisting me. Regards
- Raspberry Pi Pico (HERE)
- Micro USB Cable (HERE)
- 4-Channel Relay Driver (HERE)
- HC05 Bluetooth Module (HERE)
- Connecting Wires (HERE)
- Breadboard (HERE)
- AC bulb holder
- AC bulb
- Connecting wire for AC lines
Software Requirements
HC-05 Bluetooth Module
The HC05 Bluetooth module is a widely used component in wireless communication projects, especially those involving microcontrollers like Arduino and Raspberry Pi. Designed to be easy to use, the HC05 enables devices to communicate over short distances using Bluetooth technology. It operates on the 2.4GHz ISM band, providing a range of about 10 meters. The module features a built-in AT command set, which allows users to configure various parameters such as the baud rate, device name, and passkey. This flexibility makes it suitable for a variety of applications, from simple data transmission to more complex tasks like wireless control of devices.
The HC05 can function in both master and slave modes, making it versatile for different project requirements. In master mode, it can initiate connections with other Bluetooth devices, while in slave mode, it waits for connections from other devices. This dual functionality expands its usability in projects where bidirectional communication is needed. Additionally, the HC05 supports serial communication, interfacing easily with microcontrollers through UART (Universal Asynchronous Receiver/Transmitter) pins. This compatibility simplifies integration and coding, even for beginners.
Overall, the HC05 Bluetooth module is a powerful yet accessible tool for students and hobbyists looking to explore wireless communication and add Bluetooth functionality to their projects.
What is a Relay?
A relay is an electrically operated switch that allows you to control a high-power device with a low-power signal. It can isolate different parts of a circuit and is commonly used to control appliances, lights, and other electrical equipment. In this project, the relay will act as an intermediary between the microcontroller and the device you wish to control.
How Relay Works?

An SPDT (Single Pole Double Throw) relay is an electromechanical switch that connects one circuit to one of two other circuits. Here’s how it works:
Components of an SPDT Relay
- Electromagnet: A coil of wire that, when energized, creates a magnetic field.
- Armature: A movable metal arm that is attracted by the electromagnet when it is energized.
- Common Terminal (COM): The terminal that connects to the armature and moves between two other terminals.
- Normally Closed Terminal (NC): The terminal that is connected to the COM terminal when the relay coil is not energized.
- Normally Open Terminal (NO): The terminal that is connected to the COM terminal when the relay coil is energized.
- Spring: Returns the armature to its original position when the electromagnet is not energized.
Operation of an SPDT Relay
De-energized State:
- In its default state (when no current flows through the coil), a spring holds the armature against the NC terminal.
- The COM terminal connects to the NC terminal.
- Any circuit connected to the COM terminal connects to the NC terminal, allowing current to flow through this path.
Energized State:
- When a current flows through the coil, the electromagnet generates a magnetic field.
- This magnetic field attracts the armature, pulling it away from the NC terminal and towards the NO terminal.
- The COM terminal now connects to the NO terminal.
- Any circuit connected to the COM terminal now connects to the NO terminal, allowing current to flow through this new path.
Circuit Diagram

Circuit Explanation
To ensure your project functions correctly, follow the circuit diagram and build your circuit precisely.
HC-05 Bluetooth Module Connections:
The HC-05 Bluetooth module is a crucial component for enabling wireless communication. Below are the key connections you need to make between the HC-05 module and the Raspberry Pi Pico:
- VCC (HC-05) to Common 5V (Raspberry Pi Pico)
- GND (HC-05) to Common GND (Raspberry Pi Pico)
- Tx (HC-05) to GP1 (Raspberry Pi Pico)
- Rx (HC-05) to GP0 (Raspberry Pi Pico)
These connections allow the HC-05 to communicate with the Raspberry Pi Pico using serial communication. The VCC and GND provide power, while the Tx and Rx pins handle data transmission and reception.
Relay Driver Connections:
The relay driver I am using is a 5V 4-channel relay, which allows control of up to four devices. Here are the connections between the relay driver and the Raspberry Pi Pico:
- VCC (Relay Driver) to Common 5V (Raspberry Pi Pico)
- GND (Relay Driver) to Common GND (Raspberry Pi Pico)
- IN1 (Relay Driver) to GP17 (Raspberry Pi Pico)
- IN2 (Relay Driver) to GP16 (Raspberry Pi Pico)
- IN3 (Relay Driver) to GP15 (Raspberry Pi Pico)
- IN4 (Relay Driver) to GP14 (Raspberry Pi Pico)
These connections enable the Raspberry Pi Pico to control the relay channels, turning connected devices ON or OFF.
AC Connection:
For the AC connection, one terminal of the AC wire (BLACK wire) is common to all appliances. This terminal is connected to the NC of all the relays. Each load (appliance) has two terminals:
- The common terminal (BLACK wire) connects to the common point of the relay.
- The other terminal of the load connects to the Normally Open (NO) terminal of the relay.
When the relay activates, it completes the circuit, allowing current to flow through the appliance and turning it ON. When the relay deactivates, it breaks the circuit, causing the appliance to turn OFF. This clear functionality makes relays essential for controlling various devices in home automation and electronic projects.
Ensure all connections are secure and double-check the circuit diagram to avoid any mistakes. Properly following these connections will help ensure your home automation project operates smoothly and safely.
Source Code
This is the final code responsible for receiving data through the Bluetooth module, comparing the received data with predefined commands, and turning ON/OFF the devices connected to the relay. Follow these steps to set up the main code on your Raspberry Pi Pico board:
Create a file with main.py file inside the Raspberry Pi Pico board and copy paste the below source code.
from machine import Pin, UART
import utime
uart = UART(0,9600)
relay1=Pin(14,Pin.OUT)
relay2=Pin(15,Pin.OUT)
relay3=Pin(16,Pin.OUT)
relay4=Pin(17,Pin.OUT)
#uart1 = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))
message = ""
relay1.value(1)
relay2.value(1)
relay3.value(1)
relay4.value(1)
while True:
print("waiting...")
if uart.any():
message = uart.readline()
print(message)
message= message.decode("utf-16")
messages= str(message)
print(messages)
if messages =='*bed light on#':
relay1.value(0)
elif messages == '*bed light of#':
relay1.value(1)
elif messages == '*bed light off#':
relay1.value(1)
if messages =='*kitchen light on#':
relay2.value(0)
elif messages == '*kitchen light of#':
relay2.value(1)
elif messages == '*kitchen light off#':
relay2.value(1)
if messages =='*light on#':
relay3.value(0)
elif messages == '*light off#':
relay3.value(1)
elif messages == '*light of#':
relay3.value(1)
if messages =='*fan on#':
relay4.value(0)
elif messages == '*fan off#':
relay4.value(1)
elif messages == '*fan of#':
relay4.value(1)
utime.sleep(0.5)