Introduction: Arduino Bluetooth Garage Door Control With Sensors and Customizable Android App
Use an arduino to activate relays for opening garage doors and electric door locks.
A customizable Android App, connects to arduino via password protected bluetooth pairing.
A bluetooth hc-05 module receives commands from an android phone to open doors and transmits back the door states to the phone, wether the door is open or closed.
The Arduino code is modified from Ardudroid:
The materials used are:
-Arduino Uno or Pro Mini (for begginers it is easier with Arduino Uno)
-TTL USB Adapter Module - only if using Arduino Mini
-4 Channel Relay Board
-HC-05 Bluetooth Module.
-4 Reed Switches or Micro Switches
-2.2k and 1.5k resistors to voltage divider on hc-05
- 5v Power Supply
Step 1: Preparing the Hc-05 Bluetooth Module
If you have an Arduino Pro Mini 3.3v, you don´t have anything to do, but most arduinos are 5v and you have to adjust the logic level of the module, because 5v would damage it.
You need two resistors, 2.2k and 1.5k to make a voltage divider.
The RX track on the circuit must be cut with an exacto knife before reaching the header pin, you can test with a multimeter if you had success cutting it.
Then solder the joined resistors over the hole on the board that went to RX. Solder 2,2k to GND and 1.5k to Rx.
You can alternatively use a level shifter board.
The voltage in this particular module can be 3.3 or 5v.
Step 2: Upload to Arduino a Basic TX RX Communication Sketch to Program BT Module
First Use the attached sketch to program your Arduino UNO or Pro Mini.
If you are using UNO just connect usb to pc.
If you have Arduino Mini 5v - Connect only the USB TTL Adaper as shown in the picture in next step.
DTR is the software Reset PIN.
If you have a arduino pro mini 3.3 - Some ttl adapters have a jumper switch to select voltage, but always test with multimeter, even the logic voltage on Tx Pin.
Warning: You cannot upload the sketch to Arduino with the Tx RX wires connected to pins 0 and 1.
It is better to upload the sketch before connecting the bluetooth module.
Step 3: Programming BT Module With AT Commands
After uploading the sketch of the previous step:
Wire the HC-05 TX to the Arduino UNO RX on pin 10.
Wire the HC-05 RX to the Arduino UNO TX on pin 11 through the voltage divider explained before.
Wire the HC-05 +5v to Arduino +5 or to ext power supply +3 or +5
Use common GND between arduino and BT module.
Connect Usb to pc.
USB TTL TX to MINI RX(PIN0)
USB TTL RX to MINI TX(PIN1)
USB TTL GND to MINI GND
USB TTL 5v+ to MINI VCC
BT TX to MINI RX Pin 10
BT RX to MINI TX Pin 11
BT GND to MINI GND
BT +5v to MINI VCC (depending on your mini version 3.3v or 5v)
Programming BT Module
Start Arduino IDE, Open Serial monitor in 9600 or 115200 depending on your module brand. Write AT upercase and Enter, if it is working you will see the repply OK
Program with AT Commands the baud rate to 9600 if needed and change the bt pairing password.
(See Complete AT commands list inside sketch in previous step)
AT+NAME - Query BT Name
AT+NAME:Name - Set name
AT+UART - Query UART Speed
AT+UART:9600 - Set uart to 9600 (needs to change serial monitor speed afterwards. If you want to leave 115200 you have to change the ardudroid sketch in next step to 9600)
AT+PSWD - Query Pairing Password
AT+PSWD:xxxxxxxxxxxxxxxx Change Pairing Password (16 char upper and lower,numbers but not all signs )
I could not set the encryption configuration command, If someone does please leave comment:
AT+SENM -Query/Set Security & Encryption Modes
The other configurations may be left default.
Now you should be able to connect to the module with your phone and pair it with a secure password.
Step 4: Upload Modified Ardudroid Code to Arduino
Since the Bluetooth module is already configured, upload the attached code to arduino, to communicate with the android app. Use the same wiring as before, or if you prefer, in this step you do not need the bluetooth module connected.
Open the file in Arduino Ide, Choose your board and Port and upload.
Step 5: Connecting Sensor Switches and Relays to Arduino With HC-05
It is stronly recommended that you unplug the jumper from VCC/JD relay board and connect a separate power supply +5 to JD and GND.
Leaving VCC Connected to Arduino +5. The arduino does not have enough current to drive the coils, it can damage arduino, leaving jumper does not provide circuit isolation protection.
The reed switches are convenient to doors, you have to active it with a small magnet glued on the moving part of the door. They can be substituted by microswitches. The code uses internal resistor pullups, so you just need to bring the pin to ground to activate it. It does not need any resistor. The buttons can have common ground.
Each switch goes to a separate door to be monitored wether it is open or closed.
You can see in the pictures 4 switches soldered together for testing purposes, and a reed switch.
Notice that now the bluetooth module is connected to pins 0 RX nd 1 TX of arduino. While this pins are connected you cannot upload any sketch to arduino, just disconnect them to do so.
-Relay Pins 9-10-11-12 of arduino
VCC to VCC
JD to 5v power supply
Gnd to GND
-Switch sensor Pins 4-5-6-7 of arduino
Common to GND
BT Tx to 0 Rx Arduino
BT Rx to 1 TX Arduino
Vcc to +5 Arduino
GND to GND
Step 6: Customize Android App and Install in Your Phone
The app was developped with MIT App Inventor:
You can install it in your android phone as is, enabling it to accept apps from unknown sources in config.
Install the .apk to your phone, pair it with the bluetooth module with your programmed password to use it.
The .aia file is the source code you can import in MIT App Inventor site to translate or to adjust to your needs.
It was designed to operate 2 garage doors and 2 social doors.
In the figure is the whole app written with the visual blocks for reference.
The buttons in the app will activate momentarily different relays on arduino, that activates the external button connection, of your garage door system, and also to activate solenoid electronic locks on doors.
The empty square on the left shows if this door is open or closed, showing a green or red rectangle, this reading comes from microswitches or reed switches on each door that goes to arduino as sensors.
We have a be nice policy.
Please be positive and constructive.