Raspberry Pi Pico

Raspberry Pi Pico Bluetooth based Home Automation Project, MicroPython Programming

Raspberry Pi Pico and Bluetooth:


Raspberry Pi Pico Bluetooth-based Home Automation Project, MicroPython Programming– In this article, you will learn how to make Raspberry Pi Pico and Bluetooth-based Home automation projects. The Raspberry Pi Pico RP2040 would have been the best microcontroller board if it was provided with the Onboard Bluetooth and WiFi just like the ESP32 WiFi + Bluetooth module. Today, on the market, Raspberry Pi Pico is the cheapest microcontroller board which you can get only for 4 dollars from the DFrobot and Amazon.

Anyway, no worries at all if the raspberry Pi Pico does not come with the Onboard Bluetooth module because we can externally connect a Bluetooth module and start controlling different electrical loads wirelessly using a smartphone App. For this project, I selected the HC05 Bluetooth module because it’s cheap and easily available. I have been using the HC05 Bluetooth module with Arduino and ESP8266 WiFi Module for controlling different things wirelessly using an Android cell phone.

For this project, I also designed my own Android cell phone Application using Android studio. I have a very detailed article on how to design your own Bluetooth-supported android cell phone App. Anyways, before I am going to explain the circuit diagram, and programming first let’s watch the Raspberry Pi Pico and Bluetooth-based Home automation project in action.

Altium Designer:

altium designer sponsor

Altium Designer is the world’s most trusted PCB design system. Altium Designer enables engineers to effortlessly connect with every facet of the electronics design process. Over 35 years of innovation and development focused on a truly unified design environment makes it the most widely used PCB design solution. With Altium Designer you can create PCB designs with an intuitive and powerful interface that connects you to every aspect of the electronics design process. Route it your way through any angle, tune for the delay, Push, Slide, and Walkaround faster than ever. Interact and collaborate with mechanical designers like never before in a photo-realistic, 3D design environment. If you want to get started with the Altium designer, you can click on the get started.

When everything is powered up never touch the relay contacts and other exposed wires as 110/220Vac can be really dangerous. Don’t forget to wear protective gloves and it’s good to have someone with you while performing such high voltage experiments.

Right now, I am using three different voltage sources. I am using 5 volts regulated power supply with the Raspberry Pi Pico, 12 volts power supply with the Relay module, and 220Vac to power up the lights.

Next, I am going to connect my Android cell Phone App with the HC05 Bluetooth module.

Raspberry Pi Pico Bluetooth

As you can see, right now all the buttons in the Android cell phone App are OFF and that’s why all the 4 lights are OFF.

Raspberry Pi Pico Bluetooth

I have used the same HC05 Bluetooth module with different controller boards but the way it works with the Raspberry Pi Pico is simply amazing. I didn’t see any delays and false triggering. Raspberry Pi Pico is insanely fast and it’s better than Arduino in every aspect. Think about the Raspberry Pi Pico twice before you think of purchasing the Arduino board for your upcoming Bluetooth-controlled robotic car project, Door Lock project, etc. Anyways, now you have got an idea of what exactly you are going to learn after reading this article. So, without any further delay, let’s get started!!!

Amazon Links:

Raspberry Pi Pico

4-channels relay Module

HC05 Bluetooth Module

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Bluetooth Interfacing with Raspberry Pi Pico:

Raspberry Pi Pico Bluetooth

The circuit diagram of the Raspberry Pi Pico and Bluetooth-based home automation project is very simple. VCC and GND pins of the HC05 Bluetooth module are connected with the Raspberry Pi Pico 3.3V and GND pins. TXD and RXD pins of the Bluetooth module are connected with the GP4 and GP5 pins of the Raspberry Pi Pico.

A 4 channel relay module is connected with the GP28, GP27, GP26, and GP22. You can use a readymade relay module or you can build a one yourself by following these connections. All 4 relays are of the type SPDT “Single Pole and double throw. To control these relays, I am using 10K ohm resistors and 2n2222 NPN transistors. Don’t forget to connect the GND of the relay module with the ground of the Raspberry Pi Pico.

Raspberry Pi Pico Bluetooth

Here is my DIY homemade 4-channel relay module, if you want to make the same 4-channel relay module then you can download the Gerber files.

Raspberry Pi Pico Bluetooth

For the demonstration purposes, I am going to control these 220Vac light bulbs, if you want you can also use other AC or DC loads. Now, I am going to connect these lights with the relay module. I completed all the connections as per the circuit diagram. Now, let’s take a look at the programming.

If you are just getting started with the Raspberry Pi Pico then I highly recommend reading my complete course article on the Raspberry Pi Pico because there are so many things which I believe you need to know, like for example MicroPython installation, Thonny IDE installation, Raspberry Pi Pico Specifications, it’s comparison with Arduino, how to use GPIO pins, how to install libraries, and so on.

Raspberry Pi Pico Bluetooth MicroPython Code:

The Raspberry Pi Pico and Bluetooth-based Home Automation programming in MicroPython are far simpler than the Arduino programming.

We simply import the UART pins to which the Bluetooth module is connected. Next, we define the baud rate which is the communication speed in bits per second.

I also imported the utime which I can use for creating delays. Next, I defined the pins to which all the 4 relays are connected. The rest of the code is pretty straightforward. We check if any data is available on the Serial port then we read the serial port, decode the command, and then finally convert the command into a string.

Finally, we check every command which is received from the Android cell phone and then accordingly turn ON and turn OFF the relay. So, that’s all about the programming.

The final step is to save the code in the Raspberry Pi Pico board. Save the file with the name main.py.

Watch Video Tutorial:


Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button