Bluetooth App Controlled Smart Door Using Arduino

In today’s world, home automation has become a necessity as we continuously move toward smart living. One exciting project that seamlessly integrates automation and security is the Bluetooth App Controlled Smart Door Using Arduino. This DIY project allows you to control the locking and unlocking of a door from your smartphone using a custom-designed app powered by the RemoteXY app interface. In this tutorial, we will walk you through the process of building this smart door system using Arduino Uno, a servo motor, and an HC-05 Bluetooth module.

The project involves a basic model house with a door, where the locking mechanism is simulated using a servo motor. The motor moves the lock into position when the door is “locked,” and frees it when “unlocked.” Let’s dive into how to set up this smart door system and the step-by-step guide to building it.

Understanding the Concept of Bluetooth App-Controlled Smart Door Project

Building a Bluetooth-controlled smart door is a fantastic entry point into the world of home automation. By integrating a servo motor to control a lock and a Bluetooth module (HC-05) to communicate with a smartphone, this project enhances your home’s security while adding convenience. The RemoteXY app allows you to design a customized interface where you can remotely lock and unlock your door with a press of a button.

This project is ideal for enthusiasts who want to combine basic electronics, Arduino programming, and app development. Once completed, you will have a working prototype of a smart door locking system that you can control from your smartphone.

Read also Based System for Rain, Smoke, and Gas Detection

Components Needed

The breadboarding of the Bluetooth App Controlled Smart Door
The breadboarding of the Bluetooth App Controlled Smart Door

Here are the components you will need to build your Bluetooth App Controlled Smart Door system:

  • Arduino Uno: The brain of the project that controls the servo motor based on the Bluetooth signals.
  • HC-05 Bluetooth Module: Used to communicate wirelessly with your smartphone.
  • Servo Motor: Responsible for the actual locking and unlocking mechanism.
  • Breadboard and Jumper Wires: For connecting the components.
  • Power Supply (Optional): A 9V battery or USB power source for the Arduino.
  • Model House with Door: A physical structure to simulate the locking system.
  • Smartphone: To control the door using the RemoteXY app.

The Circuit Diagram

The circuit diagram for Bluetooth App Controlled Smart Door
The circuit diagram for Bluetooth App Controlled Smart Door

The schematic diagram above shows the breadboard view of the connection of the modules connected to the Arduino Uno board. The power jack is to supply 5V DC to the system. There is an optional connection of an I2C LCD module. This can be used to display the status of the smart door.

Read also Automatic Headlight Dimmer For Vehicles Using Arduino

Bluetooth App Controlled Smart Door: Setting Up the Hardware

the schematic diagram of the project design
the schematic diagram of the project design

The hardware setup is simple, but attention to detail is essential. Here’s a step-by-step guide:

Connecting the Servo Motor:
The servo motor will be connected to one of the PWM (Pulse Width Modulation) pins on the Arduino, typically pin 5. The three wires from the servo motor are:

  • Red (Vcc): Connect to the 5V pin of the Arduino.
  • Black (Ground): Connect to the ground pin of the Arduino.
  • Yellow (Control): Connect to pin 5 of the Arduino.

Connecting the HC-05 Bluetooth Module:
The HC-05 has four pins:

  • Vcc: Connect to 5V.
  • GND: Connect to Ground.
  • TXD: Connect to RX (pin 2) of the Arduino.
  • RXD: Connect to TX (pin 3) of the Arduino.

Read also Smart Window Automation: Arduino-Based System for Rain, Smoke, and Gas Detection

Designing the Bluetooth App Using RemoteXY

The RemoteXY app communication protocols
The RemoteXY app communication protocols

RemoteXY is a powerful tool that allows you to design graphical interfaces for controlling Arduino projects via Bluetooth. Here’s a step-by-step guide on how to set it up:

Download and Install RemoteXY

remotexy app

You can find RemoteXY in both the App Store and Google Play Store. For us here, we are using the Android platform app. And it works very well for us. Once you have your app, you can proceed to the next step to design the app on the Web based platform.

Design Your Interface

designing the app GUI for the Bluetooth App Controlled Smart Door project using RemoteXY
designing the app GUI for the Bluetooth App Controlled Smart Door project using RemoteXY

In the RemoteXY web interface, we used the drag and drop widgets to create a user interface. For this project, we will need a button labeled Lock to control the door’s locking mechanism. When we toggle the lock button, it will actuate a digital pin on the Arduino Uno board. Then we will read the state of this pinout, if it is HIGH, we will change the direction of the Servo motor hand and vice versa.

