You Can DIY!: A Class D HAT for Raspberry Pi

April 1 2020, 14:10
High-quality DIY music systems don’t have to be bulky and expensive. With the new MERUS range of amplifier products from Infineon, it is easy and affordable to build powerful (2 x 40 W peak power) distributed Class D audio amplifier-based systems with advanced features (e.g., EQ audio processing and multi-room wireless audio streaming).

Implementation is a snap, as the small, 56 mm × 30 mm Hardware Attached on Top (HAT) board fits directly on top of the Raspberry Pi Zero W board (see Photo 1). The board uses the same single 5 V supply that is already available on these. On-board power management and voltage boosting from the 5 V Raspberry Pi supply to 20 V ensures sufficient dynamic range and plenty of headroom margin to guarantee an undistorted open and natural sound that outperforms most off-the-shelf wireless speakers (see Figure 1).

No additional components are needed — so anyone equipped with a screwdriver can now turn their old loudspeakers into very powerful high-end wireless speakers. The amplifier is extremely power-efficient and does not add much to the overall power budget of the Raspberry Pi Zero. From a power consumption and battery playback time perspective, the powerful audio amplifier addition is almost “free”—making the solution extremely suitable also for portable applications.

Everybody Loves Audio
While Infineon’s MERUS integrated multi-level Class D audio amplifier ICs are rapidly gaining popularity with established audio brands and ODMs, there has also been steadily increasing interest from makers, tinkerers, hobby designers, and DIY enthusiasts who are eager to build their own high-end audio devices and systems.

The highly power-efficient MERUS ICs are ideally suited for these compact audio amplifications as they can provide very high dynamic output range and the ability to play loud, but at the same time they do not require heatsinks or extensive output filtering.

Very often, however, it has proven too difficult for non-professional users to utilize the new digital input audio-amplifier ICs to their full potential — not because of the amplifier ICs per se — but because of other system components required to build a full-fledged audio system.

With the functions and features we have come to expect in a modern audio product (e.g., stereo pairing, multi-room wireless audio streaming, advanced audio processing capabilities, etc.), until now making a full active audio design solution has just been too complex a task for the average hobbyist to overcome.

The Raspberry Pi Revolution
As the world’s third best-selling general-purpose computer, the Raspberry Pi is a phenomenon. Since Esben Upton and his team revolutionized the computer industry back in 2011 with their first prototype of the affordable and flexible Raspberry Pi computer, it has become a lot easier for everyone to get access to a very powerful and yet inexpensive computer platform.

If you have any prior experience as an electronics hobbyist, chances are high that you already have one of these tiny British-made boards in your drawers somewhere. Raspberry Pi boards are literally used everywhere in anything and everything from laptops, household appliances, and robots to thin clients and industrial control systems. Rumor has it that they even use Raspberry Pi boards to run experiments onboard the International Space Station.

As such, the Raspberry Pi Zero W is a fantastic, miniature version of the Raspberry Pi that shrinks the board down to about the size of a stick of gum and packs in Bluetooth 4.0 as well as 802.11n wireless LAN connectivity, all at a very attractive price point of around $10.
Photo 1: The small, 56 mm × 30 mm Hardware Attached on Top (HAT) board fits directly on top of the Raspberry Pi Zero W board.

Tapping into a Free Software Ecosystem
Much of the success of the Raspberry Pi is grounded in its use of open-source software. The Raspberry Pi runs Linux on a multi-core ARM CPU, which is the same hardware that you will find in many tablets, smartphones, and set-top boxes - and therefore  the operating system on the Raspberry Pi also uses the same software repositories that powers the entire Linux software ecosystem.

This means that you are tapping into the same code base that is running on almost 2 billion Android smartphones and a vast majority of the servers that are powering the Internet. Building on 20 years of continuous software development you get a lot for free—also in terms of audio functionality. The audio stack on Linux is well-designed and allows applications to stream digital audio uncompressed to the hardware codec that is connected to the I2S audio bus. With the Pi HAT board, Infineon is providing a compatible low-level driver which ensures plug-and-play digital audio with its integrated multilevel Class D audio amplifier IC on the Pi HAT.

What is more, advanced users who want to push the limits of their DIY audio system even further can add digital-signal-processing to their audio systems. The Raspberry Pi platform is compatible with open-source and free-license audio programming frameworks (e.g., Pure Data and JUCE). So it is quite feasible for the advanced user to apply additional functionality and features such as speaker equalization, crossover filters, room acoustics correction or other DSP algorithms.

Making It Easy
Intended for the construction of active loudspeakers and wireless music streaming with minimum size, extremely low power consumption, and best-in-class HD audio quality, the MERUS audio amplifier reference boards are equipped with the MA12070P monolithic Class D multilevel amplifier IC. Driven from a single 5 V supply and an onboard voltage-boost-converter, the system can provide up to 2 × 40 W peak output power boosted from the Raspberry Pi supply with up to 48 kHz/24-bit music playback.

There is no need for additional power supplies as the MERUS audio amplifier attaches directly on top of the Raspberry Pi Zero W board and is powered directly from its 5 V supply rail—so no additional components required. 

The single power supply is easily added by connecting a standard mobile phone charger via the onboard USB connector—and to build a truly wireless and portable system, you can simply add a power bank unit. The output power of the system is related directly to the peak output current of the power bank battery so make sure to use one with enough oomph. A 5 V/2.1 A with 3000 mAh capacity would be a good starting point. This will give you roughly 10 hours of continuous playback time at 60% output volume from your phone. The effective playback time is dominated by the power consumption of the Bluetooth and WiFi functionality on the Raspberry Pi Zero W board, but there are also numerous possibilities to upgrade the battery for even longer playback time.

To get the system up and running, all you need to do is to download the software onto your PC, write it to an SD card which slots into the Raspberry Pi, attach the Pi HAT to your speaker(s) and plug in the power supply. In a few seconds, you will have a full-fledged high-end wireless Hi-Fi audio system.
Figure 1: To get the system up running, all you need to do is to download the software on your PC, write it to an SD card which slots into the Raspberry Pi, attach the Pi HAT to your speaker(s) and plug in the power supply.

The resulting design is compatible with the most popular audio streaming applications for Raspberry Pi such as Justboom Player, Volumio, Max2Play, and it can be also used in Raspbian as an Airplay client or Bluetooth audio receiver.

This means that you can control the speakers from your phone or PC and pair them up in the configurations you want while streaming with Spotify, Google Music or SoundCloud to access Webradio, Podcasts, music from the cloud, or your own collection from a device anywhere in your network throughout your home or on the move.

Together, the Raspberry Pi Zero W and MERUS MA12070P Pi HAT amplifier boards make up a very strong combination that we foresee being used in a plethora of DIY audio applications such as smart speakers, soundbars, on-the-go speakers and intelligent home audio systems.

The Raspberry Pi Zero W boards are available from many sources and the Pi HAT Class D audio boards from Infineon are priced at $29.95 for single quantities and are available for sale at For Infineon’s product offering of multilevel Class D audio amplifiers, visit aX

This article was originally published in audioXpress, January 2020.
related items