Adafruit Volume control

UPDATE: Based on a posting of user j1nx on the mycroft forum (thanks a lot!) the better way to control the initial value of the Adafruit using i2cset and an udev-rule

Enable I2C

I2C is not enabled by default so run and enable I2C in the Interfacing Options

Volume control with i2cset (preferred)

Install the i2c-tools:

  • sudo apt-get install i2c-tools

The command to set the volume (30) is:

  • i2cset -y 1 0x4b 30

Create the udev-rule:

  • sudo nano /etc/udev/rules.d/10-i2c-sound.rules

with the content:

SUBSYSTEM=="i2c", ATTR{name}=="bcm2835 I2C adapter", RUN+="/usr/sbin/i2cset -y 1 0x4b 30"

This blindly sets the volume as soon as the i2c adapter is seen by udev.

How to find the value for the udev rule

Use the command:

  • udevadm info -a -p /sys/bus/i2c/devices/i2c-1

to get the values for SUBSYSTEM and ATTR

Volume control with the Adafruit python library (alternative)

Control the volume of the MAX9744 using the CircuitPython Libraries (see ). The things that I had to do:

Install the library

while in (.venv)

  • pip3 install RPI.GPIO
  • pip3 install adafruit-blinka
  • pip3 install adafruit-circuitpython-max9744
Python script

Use this script to set the initial volume to about the half (the range is 0 to 63). Create ~/bin/ with the following content

  • nano ~/bin/
    import board
    import busio
    import adafruit_max9744
    i2c = busio.I2C(board.SCL, board.SDA)
    amp = adafruit_max9744.MAX9744(i2c)
    amp.volume = 30
Start using systemd

Place a service file in the user directory:

  • nano ~/.config/systemd/user/myadavolume.service

with the content

Description=set adafruit volume

ExecStart=/home/pi/mycroft-core/.venv/bin/python /home/pi/bin/


Enable and start it:

  • systemctl --user daemon-reload
  • systemctl --user enable myadavolume
  • systemctl --user start myadavolume


The picroft installation does not use pulseaudio for the output of voice and other sound so the general volume control did not work

blacklist the internal bcm2835 sound card

This is for sure totally optional but I did it

  • sudo nano /etc/modprobe.d/alsa-blacklist.conf
    blacklist snd_bcm2835

force ALSA userspace to use PulseAudio

  • sudo nano /etc/asound.conf
    # Use PulseAudio by default
    pcm.!default {
      type pulse
      fallback "sysdefault"
      hint {
        show on
        description "Default ALSA Output (currently PulseAudio Sound Server)"
    ctl.!default {
      type pulse
      fallback "sysdefault"

mycroft conf

  • sudo nano /etc/mycroft/mycroft.conf


   "play_wav_cmdline": "aplay -Dplughw:ArrayUAC10,0 %1",
   "play_mp3_cmdline": "mpg123 -a plughw:ArrayUAC10,0 %1",


   "play_wav_cmdline": "paplay %1",
   "play_mp3_cmdline": "mpg123 %1",

additional setting in

This enables ducking and is a nice feature that the volume of music playing is turned down while Mycroft speaks instead of stopping the output.

  • sudo nano /etc/pulse/

add to the end of the file

unload-module module-suspend-on-idle
unload-module module-role-cork
load-module module-role-ducking
Last modified 4 years ago Last modified on 05/01/20 17:37:04