Once the GUI on the web interface is completed, we can click on the “Get Source Code” and we can get the basic GUI code from the RemoteXY editor.

The Arduino Source Code

// you can enable debug logging to Serial at 115200
//#define REMOTEXY__DEBUGLOG    

// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__SOFTSERIAL

#include <SoftwareSerial.h>
#include <Servo.h>

// RemoteXY connection settings 
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600

Servo myservo;  // create servo object to control a servo

// variables to store the servo positions
int pos1 = 70;    
int pos2 = 10; 


#include <RemoteXY.h>

// RemoteXY GUI configuration  
#pragma pack(push, 1)  
uint8_t RemoteXY_CONF[] =   // 60 bytes
  { 255,1,0,11,0,53,0,18,0,0,0,31,2,106,200,200,84,1,1,2,
  0,2,16,73,74,19,28,31,140,8,0,2,26,31,31,76,79,67,75,0,
  85,78,76,79,67,75,0,67,9,53,87,14,46,11,99,12,69,2,26,11 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t switch_01; // =1 if switch ON and =0 if OFF

    // output variables
  char value_01[51]; // string UTF8 end zero

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;   
#pragma pack(pop)
 
#define PIN_SWITCH_01 6


void setup() {
  RemoteXY_Init (); 
  
  myservo.attach(5);
  pinMode (PIN_SWITCH_01, OUTPUT);

  
}

void loop() { 
  RemoteXY_Handler ();
  
  digitalWrite(PIN_SWITCH_01, (RemoteXY.switch_01==0)?LOW:HIGH);
  int readButton = digitalRead(PIN_SWITCH_01);  //read the button
  //use conditional statements
  if (readButton == HIGH) {
  myservo.write(pos1);  
  //strcpy  (RemoteXY.text_1, "My text");
  sprintf (RemoteXY.value_01, "Smart Door Locked");
  }

  if (readButton == LOW) {
  myservo.write(pos2);  
  //strcpy  (RemoteXY.text_1, "My text");
  sprintf (RemoteXY.value_01, "Smart Door Unlocked");
  } 


}

Explanation of Arduino Source Code

The Arduino source code is built from the basic GUI code derived from the RemoteXY app. For us to be able to use it to our won specific need, we had to add some more recipes to it. The code checks if the the lock button has been pressed, if yes, it will turn the servo motor the positon 1, “pos1”. Otherwise, it will move and remain inthe unlock positon, position 1, “pos1”.

We also wanted it to tell us if the if the door is locked or unlocked, hence we included the text display that will change its display based on the the position of the servo motor.

Connect the App to Arduino

Connecting the Arduino Uno via Bluetooth to the RemoteXY app
Connecting the Arduino Uno via Bluetooth to the RemoteXY app

Once the design is done, we paired our smartphone with the HC-05 module. Now, when we press the Lock button on our phone, it will send a signal via Bluetooth to the Arduino to either lock or unlock the door.

Testing and Results

Conclusion

The Bluetooth App Controlled Smart Door Using Arduino is a fun and practical project that brings smart home technology to life. By using a servo motor and a Bluetooth module, you can remotely control the locking mechanism of a door from your smartphone. This project serves as an excellent introduction to both Arduino programming and home automation, with countless possibilities for further enhancements, such as adding sensors for increased security or connecting it to a Wi-Fi network for remote access.

With just a few components and the RemoteXY app, you can turn a simple door into a smart, Bluetooth-controlled system, adding both convenience and security to your home setup.

Frequently Asked Questions Smart Door Project

1. Can I use other Bluetooth modules like HC-06 for this project?
Yes, the HC-06 is also compatible, but note that it only supports slave mode, unlike the HC-05, which can operate in both master and slave modes.

2. Can this project work with a different microcontroller, such as ESP32?
Yes, you can adapt this project to work with ESP32, which has built-in Bluetooth capabilities, simplifying the connection process.

3. What happens if the Bluetooth connection is lost?
If the connection is lost, the last command executed by the Arduino will remain in place. You can add extra code to alert you if the connection drops.

4. Can I control multiple doors using the same setup?
Yes, you can control multiple doors by expanding the code and adding more servo motors, each corresponding to a different button on the RemoteXY app.

5. Is the servo motor strong enough to handle real locks?
For this model, a standard servo motor works perfectly. However, for real doors, you will need a more powerful motor or a motorized lock system.

Leave a Comment

Follow by Email
Pinterest
Pinterest
fb-share-icon
Instagram
Telegram
WhatsApp