Table of Contents
Introduction
A common way of controlling home appliances are the mechanical switches, where the person need to press the switch to turn ON or to turn OFF. But, now we are in the phase of automation and work wirelessly over a distance. So, now no need to use the same boring mechanical switches to control the home appliances.
In this article a mobile application is running on an Android device and is connected with a HC05 Bluetooth module which is then connected to a Raspberry Pi Pico board, with controlling circuit board and relay driver which is then controls the ON and OFF of any device or devices.
So, here we will make a home automation project using a Raspberry Pi Pico board, HC05 Bluetooth module, 5v relay driver, and etc. Home automation means we need to control the ON/OFF sequence over an wireless communication protocol. Here we will use HC05 Bluetooth module for wireless communication. To complete the project we will use an Android application as a remote to control all the appliances.
For this project I have designed an Android application and you can download it in the download section. And to learn application building you can follow the complete guide is in my YouTube channel. If you want to design your own mobile application you can follow this video tutorial.
We will use MicroPython to complete this project, MicroPython is the light version of Python which can run on low memory devices. So, lets start building projects using Raspberry Pi Pico and provide faster execution of statements.
Hardware Requirements
Disclaimer: It may contains Amazon affiliate links. which means I can get a small commission on the sale. This might be your indirect help to me. Thank You 🙏
- 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
About HC05 Bluetooth Module
HC05 is a popular Bluetooth module that enables wireless communication between electronic devices. It is a small and inexpensive module that uses Bluetooth 2.0 technology to establish a serial communication with a device, like a microcontroller or computer, and a remote device, such as a smartphone or tablet.
The module has a range of up to 8-10 meters and can support data transfer rates of up to 2.1 Mbps. It can be operate in either master or slave mode, and it also supports multiple Bluetooth profiles including the Serial Port Profile (SPP), which allows for easy integration with a wide range of microcontrollers and other electronic devices.
The module can be easily interfaced with a microcontroller using a serial communication and a few basic AT commands can be used to configure its settings, such as mode of the module, baud rate, device name, and etc.
Overall, the HC05 Bluetooth module is a popular choice for adding wireless communication capabilities to electronic devices due to its low cost, ease of use, and wide availability.
About 5v Relay
A 5V mechanical switching relay is an electromechanical device that allows you to switch on/off electrical circuits using a low voltage control signal. It consists of a coil, a set of contacts, and a switch that is operated by an electromagnetic force generated by the coil.
When we provide proper voltage at the coil terminal the contact connected at NC normally connected point is shifted to the NO normally open point. And then completing the whole circuit. This mechanical switching is done using an digital signal through a optocoupler in the 5v relay module.
Circuit Diagram
Circuit Explanation
Follow the circuit diagram and build your circuit correctly.
HC-05: The important pins of Bluetooth module and the connection explained below.
HC-05 Bluetooth | Raspberry Pi Pico |
VCC | Common 5v |
GND | Common GND |
Tx | GP1 |
Rx | GP0 |
Relay Driver: The relay driver I am using is a 5v 4-channel relay, this means I can control up to 4 devices. The circuit diagram is explained in the below table.
Relay Driver | Raspberry Pi Pico |
VCC | Common 5v |
GND | Common GND |
IN1 | GP17 |
IN2 | GP16 |
IN4 | GP15 |
IN4 | GP14 |
AC Connection: One terminal of AC wire is common to all the appliances, you can see the circuit diagram, the BLACK wire is common to all the AC loads and other terminal is connected to the COMMON point of relay. Now, look at the load side the load has two terminal, the one in BLACK color is the common connection and the other terminal of load is connected to the Normally Open Terminal of relay.
Source Code Explanation
MicroPython Code: The code we are using here is written in MicroPython programming language.
Main Code: (main.py)
So, this is the final code that is responsible for the receiving of data through the Bluetooth module and again compare the received data with the pre defined data and accordingly turning ON/OFF the devices connected to the relay. Now create one file in the Thonny IDE and copy/paste the code given in the download section as BluetoothHomeAutomation.txt and save it as a main.py file in the Raspberry Pi Pico board.
Why the main.py file name?
You can give any name to the file but when running the code from Thonny IDE by clicking the green button it will run once. But when we give the name main.py to the file, the Raspberry Pi Pico board will automatically detect and run the code whenever you want. You can say that this is a process of AutoStart the system.
Video Tutorial
Download Source Code
Download the complete source code: click here
2 thoughts on “Bluetooth Home Automation using Raspberry Pi Pico”