Bluetooth controlled Light Bulb using DFRobot Beetle and HC-05 module


Home automation has elevated convenience to new heights, from controlling the lights in your bedroom to automatically turning your home appliances on and off to a schedule. Instead of using mechanical switches, you can now operate all of your home's electronics with just your smartphone.

This blog demonstrates how to set up a simple automated lightbulb using DFRobot Beetle, a very small-form-factor Arduino board that's the size of your thumb!

Hardware Used: 

  • HC-05 Bluetooth Module
  • Relay Module
  • Breadboard
  • Jumper Wires
  • Micro USB to USB cable

    Software Used: 

    Application Description: 

    • DFRobot Beetle

    DFRobot Beetle is one of the smallest Arduino compatible boards in the market. It is a miniature version (20mm x 22mm) of the Arduino Leonardo (70mm x  55mm) while maintaining similar functionalities. The beetle has V-shaped IO ports which the user can use to twist the wires upon. This feature also allows for it to be directly sewn on clothes with conductive threads.
    The DFRobot Beetle comes with Atmel ATmega32U4 at 16MHz clock time and has 10 digital pins, 5 analog pins, and 4 PWM pins. To further make it user-friendly, it is compatible with Micro USB so that direct programming and testing can be done easily.
    Below is a table of the IO Port Mapping in correspondence with Arduino Port:
    • HC - 05 (Bluetooth Module)
    HC-05 Bluetooth Module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup. Its communication is via serial communication which makes an easy way to interface with controller or PC. HC-05 Bluetooth module provides switching mode between master and slave mode which means it able to use either receiving or transmitting data.
    • Relay

    A relay module is an electrical switch that is operated by an electromagnet. The electromagnet is activated by a separate low-power signal from a micro controller, in this case the Beetle. When activated, the electromagnet pulls to either open or close an electrical circuit.

    The relay module used in the project is a single channel relay (those blue cubes). There are other models with two, four and eight channels.

    Hardware Setup: 

    Pin Configuration

    HC-05 Connections 

      • TXD pin in HC-05 to RX contact point in DFRobot Beetle.
      • RXD pin in HC-05 to TX contact point in DFRobot Beetle.
      • We will not be using the STATE and EN pins on the HC-05 module, since they are not required for this setup.
    Note: The RX and TX pins of the Beetle are contact points. Therefore wires or an equivalent needs to be soldered onto them for proper connection. 
    Relay module Connections
      • S pin on relay module to D9 hole in DFRobot Beetle
      • Now we need to connect the power supply to the relay module. If you look carefully at the terminal block on the relay module, you’ll find these three terminals:

        C: Common
        NC: Normally Closed
        NO: Normally Open

      • We want to turn the bulb on only when we send a signal from the smartphone. That’s the reason we connect the load to the NO (Normally Open) terminal, so by default the light bulb is OFF. 
        When the relay is triggered from the Beetle, the relay contact switches from the NO terminal to the NC terminal, thereby completing the circuit, and turning ON the light bulb.

    Software setup:  



    const int relay = 9;
    void setup() {
      pinMode(relay, OUTPUT);
    void loop() {
      char state =;
      if (state == '1'){
        Serial.println("Lights ON");
        digitalWrite(relay, HIGH);
      } else if (state == '0'){
        Serial.println("Lights OFF");
        digitalWrite(relay, LOW);


    Code Breakdown: 

      • At the start, we initalize the variables needed for this project. Since the S pin of the relay module is connected to the D9 hole in the Beetle, we assign the value to the variable named relay.
      • In the setup() method, we set the baud rate to 9600 and declare the D9 pinmode in the OUTPUT mode.
      • In the loop() method, Serial1 is read and if ‘1’ is received as input, it turns ON the relay, and if ‘0’ is received, it turns OFF the relay.


    Arduino Controller App: 

    • Once installed, pair the HC-05 to your smartphone via the app. The first time you pair the HC-05, you are required to enter the password. By default, the password is either 1234 or 0000.
    • Once paired, A menu will pop up with the different modes we can use to connect to the HC-05. For this project, we will be connecting in Switch mode.
    • Make sure that in the Setting menu, the ON and OFF commands are set to 1 and 0 respectively. 
    • Here is a link to a video demo on how to setup the Arduino Bluetooth Controller App


    Below is a video demonstration of the working project. 




    This project demostrates a simple DIY automated lightbulb that can be controlled using a cellphone via bluetooth. Since the Arduino bluetooth contoller app can be configued to send different types of inputs rather just ON and OFF state, these inputs can be used to futher improve the complexity of your DIY project. 



    1-channel relay1-channel solid state relayArduinoAutomationBeetleBluetoothDfrobotDfrobot beetleHc-05Hc05Home automationRelaySmart lightSmart light bulb

    Leave a comment

    All comments are moderated before being published