Arduino controlling with Bluetooth

I had ordered HC-05 Bluetooth adapter for Arduino. After some frustration with some failed attempts to do the communication with it, I left it waiting for new motivation. Then last week I happened to see Triggering Remote Fireworks with an Arduino and an Android article that pointed to ArduDroid: A Simple 2-Way Bluetooth-based Android Controller for Arduino web page. ArduDroid is is a simple Android app designed to control Arduino Uno pins wirelessly. ArduDroid consists of both an Android app and an Arduino program. ArduDroid allows to control Arduino Uno’s digital and PWM pins, send commands and receive data. The communication works over Bluetooth serial using popular HC-05 Bluetooth over serial module.

This was all incentive I needed to start experimenting with Bluetooth module again. First I downloaded the Android app to smart phone. Then I made HC-05 Bluetooth module connection to Arduino according to ArduDroid app instructions:

 

1IgUsx9IFBBHqJ-2V1p-mJMxl3g1efmzTtziT2rb8nUkis1MPKwkIhTZxTA0sfnaWwM=h900

The connection is pretty direct connection except for the Arduino TXD pin. The HC-5 Bluetooth module runs on 3.3V while Arduino UNO runs at 5V, which complicates interfacing. The base board for HC-05 does the power supply regulation from 5V to 3.3V, but the TX and RX data lines needs to be adapted. On the data direction from Bluetooth module TX pin to Arduino RXD pin direct conversion works well because 3.3V signal is strong enough to drive 5V input. On the other direction 5V TXD signal from Arduino is too high level for normal 3.3V input, and because there is no data to guarantee that this input would be 5V compliant, the safest bet is to do signal level translation. In this application the 1kohm and 2kohm resistors for a voltage divider that converts 5V signal to 3.3V level. I used in my circuit 1kohm and 2.2 kohm resistors. Some web pages show that direct connection without resistors might work also work if there the base board for HC-05 has level translator in it. In my case I think my module does not have that level translator, so I thought that it is better to be safe than sorry.

Here is picture of the ugly prototype I built. The Arduino UNO board I used was Arduino UNO with Sensor Shied:

arblue1

Things worked well without too much problems. To get the Bluetooth connection work, I had to pair my smart phone with the HC-05 (pairing code needed was 1234). Then I started ArduDroid app, and wondered some time to make it to connect, but finally found out that pressing the button for app settings gave me the option to select the Bluetooth connection I wish to use. After that I could easily control the digital outputs and PWM outputs with ArduDroid app (comparable functionality to what I got with IOIO + Bluetooth).

Here is more complicated test circuit in use. There I have wired in one LED (car 12V LED with internal resistor) and one RGB led module. I can easily use this set-up to control LED brightness and RGB led color.

arblue2

Here is closeup of control app running on Android smart phone:

arblue3

You can use ArduDroid to send commands to Arduino to control a relay to turn electric gadgets on/off, control a robot servo, increase/decrease speed of a motor and reverse direction, dim a light, speed up a fan, and so on.  It should be also possible read Arduino pins and sensors then transmit the data back to your android phone: in my testing I could get reading of analogue input by pressing

For more information there is introduction video ARDUDROID: The 2-Way Android Controller for Arduino via Bluetooth which is worth to check out.

14 Comments

  1. Tomi Engdahl says:

    Somewhat related article:

    Modifying the HC-05 Bluetooth module defaults using AT commands
    http://hackaday.com/2013/09/04/modifying-the-hc-05-bluetooth-module-defaults-using-at-commands/

    Reply
  2. Tomi Engdahl says:

    Arduino-based LED Wedding Lights
    http://hackaday.com/2014/08/31/arduino-based-led-wedding-lights/

    [Rob] created these amazing Bluetooth controlled LED lights for his daughter’s wedding adding a colorful ambient glow to the ceremony. Each item held a Neopixel ring and an Arduino microprocessor with a wireless module that could be individually addressed over a ‘mini-network.’ The main master station would receive commands from a Windows Phone.

    Reply
  3. Tomi Engdahl says:

    Communication between two hc-05 Bluetooth modules
    Set an hc-05 bluetooth module to master mode to send serial data to another module.
    https://hackaday.io/project/1278-communication-between-two-hc-05-bluetooth-modules

    If you’ve ever looked into controlling an Arduino remotely, then you’ve probably come across these hc-05 Bluetooth modules. Setting up serial communication from the computer is a simple task. But what if you want to use an Arduino or other microcontroller as the master?

    Setting up communication between two modules is a two step process. The module to be used as the master must first be put into AT command mode in order to modify it’s role as either a slave or master.

    Slave role: The module waits for a master to connect to it.

    Master role: The module sets up a connection with a nearby slave device and automagically builds the overhead for serial communication.

    The default role on my modules was set to slave.

    Modify The HC-05 Bluetooth Module Defaults Using AT Commands
    http://www.instructables.com/id/Modify-The-HC-05-Bluetooth-Module-Defaults-Using-A/

    Reply
  4. Marcio says:

    What if we connect the hc-05 to the 3.3V pin on the arduino instead of the 5v?

    Reply
    • Tomi Engdahl says:

      The 3.3V pin on the normal Arduino is just 3.3V power output to module.
      The Bluetooth module want power supply that is 3.6-6V, so 3.3V would be too low here.
      So connecting anything to 3.3V on normal Arduino directly does not help here.

      If you select an Arduino variation that uses 3.3V voltage for the Atmel CPU, you can connect the
      TX and RX lines directly to each other without any resistors.

      Reply
  5. Marcio says:

    Ok, so wow, im so used to working with solar, so I guess a 1 volt here makes all the difference. So I would need my breadboard to share the 5v from the arduino to the servo and the BT module :-)

    Reply
  6. anthony says:

    can I have a full copy of the modified sketch you used

    Reply
  7. amr khaled says:

    so i am doing a similar project but instead of led i want to use a dc motor, the circuit is all wired up but the bluetooth wouldn’t receive any data, its module is Hc-05 and i connected the resistances as specified but still no change, could you please ust tell me what may be the problem ?

    Reply
    • Tomi Engdahl says:

      With your description I can’t say what would be specifically wrong.
      Check out that the wiring is correct and that bluetooth registration between the devices is working etc…

      Reply
  8. PJA says:

    You write: “and wondered some time to make it to connect, but finally found out that pressing the button for app settings gave me the option to select the Bluetooth connection I wish to use.”

    I have the same difficulty – pairing successful, ‘connecting’ unsuccessful (the LED goes to slow blinking, so it’s Paired, but it’s not Connected till it goes to the double-blink state).

    Which button for “app settings”? I’ve been back and forth with the Android BT settings, but there’s no option for ‘connecting’. Is there a ‘button’ in ArduDroid that I’m overlooking?

    Reply
  9. Tomi Engdahl says:

    Convert Any USB Keyboard to Bluetooth
    http://hackaday.com/2016/09/04/convert-any-usb-keyboard-to-bluetooth/

    [DastardlyLabs] saw a video about converting a PS/2 keyboard to Bluetooth and realized he didn’t have any PS/2 keyboards anymore. So he pulled the same trick with a USB keyboard. Along the way, he made three videos explaining how it all works.

    The project uses a stock DuinoFun USB mini host shield with a modification to allow it to work on 5V. An Arduino mini pro provides the brains.

    A standard Bluetooth module has to have HID firmware installed.
    HC-05 Bluetooth module

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

*

*