Skip to content

Controlling your Phone with AVRC Commands

Phil Schatzmann edited this page Dec 29, 2022 · 7 revisions

Support for AVRC Commands starting from ESP32 Release 1.0.6

I have added the following AVRC commmands, that you can use to 'control' your A2DP Source (Mobile Phone):

  • play();
  • pause();
  • stop();
  • next();
  • previous();

The following commands are not using AVRC because it is not available in the corresponding IDF release:

  • set_volume(int volume)
  • get_volume()

Please note however that a volume change on the phone is indeed changing the volume of the signal played: It is just not visible via an API.

Support for AVRC Commands starting from ESP32 Release 2.0.0

The Arduino ESP32 Release 2.0.0 (or later) is providing the ESP IDF 4.4 and therefore we have now access to the latest AVRC functionality. This is e.g. available if you add the development url https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json to your Board Manager URLs.

Then the following commands are based on AVRC functionality:

  • set_volume()
  • get_volume()

You can change the volume both from the ESP32 and from the Mobile Phone and the changes are dynamically updated on both devices. Please note that this is only working if the phone supports volume change notification. Mostly older Android Devices do not support this!

If the phone does not support any volume change notification, the volume managed by the phone and the volume managed by the ESP32 are independent of each other and behave like in release 1.0.6 !

Testing if your Phone supports volume change notification

  • Go to the Board Manager and double check that you use ESP32 Release 2.0.0-rc2 (or higher)
  • Set the log level to Verbose
  • Deploy your sketch
  • Change the Volume on your phone: If you see that events are triggered in the log your Phone supports event notification.