Connecting to Arduino using Processing and bluetooth (HC-05, HC06)

USB bluetooth dongle

USB bluetooth dongle

The other day I bought myself a USB bluetooth dongle for my HP laptop and a HC-05 bluetooth adapter for the Arduino.

When I connected the dongle to my laptop running Windows 8 it appeared like it would install the default drivers for it. I connected the HC-05 to an Arduino and I could locate it from my laptop. I could even pair the dongle with the adapter. (Default code: 1234.)

HC-05 bluetooth module

HC-05 bluetooth module

But when checking the HC-05 in Windows’ device manager its status would say “Offline”. It took me several hours of googling until I came across a suggestion by another user that bought the same dongle on amazon: I installed the Toshiba Bluetooth Stack! Even though it says it’s only for toshiba laptops it worked on my HP like a charm.

I also had a HC-06 adapter lying around. Optically they look very similar. As far as I know HC-05 can work as master or slave whereas HC-06 is slave only. If you use them as slaves you can use either of them using the same pins. HC-05 came up under COM40 and HC-06 identifies itself as “linvor” under COM41.

I always wanted to start programming in Processing. And when I came across the Dimmer example in Arduino’s example folder and I saw that there was also some Processing code I decided that this would be my first Processing, Arduino and bluetooth project.

I extended the Dimmer Processing code with a red, green and blue gradient strip. In the example was already the gradient from black to white. The idea was to dim a LED and also to control a RGB led from the GUI.

RGB Dimmer GUI

GUI programmed in Processing

I got some inspiration on how to send values from Processing to Arduino using this post by MadeByFrutos and set up bluetooth communication according to this instructable.

For the bluetooth connection I set up a software serial port on Arduino. I connected the RX of this software serial to the TX pin of the HC-05/HC-06. As the bluetooth module works with 3.3V levels I set up a voltage divider using a 10k poti. The TX of the software serial would be connected to HC-05/06 RX pin using that voltage divider so it would not get levels over 3.3V.

Close up

Please notice the voltage divider (poti) that puts down the level for Arduino’s TX to 3.3V.

Please find the code in my GitHub repository.

Project set up

Set up with Arduino Uno, a red Led, a RGB Led and an HC-06 bluetooth module.

Set up

Backside of the project set up.

12 thoughts on “Connecting to Arduino using Processing and bluetooth (HC-05, HC06)”

  1. Hi This’s cool :}
    Can you control with 5 bluetooth, and 5 light ..? with one program(processing)
    thx

    1. Lee, do you mean 5 arduinos with a bluetooth adapter each?

      If so, yes – As every bluetooth adapter shows up with a different COM port you could even address them individually.

      1. Roman, Yes that is a question i want to ask. Wow cool
        Now im thinking about how to use processing send text to
        Mini LED (to show text)

        Do you know about this.
        HC-05 and XBEE (which one is better)
        and do you this “The Really Bare Bones Board (RBBB)”
        http://jeelabs.com/products/rbbb
        Can i use RBBB instead Arduino UNO..?
        Coz i want to use small equipment.

        Thx

        1. Lee, sorry, I haven’t worked with XBee but from what I know they are way more expensive than a HC-05.
          Also didn’t know the RBBB. But it looks like they are Arduino compatible. Keep in mind that programming is handled with a USB-to-TTL serial cable.

  2. Allow me to ask you a few questions.

    Which programming language did u use to create own GUI and what steps are required to talk to Arduino through HC-05?

    1. I used processing but you can basically use any language you like that has a serial port object.

  3. I’m having the problem with the HC-06 in Windows 8 too.
    How can I configure the Toshiba Bluetooth Stack?

  4. Hi, I would appreciate your help in this. I have been able to send data to arduino through the wireless module, However, I am having trouble sending the data from arduino to PC. Although the module makes and incoming link as well, nothing seems to be sent to the PC. Would you please let me know if you have done something like that. (TX rather than RX) Thanks.

    1. haven’t really tried it but it should be similar. i guess you would need to check for availability of data on the processing end and just send data from the arduino using myserial.write()

  5. Hello , i want to do it with android phone instead of PC ? what can i do else from it ? Please help

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>