Bluetooth Controlled Home Automation System Along With LDR Based Night Light

Hello All,

This is an instructable about control of light and door of a house using an android app. The light is also controlled by an LDR, which is overridden by the app.

I have used a Bluetooth module HC-05 for interfacing the MCU with the app.

Here is the list of equipment required for this instructable:


1)BT Term application installed on Bluetooth enabled Cell phone


Output :

3) LED light (When there is dark)

4) Door Opening/Closing

Actuator :

4)Motor- 12V DC, 30 rpm

Electrical components:

6) Microcontroller - Arm Cortex M4 (TM4C123GXL)

7) Bluetooth Module – HC-05

8)Relay switch, 120VAC, 10 Amp

9)Motor Driver (Battery)

10) LDR – 12mm

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Understanding LDR and HC-05

A Light Dependent Resistor (LDR) is a resistor whose resistance varies with the intensity of light. The higher the intensity of incident light, lower will be the resistance offered by an LDR. It is very similar to a Metal Oxide Varistor (MOV) whose resistance varies with the voltage across it.

The LDR can be connected in series with the 60K resistor and connected across the 5V source. In daylight, the resistance of the LDR will be low and so the voltage across the 60K resistor will be high. During the night, high resistance of the LDR will lead to almost 0V across the 60K resistor. This voltage difference can be sensed by the MCU, which can then turn on/off the light.

The resistor value can be appropriately selected depending upon the used LDR (attached image shows the used circuit with a 10K resistor).

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial communication setup. Serial port Bluetooth module is fully qualified Bluetooth V2.0 + EDR (Enhanced Data Rate) 3Mbps modulation with complete 2.4GHz radio transceiver and baseband.

UART interface is used to connect HC-05 and MCU. HC-05 has an auto pairing PINCODE, which can be modified thereby making it secure. The default baud rate in slave mode is 9600. Data bits:8, Stop bit:1, Parity: No parity. The above format can be modified by programming the HC-05

The MCU UART should be programmed according to the selected format.

Step 2: Operating the Door

The door is operated using a motor. An SPDT relay is used for controlling the motor. The relay is an electro-mechanical device, which provides power to the load when its coil is actuated. This serves multiple purposes:

1. Controlling the motor

2. Providing high voltage to the motor

3. Isolating the low voltage MCU side from the high voltage side.

Step 3: Using Bluetooth Application

Here an available application (S2 terminal for Bluetooth) is used for control. Power the setup and notice the blinking pattern of the LED provided with the HC-05 module.

Open the application and pair it with the HC-05 module. When the device is paired the LED blinks 1 time/2sec.

We can then send the pre-decided signals to operate the automation system.

Step 4: Flow Chart and Program

I have attached the system flow chart and the corresponding program is as below:





volatile unsigned long j=0;

volatile unsigned long a=0x0;

volatile unsigned long i=0;

int main()

{ SYSCTL_RCGCUART_R |=0x0000008;

//SYSCTL_RCGCSSI_R|= 0x00000001;

SYSCTL_RCGC2_R|= 0x00000004;

SYSCTL_RCGC2_R|= 0x00000002;

SYSCTL_RCGC2_R|= 0x00000020;





























if ((GPIO_PORTB_DATA_R&0X20)==0X00 )




// while ((UART3_FR_R &0X10)!=0 )

// {}


if (a==0x31 )




else if (a==0X32 )



else if (a==0X33 )








Automation Contest 2016

Participated in the
Automation Contest 2016

Be the First to Share


    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest