Example Projects
Workshops
Actuators
Connections
Power
Sensors
Traces
Circuits and Code Wireless

Conductive Materials
Non-Conductive Materials
Tools
Techniques
Circuits and Code
  • Arduino Overview
  • Arduino as Bluetooth HID
  • ATtiny: 7-Segment Display
  • ATtiny: Capacitive Sensing
  • ATtiny: Programming
  • ATtiny Serial & Wireless Boards!
  • ATtiny: Soft Serial
  • ATtiny: Sound
  • ATtiny: Soft Fade
  • Multiplexed Matrix
  • Controlling EL Panel and EL Wire
  • EL panel/wire inverter hack
  • Lasercut Fabric Circuits and Traces
  • Heat Controlling Circuit
  • LED with Light Sensor
  • Lilypad XBee Shield
  • Pull-up Resistors
  • RGB Colour Fade
  • simple heat circuit
  • Solar Powered Motor Circuit
  • Sound Amplifying Circuits
  • Teensy as HID Device
  • Volume Detection
  • Visualization: 2x2 Matrix
  • Visualization: Drawing
  • Visualization: Graph
  • Visualization: Pressure Sensor Matrix
  • Visualization: Touchpad
  • Xbee lilypad shield PCB
  • About
  • Newsletter
  • Shopping Local

  • SEARCH
    Content by Mika Satomi and Hannah Perner-Wilson
    The following institutions have funded our research and supported our work:

    From 2013-2014 Mika is a guest professor at the eLab at Kunsthochschule Berlin-Weissensee

    As of July 2013 Hannah is a researcher at the UdK's Design Research Lab

    From 2010-2012 Mika was a guest researcher in the Smart Textiles Design Lab at The Swedish School of Textiles

    From 2009 - 2011 Hannah was a graduate student in the MIT Media Lab's High-Low Tech research group led by Leah Buechley


    In 2009 Hannah and Mika were both research fellows at the Distance Lab
    We support the Open Source Hardware movement. All our own designs published on this website are released under the Free Cultural Works definition
    Circuits and Code

    Arduino as Bluetooth HID

    Using Sparkfun’s Bluetooth Modem – BlueSMiRF HID to interface between an arduino Pro Mini and a desktop Computer as an Human Interface Device (HID). The default mode of the BlueSMiRF HID is as a keyboard (which is very easy to set up), but you can also use it in HID raw mode (see user manual) to send keyboard, mouse, joystick combos. I am still trying to figure out if there is also a standard way to SEND signals TO the HID Bluetooth modem to trigger events, such as force feedback…

    Also see the Penguin Interface project >> http://www.plusea.at/?page_id=2700

    Setup Instructions

    Materials and Tools

    To replicate this setup you will need:
    - Arduino Mini Pro >> http://www.sparkfun.com/products/9218
    - FTDI board >> http://www.sparkfun.com/products/9716
    - Mini USB cable >> http://www.sparkfun.com/products/598
    - BlueSmirf HID >> http://www.sparkfun.com/products/10938
    - Male headers >> http://www.sparkfun.com/products/553
    - Female headers >> http://www.sparkfun.com/products/115
    - Breadboard >> http://www.sparkfun.com/products/8800
    - Some jumper wire >> http://www.sparkfun.com/products/8024
    - Battery >> http://www.sparkfun.com/products/9876
    - Soldering iron and solder
    - Computer with Bluetooth
    - Arduino software >> http://arduino.cc/en/Main/Software

    About the BlueSMiRF HID

    Download Roving Network’s RN-HID-UM manual >> http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Wireless/Bluetooth/RN-HID-User%20Guidev0%2005.pdf
    Some useful info on the Sparkfun product page’s comments section >> http://www.sparkfun.com/products/10938
    Human Interface Device Profile (HID) >> https://www.bluetooth.org/Building/HowTechnologyWorks/ProfilesAndProtocols/HID.htm
    HID Information >> http://www.usb.org/developers/hidpage/
    Universal Serial Bus (USB) HID Usage Tables >> http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf
    Arduino as a HID Keyboard code by Andrew McDaniel (did not work for me with BlueSmirf Bluetooth modem!) >> http://arduino.cc/forum/index.php?action=printpage;topic=99.0

    For whatever reason the ASCII Codes-HID Report Tables are missing from Roving Network’s RN-HID-UM user manual on page 12. Through trial and error i found that the following HEX codes correspond with the following keys strokes on a Mac OSX:
    right arrow = 0×07;
    left arrow = 0x0B;
    up arrow = 0x0E;
    down arrow = 0x0C;
    enter key = 0x0D;

    Solder headers

    Program Arduino

    Arduino code:
    // test code for sending keystrokes from arduino
    // to computer via HID bluetooth module
    void setup() {
    Serial.begin(115200); // begin serial communication at 115200 baud rate
    }
    void loop() {
    Serial.println(“hello world”); // write hello world
    delay(1000); // delay one second
    }

    Circuit Connections

    BlueSMiRF HID >> Arduino Mini:
    RTS >> GRN = CTS
    RX >> TX
    TX >> RX
    VCC >> VCC
    CTS >> GND
    GND >> BLK = GND

    Connections on the Arduino:
    BLK = black = GND
    GRN = green = CTS

    RS232 Interface:
    TX = Output = Transmitted data
    RX = Input = Received data
    GND = Signal ground
    CTS = Input = Clear to send
    RTS = Output = Request to send
    VCC = Power supply

    Breadboarded Connections

    Soldered Adapter Connection


    Pair with Bluetooth Device

    Pairing Bluetooth device on Mac >> http://www.rioleo.org/setting-up-the-arduino-pro-mini-and-bluetooth-mate-on-mac.php
    Pairing Bluetooth device on Windows >> http://jondontdoit.blogspot.com/2011/11/bluetooth-mate-tutorial.html

    Steps:
    - power your circuit and the light on your Bluetooth modem should blink red
    - open the Bluetooth preferences of your computer and opt to pair with a new Bluetooth device
    - the circuit should show up as a FireFly Bluetooth device with an address similar to this: 00-06-66-43-A2-29
    - opt to connect with passcode, and type “1234″, which is the generic passcode
    - The light on your BlueSmirf Modem should turn a steady green
    - it will try to identify the circuit as a keyboard, press a button on your real (other) keyboard and the next step will let you skip the step and manually input the type of keyboard you want the circuit to be recognized as
    - now that your Bluetooth modem has been recognized as a keyboard you want to quickly open a text editor and it should automatically be printing “hello world”

    “Hello World”

    “hello world” with breadboarded circuit:

    “hello world” with adapter circuit:

    Video

    Problems Disconnecting

    When i disconnect the Bluetooth modem from the power, my computer does not automatically re-connect to it when i re-power it.

    I have to go back into the Bluetooth preferences and opt to add a new device, then select “Okay” when asked “Your computer is already paired with that device. Do you wish to remove the pairing and setup the device again?”

    HID to SPP to HID to SPP…

    The Bluetooth modem can switch back and forth between an HID device and a device with a serial port connection (SPP mode). For this to happen the Arduino needs to put the Bluetooth modem into command mode ($$$) and send the following commands:

    $$$ = command mode
    S~,0 = enables SPP protocol
    R,1 = reboot using SPP
    $$$ S~,0 R,1

    $$$ = command mode
    S~,6 = enables HID protocol
    R,1 = reboot using HID
    $$$ S~,6 R,1

    17 Comments so far

    1. JRMN on January 28th, 2012

      Two questions. Where you able to get the BlueSMiRF HID and you mac to auto pair after it loses and then regain power? Does iOS devices reconize the BlueSMiRF HID? Thanks in advance.

    2. admin on January 28th, 2012

      no, unfortunately, i was not able to get the mac to auto (re-)pair after loosing connection with the HID module. have not tried to connect to it with anything other than a mac or pc computer yet.

    3. JRMN on January 28th, 2012

      Do you have any iOS devices, if so can you check for me? I’m trying to decide whether or not to buy the BlueSMiRF HID breakout board. Thanks.

    4. jonny on February 16th, 2012

      Hi all…

      IOS recognition – Works great as a keyboard. There is even a command to pop up the keyboard on the iPhone. It doesn’t work as a mouse or joystick.

      Connecting after loss of power – This isn’t a problem with pairing. Pairing only needs to be done once and does essentially three things…

      1) The RN42 adds the host to a hidden pairing table of up to 8 hosts
      2) The RN42 sets it’s remote address to the hosts address (which you can see with the GR command)
      3) The host connects to the RN42

      So after power up the problem is that there is no connection, and by pairing again you are forciing a re-connection (step 3 above). Bluetooth allows either end to connect once paired, but Windows has some conventions. For serial BT devices Windows will activly make a connection to serial devices whenever the device is opened, for example in a terminal emulator. Since HID BT devices like keyboards and joystick come and go Windows passively waits for them to initiate the connection. Unlike windows the iPhone actually has an option to connect to any BT device including HID keyboards, so auto connect from the keyboard isn’t required.

      My RN42 keyboard and joystick implementation tries connecting (C command) with the remote address on power up. If the device isn’t yet paired the remote address is empty so the connect fails. It it has been paired then the connection is established. It also have an option to clear the remote address, as there isn’t a way (that I can see) to clear the pairing on the RN42 end.

      thanks
      j

    5. admin on February 16th, 2012

      thank you J!

    6. niranjan on March 3rd, 2012

      is dere anyway to implement HID profile using bluesmirf gold?? Anyone pls let me know…

    7. Bluetooth Module on May 9th, 2012

      I will use this device if its working fast on serial port.. its good while using this device on serial port.

    8. Learn Even more Here on August 7th, 2012

      I have been browsing online more than 4 hours today, yet I never found any interesting
      article like yours. It is pretty worth enough for me.
      In my opinion, if all website owners and bloggers made good content
      as you did, the web will be much more useful than ever before.

    9. hatschi on August 16th, 2012

      Hey,
      did you manage to send signals from your mac to the bluetooth device in HID mode? Something like a force-feedback signal or similar?

    10. Cristiano on August 17th, 2012

      Hello.
      Thank you for your useful post.
      I am trying to build a bluetooth gamepad and reading the RD-42 datasheet I can’t figured out if it is possible to modify the hid descriptor.

      In the datasheet it looks like that whn using the gamepad profile the RD-42 would be see as a controller with 4 analog axis and 8 buttons.

      Do you know if it is possible to change that?

      thank you

    11. Raghad on November 6th, 2012

      Hello,

      Thanks for your helpful post.

      I am doing the same project but for a mouse device using PIC.
      I would like to know if is it possible to use a different baud rate than the default and how can i do this ?

      Thank you.

    12. KliqKeyboards on January 8th, 2013

      Thanks for this tutorial. My question is, why is the data not sent as scan codes? Because not all the keys on a keyboard can be represented as ASCII. You have figured out how to get the translator to send arrow keys, but I think the right way to do it (so that all sorts of special keys can be sent including modifier keys) is to send the data using RAW mode, as stated in page 7 in the manual. I’m not sure how to do it programmatically, though. Any thoughts?

    13. KliqKeyboards on January 8th, 2013

      by the way, the UART code you were missing seems to be there now, on page 13.

      Cristiano: the way to change the HID descriptor is described in the pdf file, basically you need to use a command to flip HID flag register bit.

    14. Kliqkeyboards on January 20th, 2013

      OK, after reading the Roving network doc, I answered my own question. There’s ascii mode where the characters are translated by the roving module to send. And there’s HID raw mode where you can construct your own HID boot keyboard packets, mouse, joystick, multimedia report to send via the Bluetooth link.

    15. Kliqkeyboards on January 20th, 2013

      Here’s the guide with the table you’re missing on page 13: http://www.rovingnetworks.com/resources/download/120/HID_User_Manual

    16. Travis on March 6th, 2013

      How did you figure out the scan code issue? Im having issues with mine where its not sending scan codes and I need it to so that I can make a custom android keyboard to read the codes and perform tasks. Im not really understanding ascii vs HID raw mode.

    17. Lance on April 17th, 2013

      For those who are looking to interface with iOS, here’s an awesome BT4 LE Arduino implementation that I found while researching a project. http://www.rfduino.com/

    Leave a comment