3

I want to create a bluetooth remote audio control to control smartphone audio, essentially identical in function to this type of equipment:

Bluetooth audio control

https://www.amazon.com/FAVOLCANO-Bluetooth-Button-Smartphone-Samsung/dp/B01C5E95XG/ref=pd_lpo_147_bs_t_1?ie=UTF8&refRID=1GRBCPDRMD9YPYPGK73Y

This device is simply a bluebooth remote control which allows you to play or pause audio, skip forward or backward and change media volume on the smart phone.

All of the Arduino tutorials I see are about either using the iPhone to control a bluebooth device, or about using bluetooth to control an arduino, neither of which are what I want to do.

Can you point me in the right direction?

  • 2
    You need a BLE shield with library support for acting as a Bluetooth HID device. – Majenko Jun 23 '16 at 16:18
  • @Majenko Thank you! It's the library that needs bluetooth HID support, not the shield, correct? Or do both need to support it? – Howiecamp Jun 23 '16 at 17:35
  • Both need to support it. – Majenko Jun 23 '16 at 17:56
  • AVRCP is usually used by Bluetooth remotes, not HID. Not sure if BLE supports AVRCP though. – Ignacio Vazquez-Abrams Jun 23 '16 at 20:22
  • @IgnacioVazquez-Abrams - Is HID is normally for non-audio purposes? I don't think it matters to me its BLE or not - it's more just a matter of whether I can accomplish my purpose. Is there a way to (by looking at diagnostics etc) to see if an individual device (eg the one in the pic above) is AVRCP and/or BLE? – Howiecamp Jun 23 '16 at 21:06
5

Bluetooth supports multiple protocols for multiple purposes. There is low latency low quality monorail bi-directional communication with a little bit of bandwidth for control for Bluetooth phone calls. This is called HFE Bluetooth protocol. If you are interfacing a keyboard or a mouse you would use the Human Interface Device protocol or HID. If you wanted to listen to music and control it's playback you would use the high latency high quality 2 audio sending channels (stereo) no return audio channel with a little bit of bandwidth for controlling playback called Advanced Audio Distribution Profile or A2DP.

In this specific case we are only interested in controlling playback. So we could use the HID Bluetooth protocol. However, the native music players on the platform you are using (Android or iPhone) likely will not be listening to such a device. In order for this to work you will probably have to write your own Android or iPhone music player.

On the other hand, it is likely the native music players will work with A2DP Bluetooth protocol. Unfortunately, it is also suspected that once the A2DP Bluetooth connection is established, the phone's speaker will be shutdown and all audio will be diverted to the Bluetooth connection.

Finally, there is the Audio/Video Remote Control Profile or AVRCP. This protocol is used to control media playback. There are several versions of this protocol so what features are available for a given device / music-application may vary greatly.

  • +1 nice answer. I do have one thing to add. I've tested media control via HID and it works for me on Android. (Perhaps HID support has improved in the past 2.5 years.) It's easy enough to test using a bluetooth keyboard that has media buttons. HID may be easier to implement, but I found one drawback. If I haven't hit a key after several minutes, there is a delay in processing the next key. (Power saving mode?) One of my goals was to skip podcast commercials, the delay made HID less useful for this purpose. AVRCP a better choice, even if it's harder to get working. – jimhark Feb 14 at 23:31
  • Thanks for the +1. Assuming the devices you are using are powered off of batteries, I wonder if the delay can be avoided if devices were powered off main instead. – st2000 Feb 15 at 4:28
  • I didn't spend the time to dig into this, I only made some assumptions about the delay. I tested with a BT keyboard, not a device I programmed. The keyboard would go into a stand by mode presumably to save power. This indicated to me that maintaining a full connection used too much power, and behavior seemed to be driven by the keyboard because it was documented in its user manual After that I looked at at AVRCP. But now I'm reading up on BLE's HID over GATT Profile, HOGP which has been supported by Android since KitKat. It's looking like the right solution for me. – jimhark Feb 15 at 23:30
1

I can add something to @st2000's excellent answer (in a better format than our discussion in the comments there).

The original question is vague. Does Bluetooth mean Classic or is Low Energy (BLE) acceptable or preferred. Which smartphones must be supported? Apple and/or Android? And what minimum version must be supported?

The 2.5 years that have passed since this question was asked makes it easier to choose BLE because adoption is so prevalent now.

I've been researching what it would take to implement a media control device as described in the original post. My target smartphone is Android Nougat. My goal is to skip podcast commercials. I have tested using a Bluetooth Classic keyboard. The media control buttons, Play/Pause, skip forward, skip back, etc. seem to do what I need.

I'd prefer to use BLE's support for keyboards and other Human Interface Devices: HID over Gatt Profile (HOGP). The KitKat release notes say that's when HID over GATT support was added, so it's been around for a while.

Having decided on a Bluetooth LE profile, device selection remains. Adafruit Bluefruit LE UART Friend has a HIDKeyboard example. I prefer an MCU with integrated BLE support. While total overkill for this application, I have an ESP32 that I plan to use for this. It has good community support and is cheap. If battery life (or size) becomes a problem, I'll look for a lesser device.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.