# Adafruit E-Ink Bonnet for Raspberry Pi

## Overview

![an 800x480 tri-color display connected to the bonnet](https://cdn-learn.adafruit.com/assets/assets/000/139/679/medium800/adafruit_products_6418-00.jpg?1758030712 )

Easy e-paper finally comes to Raspberry Pi, with this bonnet that's designed to make it a breeze to add any 'standard' pinout 24-pin flex-connector E-Ink display. This add-on handles all the extra components needed to make E-Paper interfacing easy for Pi and Pi-compatible boards. We even include extras like two user buttons, Stemma QT I2C port, and a 3W I2S speaker so you can also have audio playback. Insert your favorite E-Paper display to the connector and you'll have a powerful Linux-powered display for your desk or wall.

![front view of the bonnet](https://cdn-learn.adafruit.com/assets/assets/000/139/680/medium800/adafruit_products_6418-04.jpg?1758030751 )

Chances are you've seen one of those new-fangled 'e-readers' like the Kindle or Nook. They have gigantic electronic paper 'static' displays - that means the image stays on the display even when power is completely disconnected. The image is also high contrast and very daylight readable. It really does look just like printed paper!

**Please note that this does NOT come with the raw display itself** - [we stock a wide variety of bare displays](https://www.adafruit.com/product/6396) that will work great. Don't forget to verify that each display needs driver code to match the driver chip. For displays we sell, [we have examples in our E-Ink Python library you can use to craft your own project](https://github.com/adafruit/Adafruit_CircuitPython_EPD). Often times the E-Paper display has a short cable, in which case [we suggest one of our extender cables](https://www.adafruit.com/product/4230).

![back view of the bonnet](https://cdn-learn.adafruit.com/assets/assets/000/139/681/medium800/adafruit_products_6418-02.jpg?1758030796 )

 **Comes completely pre-assembled and tested** so you can plug it in and install our Python code! **Works with any Raspberry Pi computer that has a 2x20 connector** , such as the Pi B+, Pi 2, Pi 3, Pi 4, Pi 5, and Pi Zero (and any others that have a 2x20 connector!) For installing on Pi's where you need to clear a case or you don't want it against the board, [grab a 2x20 socket riser](https://www.adafruit.com/product/4079).

Since we had some space on the bonnet, we added a [MAX98357 3W 4-8Ω speaker driver](https://www.adafruit.com/product/3006) which has digital I2S input for great sounding audio. This makes it easy to add audio alerts and feedback to your E-Paper projects. [Note you'll have to add a 4-8Ω speaker to the terminal blocks](https://www.adafruit.com/product/4445).

[On the bottom, we have a Qwiic/STEMMA QT connector for I2C sensors and devices so you can plug and play any of our STEMMA QT devices](https://www.adafruit.com/?q=stemma%20qt).

![connector side view of the bonnet](https://cdn-learn.adafruit.com/assets/assets/000/139/682/medium800/adafruit_products_6418-03.jpg?1758030868 )

 **To summarize, you will probably want some accessories to build a full project:**

- A matching 'bare' E-Paper display with standard 24-pin connector [we stock a wide variety of bare displays here](https://www.adafruit.com/product/6396)
- [One of our extender cables](https://www.adafruit.com/product/4230) so you have plenty of maneuvering room
- [A 4-8Ω speaker](https://www.adafruit.com/product/4445) if you want to use the onboard amplifier
- And of course a Raspberry Pi or other 2x20-connector'd single-board Linux computer!

# Adafruit E-Ink Bonnet for Raspberry Pi

## Pinouts

![front and back view of the bonnet](https://cdn-learn.adafruit.com/assets/assets/000/139/790/medium800/adafruit_products_double.jpg?1758308494 )

## E-Paper Display 24-pin Connector

- **24-pin Connect** - This connector allows you to connect bare E-Paper displays.

Pins needed for using the display:

- **MOSI/MISO/SCK** - SPI pins are connected to the default **&nbsp;SPI&nbsp;** port on the Raspberry Pi.
- **CS&nbsp;** on Raspberry Pi&nbsp; **CE 0.**
- **DC&nbsp;** on&nbsp;Raspberry Pi **GPIO 22.**
- **Reset&nbsp;** on&nbsp;Raspberry Pi **GPIO 27.**
- **Busy&nbsp;** on&nbsp;Raspberry Pi **GPIO 17**

## RESE Resistor Switch

In the center of the Bonnet is a slide switch with **3**** Ω **and** 0.5Ω **labels on the board silk. This switch changes the resistor value for the** RESE** pin for the E-Paper display. 0.5Ω is the most common value, but check your display datasheet to confirm.

## Buttons

There are two buttons on the right side of the Bonnet, connected to **GPIO 5&nbsp;** and **GPIO 6**. You can use these as inputs.

## STEMMA QT Connector

- **[STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt) -** This connector, on the left side of the Bonnet, allows you to connect to sensors and breakout boards with STEMMA QT / Qwiic connectors or to other things with **[various associated accessories](https://www.adafruit.com/category/619).**
- **SDA/SCL** - The I2C pins for the STEMMA QT connector are connected to the default **I2C** port on the Pi.
- **3.3V/GND** - The power for the STEMMA QT connector is 3.3V. Ground is the common ground for power and logic.

## STEMMA JST PH

- [**STEMMA JST PH**](https://learn.adafruit.com/introducing-adafruit-stemma-qt) - towards the right side of the Bonnet is a 2mm pitch STEMMA JST port for use with [3-pin STEMMA JST PH cables](https://www.adafruit.com/category/619). It has connections for:
  - **GND** - common ground for power and data. It is the black wire on the JST PH cable.
  - **+5V** - connected to 5V power on the Raspberry Pi. It is the red wire on the JST PH cable.
  - **#12** - connected to GPIO 12 on the Raspberry Pi. It is the white wire on the JST PH cable.

## I2S Amplifier, Speaker Output and Gain

The Bonnet uses the **MAX98357**  **I2S amplifier chip** for digital audio. It uses the following pins:

- **BCLK - GPIO 18**
- **LRCLK - GPIO 19**
- **DIN - GPIO 21**

Towards the center of the Bonnet is the **speaker output terminal block**. It can drive a&nbsp;[4-8Ω speaker](https://www.adafruit.com/product/4445).

Directly above the **MAX98357&nbsp;** is the **Gain** jumper. By default, the gain is set to 6dB. If you cut the jumper, it will set the gain to 9dB.

# Adafruit E-Ink Bonnet for Raspberry Pi

## E-Ink Use

It's easy to use eInk breakouts with Python and the&nbsp;[Adafruit CircuitPython EPD](https://github.com/adafruit/Adafruit_CircuitPython_EPD)&nbsp;library.&nbsp; This library allows you to easily write Python code to control the display.

Since there are&nbsp;_dozens_&nbsp;of Linux computers/boards you can use, we will show wiring for Raspberry Pi. For other platforms,&nbsp;[please visit the guide for CircuitPython on Linux to see whether your platform is supported](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux).&nbsp;

Info: 

Warning: 

## Setup Virtual Environment

If you are installing on the Bookworm version of Raspberry Pi OS or later, you will need to install your python modules in a virtual environment. You can find more information in the&nbsp;[Python Virtual Environment Usage on Raspberry Pi](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi)&nbsp;guide. To Install and activate the virtual environment, use the following commands:

```terminal
sudo apt install python3-venv
python -m venv env --system-site-packages
```

To activate the virtual environment:

```terminal
source env/bin/activate
```

## Install Adafruit\_Blinka

You'll need to install the&nbsp; **Adafruit\_Blinka** library that provides the CircuitPython support in Python. This may also require enabling SPI on your platform and verifying you are running Python 3. [Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)!

## Python Installation of EPD Library

Once that's done, from your command line run the following command:

```terminal
pip3 install adafruit-circuitpython-epd
```

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

If that complains about pip3 not being installed, then run this first to install it:

```terminal
sudo apt-get install python3-pip
```

## Download font5x8.bin

**This library also requires a font file to run!** You can download it below. Before continuing, make sure the folder you are running scripts from&nbsp;contains the **font5x8.bin** file.

[Download font5x8.bin](https://github.com/adafruit/Adafruit_CircuitPython_framebuf/raw/main/examples/font5x8.bin)
Alternatively, you can use `wget` to directly download the file to your pi:

```terminal
wget https://github.com/adafruit/Adafruit_CircuitPython_framebuf/raw/main/examples/font5x8.bin
```

## DejaVu TTF Font

Raspberry Pi usually comes with the DejaVu font already installed, but in case it didn't, you can run the following to install it:

```terminal
sudo apt-get install fonts-dejavu
```

This package was previously calls **ttf-dejavu** , so if you are running an older version of Raspberry Pi OS, it may be called that.

## Pillow Library

Some of the examples also use PIL, the Python Imaging Library, to allow graphics and using text with custom fonts. There are several system libraries that PIL relies on, so installing via a package manager is the easiest way to bring in everything:

```terminal
sudo apt-get install python3-pil
```

## Chip Enable Lines

Follow [these instructions](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/spi-sensors-devices#reassigning-or-disabling-the-spi-chip-enable-lines-3097985) for dealing with SPI chip enable line issues.

That's it. You should be ready to go.

# Adafruit E-Ink Bonnet for Raspberry Pi

## E-Ink Test

Info: The example below is for the 7.5" 800x480 Tri-Color UC8179. You can change the initialization at the top of the code for a different display. You can see this in the [Simple Test example for the CircuitPython EPD library](https://github.com/adafruit/Adafruit_CircuitPython_EPD/blob/main/examples/epd_simpletest.py).

After you've followed the steps on the previous [setup page](https://learn.adafruit.com/adafruit-e-ink-bonnet-for-raspberry-pi/python-setup), you can get started with using bare E-Ink displays with the E-Ink Bonnet and a Raspberry Pi. This page will show the [7.5" 800x480 Tri-Color eInk](https://www.adafruit.com/product/6415) with the Bonnet.

### 7.5" 800x480 Tri-Color eInk / ePaper - Bare Display

[7.5" 800x480 Tri-Color eInk / ePaper - Bare Display](https://www.adafruit.com/product/6415)
[E-Ink/E-Paper displays](https://www.adafruit.com/search?q=E-Ink+%2F+E-Paper)&nbsp;make for great low-power displays that are daylight visible and keep their image even when depowered. For folks who want to DIY their own E-Ink setups,&nbsp;this is a **&nbsp;7.5" diagonal...**

In Stock
[Buy Now](https://www.adafruit.com/product/6415)
[Related Guides to the Product](https://learn.adafruit.com/products/6415/guides)
![7.5" tri-color (red, black, and white) electronic ink display showing a friendly Python and display driver specifications.](https://cdn-shop.adafruit.com/640x480/6415-06.jpg)

If you are using a different display, you'll need to update the initialization at the top of the code. The code below will only work with the 7.5" 800x480 Tri-Color bare display.

Warning: Note this is not a kernel driver that will let you have the console appear on the eInk. However, this is handy when you want to use the eInk display purely from 'user Python' code!

## Wiring

Insert the ribbon cable from the bare E-Ink display into the 24-pin connector on the Bonnet. Then plug the Bonnet into the GPIO pins on the Raspberry Pi.

![a close up of the ribbon cable plugged into the bonnet](https://cdn-learn.adafruit.com/assets/assets/000/139/820/medium800/adafruit_products_54791858610_75e2052b57_o.png?1758567578 )

## Pillow Graphics Demo

The great part about using a display on a Raspberry Pi is that you can use Pillow graphics alongside the CircuitPython driver.

The following example uses Pillow for text and drawing shapes. Copy or download the following example to your computer, and run the following in your virtual environment, replacing&nbsp; **code.py** &nbsp;with whatever you named the file:

`sudo -E env PATH=$PATH python3 code.py`

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/E-Ink_Bonnet_Examples/Blinka_EPD_Demo/code.py

![the basic graphics demo with shapes and text on the display](https://cdn-learn.adafruit.com/assets/assets/000/139/822/medium800/adafruit_products_IMG_5143.png?1758569690 )

## Pillow Image Demo

Pillow is really useful for displaying image files as well.

The following example uses Pillow to display a&nbsp; **.PNG** &nbsp;file. The image is available to download [here](https://cdn-learn.adafruit.com/assets/assets/000/139/823/original/adafruit_products_blinka.png?1758569762) or via the Project Bundle with the&nbsp; **code.py** &nbsp;file.

![the blinka png image file for the demo code](https://cdn-learn.adafruit.com/assets/assets/000/139/823/medium800/adafruit_products_blinka.png?1758569762 )

Copy or download the following example to your computer, and run the following in your virtual environment, replacing&nbsp; **code.py** &nbsp;with whatever you named the file:

`sudo -E env PATH=$PATH python3 code.py`

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/E-Ink_Bonnet_Examples/Blinka_EPD_Pillow_Image/code.py

![the dithered blinka image on the display](https://cdn-learn.adafruit.com/assets/assets/000/139/821/medium800/adafruit_products_IMG_5144.png?1758569662 )

## Updating the Code for Other Displays

The code can be updated to work for a bare display other than the Tri-Color UC8179. This is done by changing the initialization at the top of the code. You can see this in the Simple Test example for the CircuitPython EPD library:

https://github.com/adafruit/Adafruit_CircuitPython_EPD/blob/main/examples/epd_simpletest.py

At the top of the code are a bunch of commented out lines with the different display inits:

```python
# display = Adafruit_JD79661(122, 150,        # 2.13" Quad-color display
# display = Adafruit_SSD1608(200, 200,        # 1.54" HD mono display
# display = Adafruit_SSD1675(122, 250,        # 2.13" HD mono display
# display = Adafruit_SSD1680(122, 250,        # 2.13" HD Tri-color display
# display = Adafruit_SSD1681(200, 200,        # 1.54" HD Tri-color display
# display = Adafruit_SSD1681(200, 200,        # 1.54" HD Tri-color display
# display = Adafruit_IL91874(176, 264,        # 2.7" Tri-color display
# display = Adafruit_EK79686(176, 264,        # 2.7" Tri-color display
# display = Adafruit_IL0373(152, 152,         # 1.54" Tri-color display
# display = Adafruit_UC8151D(128, 296,        # 2.9" mono flexible display
# display = Adafruit_UC8179(648, 480,         # 5.83" mono 648x480 display
# display = Adafruit_UC8179(800, 480,         # 7.5" mono 800x480 display
# display = Adafruit_IL0373(128, 296,         # 2.9" Tri-color display IL0373
# display = Adafruit_SSD1680(128, 296,        # 2.9" Tri-color display SSD1680
# display = Adafruit_SSD1683(400, 300,        # 4.2" 300x400 Tri-Color display
# display = Adafruit_IL0398(400, 300,         # 4.2" Tri-color display
```

For example, if you were using the 2.13" quad-color display, you would update the initialization to be:

```python
display = Adafruit_JD79661(
    122,
    150,
    spi,
    cs_pin=ecs,
    dc_pin=dc,
    sramcs_pin=srcs,
    rst_pin=rst,
    busy_pin=busy,
)
```

# Adafruit E-Ink Bonnet for Raspberry Pi

## Python Docs

# Adafruit E-Ink Bonnet for Raspberry Pi

## MAX98357 Use

Warning: 

Danger: 

# Setup Virtual Environment

If you are installing on the Bookworm version of Raspberry Pi OS or later, you will need to install your python modules in a virtual environment. You can find more information in the&nbsp;[Python Virtual Environment Usage on Raspberry Pi](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi)&nbsp;guide. To Install and activate the virtual environment, use the following commands:

```terminal
sudo apt install python3-venv
python -m venv env --system-site-packages
```

To activate the virtual environment:

```terminal
source env/bin/activate
```

# Installer script

Luckily its quite easy to install support for I2S DACs on Raspbian.

[These instructions are totally cribbed from the PhatDAC instructions at the lovely folks at Pimoroni!](http://learn.pimoroni.com/tutorial/phat/raspberry-pi-phat-dac-install)

Run the following from your Raspberry Pi with Internet connectivity:

```terminal
sudo apt install -y wget
pip3 install adafruit-python-shell
wget https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/raw/main/i2samp.py
sudo -E env PATH=$PATH python3 i2samp.py
```

![](https://cdn-learn.adafruit.com/assets/assets/000/129/696/medium800/adafruit_products_quickinstall.png?1714405053)

We've added an extra helper systemd script that will play quiet audio when the I2S peripheral isn't in use. This removes popping when playback starts or stops. It uses a tiny amount of CPU time (on a Pi Zero, 5%, on a Pi 2 or 3 its negligible). You don't need this on RetroPie because it never releases the I2S device, but it's great for Raspbian.

![](https://cdn-learn.adafruit.com/assets/assets/000/066/516/medium800/adafruit_products_image.png?1543384670)

You will need to reboot once installed.

![](https://cdn-learn.adafruit.com/assets/assets/000/044/812/medium800/adafruit_products_reboot.png?1501791755)

Warning: 

After rebooting, log back in and re-run the script again...It will ask you if you want to test the speaker. Say **y** es and listen for audio to come out of your speakers...

![](https://cdn-learn.adafruit.com/assets/assets/000/044/813/medium800/adafruit_products_spkrtest.png?1501791845)

If it sounds really distorted, it could be the volume is too high. However, in order to have volume control appear in Raspbian desktop or Retropie you must reboot a second time after doing the speaker test, with **sudo reboot**

Warning: 

Once rebooted, try running **alsamixer** and use arrow keys to lower the volume, 50% is a good place to start.

If you're still having audio problems, try re-running the script and saying **N** (disable) the `/dev/zero playback service`.

You can then go to the next page on testing and optimizing your setup. Skip the rest of this page on **Detailed**  **Installation** if the script worked for you!

# Detailed Install

If, for some reason, you can't just run the script and you want to go through the install by hand - here's all the steps!

## Update /etc/modprobe.d (if it exists)

Log into your Pi and get into a serial console (either via a console cable, the TV console, RXVT, or what have you)

Edit the raspi blacklist with

```terminal
sudo nano /etc/modprobe.d/raspi-blacklist.conf
```

![](https://cdn-learn.adafruit.com/assets/assets/000/032/629/medium800/adafruit_products_blacklist.png?1464031033)

 **If the file is empty, just skip this step**

However, if you see the following lines:

`blacklist i2c-bcm2708`  
`blacklist snd-soc-pcm512x `  
`blacklist snd-soc-wm8804`

![](https://cdn-learn.adafruit.com/assets/assets/000/032/630/medium800/adafruit_products_empty.png?1464031122)

Update the lines by putting a **#** before each line

![](https://cdn-learn.adafruit.com/assets/assets/000/032/631/medium800/adafruit_products_blacklisted.png?1464031154)

Save by typing **Control-X Y \<return\>**

## Disable headphone audio (if it's set)

Edit the raspi modules list with

```terminal
sudo nano /etc/modules
```

 **If the file is empty, just skip this step**

However, if you see the following line:

`snd_bcm2835`

![](https://cdn-learn.adafruit.com/assets/assets/000/032/632/medium800/adafruit_products_sndmod.png?1464031844)

Put a **#** in front of it

![](https://cdn-learn.adafruit.com/assets/assets/000/032/633/medium800/adafruit_products_nosnd.png?1464031943)

and save with **Control-X Y \<return\>**

## Create asound.conf file

Edit the raspi modules list with

```terminal
sudo nano /etc/asound.conf
```

This file ought to be blank!

![](https://cdn-learn.adafruit.com/assets/assets/000/032/634/medium800/adafruit_products_newasound.png?1464032034)

Copy and paste the following text into the file

```auto
pcm.speakerbonnet {
   type hw card 0
}

pcm.dmixer {
   type dmix
   ipc_key 1024
   ipc_perm 0666
   slave {
     pcm "speakerbonnet"
     period_time 0
     period_size 1024
     buffer_size 8192
     rate 44100
     channels 2
   }
}

ctl.dmixer {
    type hw card 0
}

pcm.softvol {
    type softvol
    slave.pcm "dmixer"
    control.name "PCM"
    control.card 0
}

ctl.softvol {
    type hw card 0
}

pcm.!default {
    type             plug
    slave.pcm       "softvol"
}
```

![](https://cdn-learn.adafruit.com/assets/assets/000/045/128/medium800/adafruit_products_asound.png?1502334751)

Save the file as usual

## Add Device Tree Overlay

&nbsp;Edit your Pi configuration file with

Info: For older versions of Raspberry Pi, edit /boot/config.txt instead.

```terminal
sudo nano /boot/firmware/config.txt
```

And scroll down to the bottom. If you see a line that says: `dtparam=audio=on`

![](https://cdn-learn.adafruit.com/assets/assets/000/032/636/medium800/adafruit_products_dtover.png?1464032257)

Disable it by putting a **#** in front.

Then add:

```auto
dtoverlay=max98357a
```

on the next line. Save the file and reboot your Pi with

```terminal
sudo reboot
```

# Adafruit E-Ink Bonnet for Raspberry Pi

## Speaker Test

# Speaker Tests!

OK you can use whatever software you like to play audio but if you'd like to test the speaker output, here's some quick commands that will let you verify your amp and speaker are working as they should!

## Simple white noise speaker test

Run

```terminal
speaker-test -c2
```

to generate white noise out of the speaker, alternating left and right.

If you have a mono output amplifier, the I2S amp merges left and right channels, so you'll hear continuous white noise

## Simple WAV speaker test

Once you've got something coming out, try to play an audio file with **speaker-test** (for WAV files, not MP3)

```terminal
speaker-test -c2 --test=wav -w /usr/share/sounds/alsa/Front_Center.wav
```

You'll hear audio coming from left and right alternating speakers

## Simple MP3 speaker test

If you want to play a stream of music, you can try

```terminal
sudo apt-get install -y mpg123
mpg123 http://ice1.somafm.com/u80s-128-mp3
```

[If you want to play MP3's on command, check out this tutorial which covers how to set that up](http://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi "Link: http://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi")

At this time, Jessie Raspbery Pi kernel **does not support mono audio** out of the I2S interface, **you can only play stereo** , so any mono audio files may need conversion to stereo!

Info: 

# Volume adjustment

Many programs like PyGame and Sonic Pi have volume control within the application. For other programs you can set the volume using the command line tool called **alsamixer**. Just type alsamixer in and then use the up/down arrows to set the volume. Press Escape once its set

![](https://cdn-learn.adafruit.com/assets/assets/000/045/130/medium800/adafruit_products_alsamixer.png?1502336173)

In Raspbian PIXEL you can set the volume using the menu item control. If it has an X through it, try restarting the Pi (you have to restart twice after install to get PIXEL to recognize the volume control

![](https://cdn-learn.adafruit.com/assets/assets/000/045/131/medium800/adafruit_products_2017-08-10-033949_1280x800_scrot.png?1502336515)

# Adafruit E-Ink Bonnet for Raspberry Pi

## Pi I2S Tweaks

Warning: 

# Reducing popping

For people who followed our original installation instructions with the simple alsa config, they may find that the I2S audio pops when playing new audio.

The workaround is to use a software mixer to output a fixed sample rate to the I2S device so the bit clock does not change. I use ALSA so I configured **dmixer** and I no longer have any pops or clicks. Note that the RaspPi I2S driver does not support **dmixer** by default and you must [follow these instructions provided](https://support.hifiberry.com/hc/en-us/articles/207397665-Mixing-different-audio-sources) to add it. Continue on for step-by-step on how to enable it!

## Step 1

Start by modify **/boot/firmware/config.txt** to add`dtoverlay=i2s-mmap`

Run **sudo nano /boot/firmware/config.txt** and add the text to the bottom like so:

![](https://cdn-learn.adafruit.com/assets/assets/000/044/822/medium800/adafruit_products_i2smmap.png?1501793168)

Warning: 

Save and exit.

Then change **/etc/asound.conf** to:

```auto
pcm.speakerbonnet {
   type hw card 0 
}

pcm.!default { 
   type plug 
   slave.pcm "dmixer" 
}

pcm.dmixer { 
   type dmix 
   ipc_key 1024
   ipc_perm 0666
   slave { 
     pcm "speakerbonnet" 
     period_time 0
     period_size 1024
     buffer_size 8192
     rate 44100
     channels 2 
   } 
}

ctl.dmixer { 
  type hw card 0 
}
```

By running `sudo nano /etc/asound.conf`

This creates a PCM device called speakerbonnet which is connected to the hardware I2S device. Then we make a new 'dmix' device (`type dmix`) called `pcm.dmixer`. We give it a unique Inter Process Communication key (`ipc_key 1024`) and permissions that are world-read-writeable `(ipc_perm 0666`) The mixer will control the hardware pcm device speakerbonnet (pcm "speakerbonnet") and has a buffer set up so its nice and fast. The communication buffer is set up so there's no delays (`period_time 0`, `period_size 1024` and `buffer_size 8192` work well). The default mixed rate is 44.1khz stereo (`rate 44100 channels 2`)

Finally we set up a control interface but it ended up working best to just put in the hardware device here -`ctl.dmixer { type hw card 0 }`

![](https://cdn-learn.adafruit.com/assets/assets/000/044/823/medium800/adafruit_products_alsaconfig.png?1501793177)

Save and exit. Then reboot the Pi to enable the mixer. Also, while it will _greatly_ reduce popping, you still may get one once in a while - especially when first playing audio!

# Add software volume control

The basic I2S chipset used here does not have software control built in. So we have to 'trick' the Pi into creating a software volume control. [Luckily, its not hard once you know how to do it](http://alsa.opensrc.org/How_to_use_softvol_to_control_the_master_volume).

Create a new audio config file in **~/.asoundrc** with `nano ~/.asoundrc` and inside put the following text:

```auto
pcm.speakerbonnet {
   type hw card 0
}

pcm.dmixer {
   type dmix
   ipc_key 1024
   ipc_perm 0666
   slave {
     pcm "speakerbonnet"
     period_time 0
     period_size 1024
     buffer_size 8192
     rate 44100
     channels 2
   }
}

ctl.dmixer {
    type hw card 0
}

pcm.softvol {
    type softvol
    slave.pcm "dmixer"
    control.name "PCM"
    control.card 0
}

ctl.softvol {
    type hw card 0
}

pcm.!default {
    type             plug
    slave.pcm       "softvol"
}
```

Warning: 

![](https://cdn-learn.adafruit.com/assets/assets/000/044/883/medium800/adafruit_products_softmaster.png?1501994429)

Warning: Pi OS Desktop will trash the ~/.asoundrc configuration file everytime it starts up.

You can set the immutable bit to prevent this file from being destroyed. This is due to the&nbsp;

lxplug-volumepulse desktop widget. Pi OS Lite does not have this issue.

```auto
chattr +i ~/.asoundrc
```

Save and exit

Now, here's the trick, you have to reboot, then play some audio through alsa, then reboot to get the alsamixer to sync up right:

`speaker-test -c2 --test=wav -w /usr/share/sounds/alsa/Front_Center.wav`

_Then_ you can type **alsamixer** to control the volume with the 'classic' alsa mixing interface

![](https://cdn-learn.adafruit.com/assets/assets/000/044/880/medium800/adafruit_products_alsamixer.png?1501993968)

Just press the up and down arrows to set the volume, and ESC to quit

# Adafruit E-Ink Bonnet for Raspberry Pi

## I2S Audio FAQ

### 

Try rebooting once after playing some audio. Also make sure you have our latest alsa configuration (check the detailed install page on the Raspberry Pi Setup page for the `/etc/asound.conf`!

If its still not working, you can still change the volume, just use **alsamixer** from a Terminal command prompt.

### 

Yep, this is a known Raspbian Linux thing. Yay Linux! We don't have a fix for it. If it makes you feel better, my fancy Windows development computer does the same thing with my desktop speakers.

You can reduce popping a lot with the '/dev/zero play' option in the i2s setup script. (We added it in October 2018) but you still might get that one initial pop

### 

Make sure you've lowered the volume. The default is 100% which is waaaay too high! Use **alsamixer** to reduce the volume to 50% or so

### 

It will work with _anything_ that has alsa audio support. There's thousands of linux programs so we can't guarantee all of them will work but here's what we found does for sure!

- **PyGame** - see our page on [playing audio with PyGame](../../../../adafruit-speaker-bonnet-for-raspberry-pi/audio-with-pygame) for example code. Volume can be controlled within pygame
- **mpg123** - command line mp3 audio playback. use alsamixer to control the volume
- **aplay** - for playing wav files on the command line
- **Sonic Pi** - tested in the Pixel Desktop. Use the Sonic Pi settings panel to change the volume - it does not seem to care about what global audio volume you set!
- **Scratch 2** - tested in the Pixel Desktop. Works fine but may have a delay and make a popping sound the first time you play audio. You can set volume with alsamixer and also via the app by using the **set volume to nn%** block
- **Scratch 1** - doesn't work, something not set up with Scratch 1 to use alsa?
- **RetroPie/Emulation Station** - audio works within games (we tested NES and MAME libretro) but does not work in the 'main screen' (selecting which game to play interface)

# Adafruit E-Ink Bonnet for Raspberry Pi

## Downloads

## Files

- [MAX98357 Datasheet](https://cdn-shop.adafruit.com/product-files/3006/MAX98357A-MAX98357B.pdf)
- [EagleCAD PCB files on GitHub](https://github.com/adafruit/Adafruit-E-Ink-Bonnet-for-Raspberry-Pi-PCB)
- [3D models on GitHub](https://github.com/adafruit/Adafruit_CAD_Parts/tree/main/6418%20E-Ink%20Bonnet)
- [Fritzing object in the Adafruit Fritzing Library](https://github.com/adafruit/Fritzing-Library/blob/master/parts/Adafruit%20E-Ink%20Bonnet%20for%20Raspberry%20Pi.fzpz)

## Schematic and Fab Print
![schematic for the bonnet](https://cdn-learn.adafruit.com/assets/assets/000/139/683/medium800/adafruit_products_schem.png?1758032743 )

![the fab print for the bonnet](https://cdn-learn.adafruit.com/assets/assets/000/139/684/medium800/adafruit_products_fab.png?1758032767 dimensions are in inches)

![](https://cdn-learn.adafruit.com/assets/assets/000/139/737/medium800/adafruit_products_6418_E-Ink_Bonnet.jpg?1758134285 )


## Primary Products

### Adafruit E-Ink Bonnet for Raspberry Pi - 24-pin E-Paper Displays

[Adafruit E-Ink Bonnet for Raspberry Pi - 24-pin E-Paper Displays](https://www.adafruit.com/product/6418)
Easy e-paper finally comes to Raspberry Pi, with this bonnet that's designed to make it a breeze to add any 'standard' pinout 24-pin flex-connector E-Ink display. This add-on handles all the extra components needed to make E-Paper interfacing easy for Pi and Pi-compatible boards....

In Stock
[Buy Now](https://www.adafruit.com/product/6418)
[Related Guides to the Product](https://learn.adafruit.com/products/6418/guides)

## Featured Products

### 2x20 Socket Riser Header for Raspberry Pi HATs and Bonnets

[2x20 Socket Riser Header for Raspberry Pi HATs and Bonnets](https://www.adafruit.com/product/4079)
Give yourself a lift with this 2x20 female socket header that has _slightly longer than usual pins_. You can plug this into your Raspberry Pi GPIO port and then plug a HAT or Bonnet or Phat on top.

Especially useful for Bonnets that have slim headers on the bottom, but you want...

In Stock
[Buy Now](https://www.adafruit.com/product/4079)
[Related Guides to the Product](https://learn.adafruit.com/products/4079/guides)
### 7.5" 800x480 Tri-Color eInk / ePaper - Bare Display

[7.5" 800x480 Tri-Color eInk / ePaper - Bare Display](https://www.adafruit.com/product/6415)
[E-Ink/E-Paper displays](https://www.adafruit.com/search?q=E-Ink+%2F+E-Paper)&nbsp;make for great low-power displays that are daylight visible and keep their image even when depowered. For folks who want to DIY their own E-Ink setups,&nbsp;this is a **&nbsp;7.5" diagonal...**

In Stock
[Buy Now](https://www.adafruit.com/product/6415)
[Related Guides to the Product](https://learn.adafruit.com/products/6415/guides)
### Mono Enclosed Speaker with Plain Wires - 3W 4 Ohm

[Mono Enclosed Speaker with Plain Wires - 3W 4 Ohm](https://www.adafruit.com/product/4445)
Listen up! This single&nbsp; 2.8" x 1.2" speaker&nbsp;is&nbsp;the perfect addition to any audio project where you need 4 ohm impedance and 3W or less of power. We particularly like these speakers as they are small and enclosed for good audio volume and quality. This speaker _does..._

In Stock
[Buy Now](https://www.adafruit.com/product/4445)
[Related Guides to the Product](https://learn.adafruit.com/products/4445/guides)
### 24-pin eInk / ePaper Extension Cable 0.5mm Pitch - 25cm Long

[24-pin eInk / ePaper Extension Cable 0.5mm Pitch - 25cm Long](https://www.adafruit.com/product/4230)
When you need more distance between you and your eInk display, use this 24-pin 0.5mm pitch FPC cable [with an extender](https://www.adafruit.com/product/4524) adapter to streeeeeeeeeetch it out. The cable is generic, but we recommend it for use with eInk because often folks want to...

In Stock
[Buy Now](https://www.adafruit.com/product/4230)
[Related Guides to the Product](https://learn.adafruit.com/products/4230/guides)
### Raspberry Pi 4 Model B - 4 GB RAM

[Raspberry Pi 4 Model B - 4 GB RAM](https://www.adafruit.com/product/4296)
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 4 better than the 3? How about a&nbsp;_faster_ processor, USB 3.0 ports, and updated Gigabit Ethernet chip with...

In Stock
[Buy Now](https://www.adafruit.com/product/4296)
[Related Guides to the Product](https://learn.adafruit.com/products/4296/guides)
### Raspberry Pi 5 - 4 GB RAM

[Raspberry Pi 5 - 4 GB RAM](https://www.adafruit.com/product/5812)
The Raspberry Pi 5&nbsp;is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 5 better than the 4? How about a&nbsp;_faster_ processor, USB 3.0 ports, and an updated Gigabit Ethernet chip with PoE...

In Stock
[Buy Now](https://www.adafruit.com/product/5812)
[Related Guides to the Product](https://learn.adafruit.com/products/5812/guides)
### Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C

[Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C](https://www.adafruit.com/product/5814)
The official Raspberry Pi PD USB-C power supply is here! Superfast with just the right amount of cable length to get your Pi 5 projects up and running! With true Power Delivery support, this supply can easily supply 5 A of current!

Comes in gothy Adafruit Black! Great for use with Pi 4...

In Stock
[Buy Now](https://www.adafruit.com/product/5814)
[Related Guides to the Product](https://learn.adafruit.com/products/5814/guides)

## Related Guides

- [Raspberry Pi Care and Troubleshooting](https://learn.adafruit.com/raspberry-pi-care-and-troubleshooting.md)
- [Bare E-Ink Displays Crash Course](https://learn.adafruit.com/bare-e-ink-displays-crash-course.md)
- [eInk Slow Movie Player](https://learn.adafruit.com/eink-slow-movie-player.md)
- [Adafruit VL53L1X Time of Flight Distance Sensor](https://learn.adafruit.com/adafruit-vl53l1x.md)
- [Scroll an SMS Text Message on your RGB Matrix](https://learn.adafruit.com/scroll-an-sms-text-message-on-your-rgb-matrix.md)
- [Adafruit PiCowbell Proto for Pico](https://learn.adafruit.com/picowbell-proto.md)
- [Green Goblin Pumpkin CPB Ornament](https://learn.adafruit.com/green-goblin-pumpkin-cpb-ornament.md)
- [Build an ML Rock Paper Scissors Game with Lobe](https://learn.adafruit.com/lobe-rock-paper-scissors.md)
- [Adafruit MCP9601 I2C Thermocouple Amplifier](https://learn.adafruit.com/adafruit-mcp9601.md)
- [MagTag Showerthoughts and Quotes](https://learn.adafruit.com/magtag-showerthoughts.md)
- [Trellis M4 Expressive MIDI Controller](https://learn.adafruit.com/trellis-m4-midi-keypad-and-tilt-controller.md)
- [Introducing Adafruit Trellis ](https://learn.adafruit.com/adafruit-trellis-diy-open-source-led-keypad.md)
- [CompuCanvas 101 - Transitions](https://learn.adafruit.com/compucanvas-101.md)
- [Adafruit Slider Trinkey](https://learn.adafruit.com/adafruit-slider-trinkey.md)
- [PyPortal Pet Planter with Adafruit IO](https://learn.adafruit.com/pyportal-pet-planter-with-adafruit-io.md)
- [Use Apple HomeKit Devices with itsaSNAP and Adafruit IO](https://learn.adafruit.com/use-apple-homekit-devices-with-itsasnap.md)
- [AdaBox 017](https://learn.adafruit.com/adabox017.md)
