Project

In this project I will show you how to make a device that will tell you weather your door is open is closed. Just connect to the device via Bluetooth and as long as your in range you will be able to see if the door is open or closed. This device is not just limited to doors you could use this for many applications by simply swapping the reed switch with another switch or input device and on the phone it will tell you if the input is high or low.

The connections

For this device you will need to have a HC-05 Bluetooth module and an Arduino (any Arduino will do but the pin numbers in the code may need to be altered) I chose to use a Arduino Uno. You will also need a reed switch and a magnet to attach to the door. The Bluetooth has a receive voltage level of 3.3 volts where as the Arduino has a 5v transmit voltage level so a voltage divider will need to be used. Just connect all the parts together as shown in the diagram.

Code

I have included some code for you to use for the device you can change bits of the code to the needs of your chosen application. I have included the code for a door monitor.

Once you are happy with your code just upload it to the Arduino.

#include <SoftwareSerial.h>
SoftwareSerial BlueTooth(5, 6);
int reedswitch = 12
int val = 0
char BT_input; 
void setup()  
{
 pinMode(reedswitch, INPUT);
 BlueTooth.begin(9600);  
}
void loop() 
{
 if (BlueTooth.available())
 {
   BT_input=(BlueTooth.read());
   if (BT_input=='1')
   {
       if val = digitalRead(reedswitch) == low
         BlueTooth.println("The door is closed")
       else if val = digitalRead(reedswitch)== high
         BlueTooth.println("The door is open")
   }
  else if (BT_input=='?')   
   {
     BlueTooth.println("Send '1' to see if the door is open or closed");
   }   
}

How to use.

Now that the code is uploaded and all the connections are made just turn on the device and connect the module via Bluetooth.

You will need a app to receive information from the device. I used the 'Bluetooth terminal HC-05' app but you could use any Bluetooth terminal app or even write your own custom app to display the data.

Now when you want to know the status of the door/input just send '1' to the module and it will tell you weather the door is opened or closed.

Acknowledgement

I thank PCBWay & LCSC Electronics for the partnership.

PCBWay is a cheap and reliable service where you can get your PCBs manufactured. All the PCBs are high quality and the engineers are very helpful. Sign up today and get a $5 welcome bonus. Check out their Gift shop and Gerber viewer.

LCSC Electronics Is China's leading Electronic Components Distributor. LCSC sells a wide variety of high quality electronic components at low prices. With over 150, 000 parts in stock they should have the components you need for your next project. Sign up today and get $8 off on your first order.

Website

Check out more of my other projects on my website.