I am glad to announce that Bluetooth HID devices are now supported by the USB Host library. The library already supports PS3 and Wiimote controllers, but now you are also able to use Bluetooth mice and keyboards with the library.
An example is available at the following link: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/Bluetooth/BTHID/BTHID.ino.
I have personally tested it with a PS3 keyboard (see image), an Apple Wireless Keyboard and an old Bluetooh mouse from Microsoft and all of them works fine.
For more specific instructions on how to use the library I recommend taking a look at the blog post at my own blog: http://blog.tkjelectronics.dk/2013/12/bluetooth-hid-devices-now-supported-by-the-usb-host-library/.
Feel free to post a comment below if you got questions or got problem with a specific device and I will answer as fast as possible.
Discovering Arduino Bluetooth
This is a second article about Bluetooth connectivity using USB Host library for Arduino. Previous article described Android connectivity
; today, I will show how to connect an Arduino to a Windows machine using USB Host Shield ( available at the store
) and USB Bluetooth dongle.
The biggest issue with Bluetooth on a Windows machine is third-party Bluetooth stacks. They all work well but behave slightly differently and it is not possible to write a step-by-step walkthrough valid for any Windows PC. My setup is 64-bit Windows 7 with Broadcomm Bluetooth stack; other Windows versions and Bluetooth stacks will be slightly different.If you have any difficulties following the text, leave a comment and I’ll try to help. Also, Bluetooth protocols time out very quickly – 5-10 minutes, sometimes less. If you get a timeout at any step simply start over again; sometimes, resetting Arduino may be necessary.
First thing that needs to be done is to make a working Arduino setup. Previous article on the topic gives plenty of information about necessary gear, compatible Bluetooth dongles and expected terminal output. Once this is done, install Bluetooth on Windows. On Win7, the installation consists of plugging in a Bluetooth dongle to USB port and watching the progress of installation process which will start automatically. At the end of the installation system will give you the warning that your PC is not discoverable – ignore it. If installation is successful a Bluetooth icon will appear in the system tray.
The next step is to pair Arduino to a PC. At this point, an Arduino-USB Host Shield-Bluetooth dongle combo shall be put together as described earlier, tested, and set up as follows:
- Powered from external supply – optional but highly recommended, at least for the first attempt. If you decide to use external supply, connect it before USB cable
- Connected to a PC with USB cable. It could be the same PC to which you are going to pair your Arduino via Bluetooth
- Terminal to Arduino opened. It can be Serial Monitor in Arduino IDE or third-party terminal program such as Putty or Teraterm. If everything is wired correctly and Bluetooth dongle is good you should see the following output in the terminal window:
Continue reading Using USB Bluetooth dongle on Arduino to connect to Windows PC
Arduino connected to Nexus S
Since Kristian’s release of SPP service for USB Host 2.0 library
I got many e-mails with questions about Bluetooth serial communications in general and using the SPP class in particular. While establishing a Bluetooth connection is quite easy when using PCs/smartphones/tablets, the Arduino implementation is less user-friendly (for a good reason) and somewhat confusing. This article is intended to be a short tutorial of Arduino USB Bluetooth connectivity using an Android device as a peer – in my opinion, the simplest one to set up and communicate.
To follow this tutorial, you will need the following:
- An Arduino board ( I sell them too )
- full-size USB Host Shield 2.0
- USB Host Shield 2.0 library downloaded and installed in your Arduino library directory
- An SPP example sketch
- Bluetooth dongle – see below for detailed discussion
- Android device – a phone or tablet. The accuracy of this tutorial has been checked on Nexus S phone and Nexus 7 tablet, both running Jelly Bean 4.1.1 OS.
- A Bluetooth terminal emulator app for Android – I use Blueterm
The hardware setup is shown on the title photo (click on it to make it larger). It is a good idea to use external power supply at least in the beginning – some Bluetooth dongles are not happy when powered together with Arduino board/USB Host shield from USB cable. On a side note, it is always a good idea to use external power supply while experimenting with USB devices, especially when using current Arduino boards with their weak regulators. Also, Bluetooth code requires plenty of resources. The example used in this article compiles in ~24K and even though it would work on standard Arduino, any meaningful project will likely require a bigger board, like a Mega.
Continue reading Using USB Bluetooth dongle on Arduino to connect to Android phone
Compatible Bluetooth Dongles
[EDIT] Here is Kristian’s post with more detailed explanation of the example sketch.[/EDIT]
Kristian Lauszus from TKJ Electronics, a man behind PS3 and Xbox360 code in USB Host Shield 2.0 library did it again! I’m pleased to announce that the library now supports standard RFCOMM/SPP implementation, thanks to Kristian’s work.
RFCOMM is basic Bluetooth service and SPP is serial port emulator on top of this. The code allows interfacing standard USB Bluetooth dongles to Arduino boards using USB Host Shield v.2.0. Bluetooth dongles (the ones I’ve tested can be seen on a title picture ) are widely available, cost much less than specialized serial Bluetooth modules (I have a couple of powerful class 1 dongles bought on eBay for $1 shipped) and won’t occupy precious serial port on Arduino board. Even though most dongles are compatible with the code, there are also some that don’t work. The code has been tested for compatibility with all major OSes – Linux, MacOS and Windows 7, as well as Android devices. It will likely work with any RFCOMM client, however, more testing is necessary.
The example code is a simple SPP server. It needs to be started before attempting to connect to it from a PC/phone. Once started, the state of the server is printed on a terminal. After that, the device can be discovered/paired/connected to; it is then possible to send characters from one device to the other by means of a keyboard. In the coming days I will write a series of posts with details of connecting different Bluetooth devices to Arduino. In the mean time, enjoy the code! Please give it a try and let me know what you think.