14

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?

6
  • 2
    You need a BLE shield with library support for acting as a Bluetooth HID device.
    – Majenko
    Commented Jun 23, 2016 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
    Commented Jun 23, 2016 at 17:35
  • Both need to support it.
    – Majenko
    Commented Jun 23, 2016 at 17:56
  • AVRCP is usually used by Bluetooth remotes, not HID. Not sure if BLE supports AVRCP though. Commented Jun 23, 2016 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
    Commented Jun 23, 2016 at 21:06

3 Answers 3

16

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.

3
  • 2
    +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
    Commented Feb 14, 2019 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
    Commented Feb 15, 2019 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
    Commented Feb 15, 2019 at 23:30
4

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.

2

I did it on HC-05 (reflash to RN-42) and use HID profile to send command: Play/pause fwd/rwd vol+/- I can post sample code if needed. Here's the video https://youtu.be/y8PcNbAA6AQ

4
  • 4
    Please edit your answer to add the sample code.
    – VE7JRO
    Commented Jan 2, 2020 at 23:58
  • 2
    I'm trying to do exactly the same, would you mind sharing your code please?
    – Maen
    Commented Jul 29, 2020 at 18:46
  • 1
    Yes, some sample code would be much appreciated.
    – Zeph
    Commented Nov 1, 2020 at 22:01
  • 1
    Posting Arduino code that shows how to use the AVRCP would be great, if you've done it.
    – asylumax
    Commented Jan 22, 2022 at 21:12

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