Skip to content

sonocotta/raspberry-media-center

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Media Center and Hats

Open Source Hardware Open Source Software I sell on Tindie
Dev Chat

DSC_0005

Raspberry Pi Media Center and Hats are a series of Raspberry Pi Zero-based media center devices. They share a similar look, and compared to my earlier designs, they have a great-looking aluminum case.

DSC_0081

Raspberry Pi Media Center Hats are cost-effective versions of the above devices, sharing the same DACs and similar schematics, but being able to pair with any Raspberry Pi boards.

Table of Contents

Motivation

I did few audio projects in the past, some using ESP32, some using larger Orange Pi and Raspberry Pi devices. Each has its pros and cons, and with each iteration, I'm trying to focus on the details that were working best for me, while actually using those devices at home.

What is special about the Raspberry eco-system is of course its community support. Being a not-so-strong software developer, I often have to rely on the work that other people did and baked into the base Raspbian image. Attaching a DAC, Ethernet, and IR reader is as simple as adding 3 lines into the config.txt file, which is a bit of magic really

dtoverlay=gpio-ir,gpio_pin=23
dtoverlay=w5500
dtoverlay=hifiberry-dac

Believe it or not, all the device tree definitions, kernel drivers, and dependency packages are already in place.

Sure, compared to the ESP32 platform it is not as lightweight. It requires more power, it takes some time to boot. But when it comes to rapid development, there is nothing like the Raspberry Pi.

Raspberry Pi HiFi Media Center and Hats

DSC_0727

Raspberry Pi HiFi Media Center is a first-in-line product that uses the legendary PCM5100 series DAC with supreme audio quality. It exposes line-level output that you can plug into a stereo amplifier. Analog power comes through an Ultra-low-noise LDO, making sure no interference from Raspberry comes through to your speakers. Spend as much as you need on the external amp to deliver the sound you like (personally I prefer late 80's audio gear).

1X 2X
DSC_0122 DSC_0113

Raspberry Pi HiFi Hat is the lightweight implementation of the same DAC and power circuitry in a Hat shape. It has two flavors: 1X is a traditional DAC that works with any Raspberry Pi out there, while 2X is specifically designed for Raspberry Pi 5 and implements two stereo-DACs which Raspberry Pi 5 users can use independently. Using two of them you can have up to 4 stereo outputs totalling 8 channels of audio.

Amped Raspberry Pi Media Center and Hats

(The Media Center version is in development)

The PCM5100 HiFi DAC combined together with a highly efficient TPA3110D2 D-class amplifier. It brings all the best from the HiFi model and adds an onboard amp to form a complete solution that can be paired with speakers directly. It uses an external power source to feed hungry amps and host Pi using an onboard drop-down converter. Following the same pattern, 1X version is a single DAC+AMP combo that will work with every Pi, while 2X is a Raspberry Pi 5 specialty, that can drive 4 channels independently. 2X boards use 4-layer PCBs to ensure good signal protection to keep that noise low.

1X 2X
DSC_0133 DSC_0054

The Media Center version of the HiFi-Amped model is in the ideation stage. I see it to be a little more than just the same DAC on the boxed shape. The benefit of having DAC and AMP separated is the ability to fiddle with the audio in the middle, so I'm looking to implement volume and tone controls available on the front panel, as well as a tone correction button. I'm thinking of pumping the visual with the LED matrix or small OLED screen, which requires mastering certain mechanical tasks. Long story short, this is a work in progress.

Originally amps could be shut down using GPIO pins, but in the latter version of the board, I removed that functionality. The reason is, that TPA3116 doesn't have a dedicated MUTE pin, and I was using SHDN pin for that purpose. Changing the voltage on that pin created a pop sound, no matter how slow I changed the voltage. I'm planning to switch to a more modern TPA32XX series going forward to solve this issue.

Loud Raspberry Pi Media Center and Hats

DSC_0013

Loud Raspberry Pi Media Center uses a dual MAX98357 HiFi DAC with a built-in highly efficient D-class amp to deliver 3 to 5W of music power directly to your speakers. It is not too loud, but also very simple to use and fun to play with. When DAC is not in use, it goes into shutdown mode, making sure no hissing will keep you up at night. It powers from a standard USB-C power source, like a phone charger, etc.

1X 2X
DSC_0179 DSC_0043

Loud Raspberry Pi Hat is the same DAC and audio circuitry in a cost-efficient Hat form. 1X version can be used with any Raspberry Pi, while Raspberry Pi 5 users can use two pairs of speakers independently on the 2X version. Hat will pull the juice from the Pi's 5V line, or power the Pi itself using screw connectors, so you can make sure enough power is delivered to both boards.

Louder Raspberry Pi Media Center and Hats

Louder Raspberry Pi Louder Raspberry Pi NOPD
DSC_0008 DSC_0100

Louder Raspberry Pi Media Center is a top-of-the-range model that uses a modern highly capable TAS5805M DAC and is aimed to be paired with medium-to-large speaker systems. With 25W per channel stereo output, it packs a punch and can easily enliven living quarters or dorm rooms. It is highly efficient, but much more demanding for power when cranked, therefore it uses USB-C Power Delivery to pull up to 65W from the wall power adapter. Alternatively, the NOPD version will pull the power from a generic power adapter using a standard barrel jack. It can be used both with Wi-Fi and Ethernet (to make sure bad Wi-Fi would not interrupt the stream)

1X 2X
DSC_0169 DSC_0164

Louder Raspberry Pi Hat drops the USB-PD in favor of an external power supply up to 28V (opposed to 20V over PD) and has a step-down converter onboard to deliver 5V to the Pi, so you need only a single power source for everything. Otherwise, it delivers audio through the same highly capable DAC, capable of driving large speakers or tearing apart small ones. The 2X version is a bit special since it uses a TAS5805M capability to chain DACs using the same I2S data source and apply a DSP pipeline on every DAC to deliver flexible speaker combinations. This Hat specifically aimed to deliver a 2.1 speaker configuration with a power budget dedicated to the subwoofer around double of the satellite speaker.

TAS5805M DAC has a highly capable DSP that allows flexible configuration of each channel to fit your needs. I'm working currently on Linux driver improvements that would allow to change DSP settings on the fly from the user space. This would allow changing the EQ settings, Mixer, Gain, and a few other key parameters on the fly.

image

Features

HiFi Raspberry Media Center HiFi Raspberry Hat Amped Raspberry Media Center Amped Raspberry Hat Loud Raspberry Media Center Loud Raspberry Hat Louder Raspberry Media Center Louder Raspberry Hat
Image DSC_0733 (copy 1) DSC_0122 coming soon… DSC_0046 DSC_0008 DSC_0179 DSC_0011-copy DSC_0169
Image (2X, NOPD) DSC_0113 DSC_0043 DSC_0100 DSC_0164
DAC Single PCM5100A 32bit Stereo DAC Single (1X) or Dual (2X) PCM5100A 32bit Stereo DAC Single (1X) or Dual (2X) PCM5100A 32bit Stereo DAC working with
TPA3110D2 D-Class amp
Single (1X) or Dual (2X) PCM5100A 32bit Stereo DAC working with
TPA3110D2 D-Class amp
Dual I2S DAC MAX98357 with built in D-Class amp Dual (1X) or Quadruple (2X) I2S DAC MAX98357 with built in D-Class amp Stereo I2S DAC TAS5805M with built in D-Class amp (1X) Stereo I2S DAC TAS5805M with built in D-Class amp

(2X) Dual (2.1) I2S DAC TAS5805M with built in D-Class amp
Output 2.1 VRMS Line level output -100 dB typical noise level 2x 2.1 VRMS Line level output -100 dB typical noise level [1X]2x 25W (8Ω, 1% THD+N) at 22V; 2x 22W (4Ω, 1% THD+N) at 16V
1x 40W (4Ω, 1% THD+N) at 20V

[2X]4x 25W (8Ω, 1% THD+N) at 22V; 4x 22W (4Ω, 1% THD+N) at 16V
2x 40W (4Ω, 1% THD+N) at 20V
[1X]2x 25W (8Ω, 1% THD+N) at 22V; 2x 22W (4Ω, 1% THD+N) at 16V
1x 40W (4Ω, 1% THD+N) at 20V

[2X]4x 25W (8Ω, 1% THD+N) at 22V; 4x 22W (4Ω, 1% THD+N) at 16V
2x 40W (4Ω, 1% THD+N) at 20V
2x 3W (8Ω); 2x 5W (4Ω) 4x 3W (8Ω); 4x 5W (4Ω) 2x 22W (8Ω, 1% THD+N); 2x 32W (4Ω, 1% THD+N) at 20V
1x 45W (4Ω, 1% THD+N) at 20V
2x 32W (8Ω, 1% THD+N) at 24V
1x 55W (4Ω, 1% THD+N) at 24V
RGB LED yes none yes none yes none yes none
IR input yes yes yes yes (1X), no (2X) yes yes yes yes
External relay driver yes none yes none no none yes none
Onboard Serial Bridge yes none yes none yes none yes none
Ethernet Wiznet W5500 SPI Ethernet none Wiznet W5500 SPI Ethernet none Wiznet W5500 SPI Ethernet none Wiznet W5500 SPI Ethernet none
Powers from 5V USB-C power adapter (up to 1 A)
Triple LP5907 3.3 V Ultra-Low-Noise LDO
5V from the host
5x LP5907 3.3 V Ultra-Low-Noise LDO
5V USB-C power adapter (up to 1 A)
Triple LP5907 3.3 V Ultra-Low-Noise LDO
8..26V from external source
powering host (up to 3A cont.)
5V USB-C power adapter (up to 3 A) 5V from the host (up to 4A)
or 5V from screw connector (powering host)
65W USB-C PD power adapter (25W/45W with limited power)

[NOPD] Up to 26V from external PSU
7..28V from external source
powering host (up to 3A cont.)
Mechanical dimensions (WxHxD) 88mm x 38mm x 100mm 65mm x 30mm x 15mm 88mm x 38mm x 100mm 70mm x 61mm x 20mm 88mm x 38mm x 100mm 65mm x 30mm x 20mm 88mm x 38mm x 100mm 65mm x 56mm x 20mm

Boards Pinout

Audio

I2S CLK I2S DATA I2S WS MAX98357A EN, Loud Media Center MAX98357A EN, Loud Hat TPA3110 EN, HiFi-Amped Hat (Revisions A,B)
Raspberry Pi Zero 18 21 19 4 [1X]8, [2X]5,6 [Rev A, B]5,6
Raspberry Pi 2,3,4 18 21 19 4 [1X]8, [2X]5,6 [Rev A, B]5,6
Raspberry Pi 5 18 21, 23, 25, 27 19 4 [1X]8, [2X]5,6 [Rev A, B]5,6

Peripheral

SPI CLK SPI MOSI SPI MISO LAN RES LAN CS LAN INT WS2812 RGB LED RELAY EN IR INPUT
Raspberry Pi Zero (BCM) 11 10 9 24 8 25 12 7 23

Peripheral (Louder)

I2C CLK I2C DATA DAC PWDN DAC FAULT PD POWER GOOD
Raspberry Pi Zero (BCM) 3 2 4 26 16

Software

Being a Raspberry Pi software selection is a vast space for experimentation. First things first, for any OS you need to configure DAC. Then we talk about different OS options.

DAC Configuration - HiFi Raspberry Pi and Hat

You can use any distribution you like. The only change you need to make to enable hardware is to add 3 lines to the /boot/config.txt

dtoverlay=gpio-ir,gpio_pin=23
dtoverlay=w5500
dtoverlay=hifiberry-dac

DAC Configuration - Amped Raspberry Hat

A simple setup should only include a single line into /boot/config.txt, the amp will be powered on all the time by default.

dtoverlay=hifiberry-dac

[Revisions A and B] If you want to control the amp using GPIO you may use software integration to pull GPIO5/6 HIGH or LOW to switch the amp ON and OFF.

Starting from revision C it will be possible to use device-tree configuration to switch the amp ON and OFF when audio is playing (it is possible in earlier revisions as well, but I didn't manage to avoid fully the speakers popping sound)

DAC Configuration - Loud Raspberry Pi

As simple as the HiFi model, just add 3 lines to the /boot/config.txt

dtoverlay=gpio-ir,gpio_pin=23
dtoverlay=w5500
# pin 4 for Media center, pins 5,6 for Hat
dtoverlay=max98357a,sdmode-pin=4

Note that for Hat only the last line is applicable

Note for 2X Loud Hat - it will probably require a dedicated device tree file, that's a work in progress still

DAC Configuration - Louder Raspberry Pi

TAS5805M DAC is not supported by default Raspbian distribution, therefore some work needs to be done to enable it. Linked repo contains code and instructions on how to configure it. It will take you 5 minutes and one reboot.

Note for 2X Louder Hat - updated driver capable of driving all 3 speakers is a work in progress still.

Bare OS Options

With the bare OS, you're in full control of what to install and configure. It is totally up to your use case.

Raspbian DietPi PostmarketOS
Link link link link
Code link link link
Based on Debian Debian Alpine
Type Bare OS Base OS Bare OS

Bare OS + Standard client services

This is a work in progress and the idea is to have a bare minimum OS (be it Raspbian, DietPi, or Armbian) and install the most used client services via the Ansible playbook. I will add more details, as soon as I have working samples, but planned things to add are

  • Configure DAC (pick one of HiFi, Loud, or Louder)
  • Pulseaudio server with network sink
  • Spotify Connect
  • Snapcast client (with autodiscovery)
  • Slimproto client (with autodiscovery)
  • Apple Airplay
  • UPNP sink (gmediarender)

This will allow integration into existing media sources with Home Assistant, LMS, or Mopidy instance, including multi-room sync.

How to use them

  • Write the downloaded Armbian image onto an SD card of your choice. Start your Orange Pi and find its IP address. The next steps will assume that the IP address of each node stays the same after reboot. You might need to configure your router to lease static IP to Orange Pi to make it stable.
  • Open media-center-via-ansible folder in vscode. In case you don't want to install vscode, you can run commands in plain terminal as well. Please use tasks.json file for reference
  • Prepare hosts file. Add your node's IP address and name. If you prefer password auth, you need to add a password here, but ssh-key auth is recommended
  • Run 0. install host prerequisites task. It will install necessary tools on your laptop/PC, like Ansible client and such
  • Run 1-hifi-raspberry-pi.yml, 1-loud-raspberry-pi.yml or 1-louder-raspberry-pi.yml playbook using 1. apply without password task depending on your hardware.
  • Run remaining playbooks the same way, pick those that you're planning to use

Third-party Media Software

HifiBerry OS PiCorePlayer MupiBox Mopidy Volumio Moode Balena Audio
Link link link link link link link link
Code link link link link link link link
Based on Debian Tiny Core Linux DietPi Debian Debian Debian Balena
Type OS + Services OS + Services OS + Services Services only OS + Services OS + Services OS + Services
Remote management No No No No No No Yes
SW support
UI/UX features
Web UI Yes Yes Yes Yes Yes Yes
Mobile App/UI Yes Yes Yes Yes Yes
IR Remote ? Yes ? ? ? ? Custom
Server features
LMS server Yes ? No ? ? ?
Local library Yes Yes Yes Yes Yes
Radio providers Yes Yes Yes Yes Yes
Snapcast server ? ? ? ? ? ? Yes
Client features
LMS Client/Squeezelite Yes Yes ? No Yes Yes ?
Airplay Yes Yes ? No Yes Yes Yes
Spotify Yes Yes Yes No Yes Yes Yes
Snapcast client (HA) Yes ? ? ? ? ? Yes
Pulseaudio sink ? ? ? ? ? ? Yes
UPNP/DLNA client Yes Yes Yes
MPD Yes

Volumio

Volumio is a great piece of software, extremely popular with media center devices like Raspberry Media Center.

With HiFi Raspberry and Loud Raspberry, things are fairly simple. Those DACs are supported out of the box. Select HiFiBerry DAC and Adafruit MAX98357 in the DAC Model settings accordingly. Optionally you may also create a /boot/userconfig.txt file and add the following config to enable W5500 Ethernet

[all]
dtoverlay=w5500

For Louder Raspberry, you'd need to perform a few more steps to configure a custom DAC.

Setup instructions

First, get access to the terminal either from USB-Serial or from SSH. To enter the Serial terminal you'd need to add this line to /boot/volumioconfig.txt

enable_uart=1

You can enable SSH at volumio.local/dev and log in using user volumio and password volumio

We're about to build kernel modules, so we need to install a few dependencies first (all commands going forward are running on the target host, ie Raspberry Pi)

sudo apt update && sudo apt install git raspberrypi-kernel-headers build-essential -y

Assuming you're in, first install build prerequisites (this will take a while, grab a coffee)

volumio kernelsource

Next, pull the DAC driver from the GitHub

cd ~
git clone https://github.com/sonocotta/tas5805m-for-raspbian-paspberry-pi-zero
cd tas5805m-for-raspbian-paspberry-pi-zero

Build kernel driver

cd /usr/src/rpi-linux && sudo find . -type d -exec chmod 755 {} \;  # no idea why permissions are not right, but this should fix it
cd ~/tas5805m-for-raspbian-paspberry-pi-zero
make all

If all goes well you should see no errors in the console

make -C /lib/modules/6.1.77+/build M=/home/volumio/dev/tas5805m-for-raspbian-paspberry-pi-zero modules
make[1]: Entering directory '/usr/src/rpi-linux'
  CC [M]  /home/volumio/dev/tas5805m-for-raspbian-paspberry-pi-zero/tas5805m.o
  MODPOST /home/volumio/dev/tas5805m-for-raspbian-paspberry-pi-zero/Module.symvers
  CC [M]  /home/volumio/dev/tas5805m-for-raspbian-paspberry-pi-zero/tas5805m.mod.o
  LD [M]  /home/volumio/dev/tas5805m-for-raspbian-paspberry-pi-zero/tas5805m.ko
make[1]: Leaving directory '/usr/src/rpi-linux'

Copy over kernel drivers to the filesystem

sudo make install

Now let's compile and copy the device tree

sudo apt install device-tree-compiler -y
sudo ./compile-overlay.sh

Next, we need to update the Volumio settings. Navigate to /volumio/app/plugins/system_controller/i2s_dacs/dacs.json file and add this line as the first choice in the Raspberry PI section

{"id":"louder-raspberry","name":"Louder Raspberry","overlay":"tas5805m,i2creg=0x2d","alsanum":"2","alsacard":"LouderRaspberry","mixer":"Master","modules":"tas5805m","script":"","needsreboot":"yes"},

image

Restart the Volumio service

sudo systemctl restart volumio.service

Now you should be able to select Louder Raspberry in the DAC list, which will restart the Raspberry

image

At this stage it is not changing DT overlay automatically, I need to figure out why, but for now let's add it manually to the end of the /boot/config.txt file

#### Volumio i2s setting below: do not alter ####
dtoverlay=tas5805m,i2creg=0x2d

After reboot, you should be able to see the new sound card via aplay -l

card 2: LouderRaspberry [Louder-Raspberry], device 0: bcm2835-i2s-tas5805m-amplifier tas5805m-amplifier-0 [bcm2835-i2s-tas5805m-amplifier tas5805m-amplifier-0] ^F Forward
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Volumio will start playing using the right DAC on its own. Congratulations!

Rotating MAC address on the W5500

On some systems, the W5500 driver will rotate the chip's MAC address on each boot, which is quite annoying if you're binding the DHCP server to them. There is a manual fix that can help with that

  • Downloaded the w5500 overlay file
  • uncomment this line and change the MAC to your liking // local-mac-address = [aa bb cc dd ee ff];
  • save the file as w5500-overlay-custom.dts
  • create the binary with the following command: dtc -I dts -O dtb -o w5500-custom.dtbo w5500-overlay-custom.dts
  • backup the original w5500.dtbo: sudo mv /boot/overlays/w5500.dtbo /boot/overlays/w5500.dtboBACKUP
  • move the new .dtbo into the overlays directory: sudo cp w5500-custom.dtbo /boot/overlays/w5500.dtbo
  • reboot and ip a will report the new MAC address

TAS5805M DSP Capabilities

TAS5805M DAC (and his big brother TAS5825M) has quite a sophisticated DSP inside, which is mostly undiscovered by the community at the moment. Documentation of it is scarce. The only reasonable way to use it is to obtain a TI PurePath license and Hardware Development kit ($250 if you find it). This should allow the following skills

  • 2.0, 1.1, 2.1, 0.1, and pretty much any other speaker configuration
  • Loudness correction (or Tone correction)
  • Soft clipping
  • Individual EQ (16 of them I think)
  • True mono and other routing configurations
  • And many more
PurePath screenshots

image image image image

I'm planning to dive deep into the topic (whenever I have time, haha) and provide an optional setting for the most common configurations. This is a work in progress with no deadline set.

Hardware

Please visit the hardware section for board schematics and PCB designs. Note that PCBs are shared as multi-layer PDFs as well as Gerber archives.

HiFi Raspberry Pi

Front Back PCB
DSC_0730 (copy 1) JPG-mh (1) DSC_0733 (copy 1) JPG-mh DSC_0739 (copy 1) JPG-mh

HiFi Raspberry Hat

Image
image

HiFi-Amped Raspberry Hat

Image
image

Loud Raspberry Pi

Front Back PCB
DSC_0730 (copy 1) JPG-mh (1) DSC_0008_small JPG-mh (1) DSC_0016_small JPG-mh

Loud Raspberry Hat

Image
image

Louder Raspberry Pi

Front Back Back (NOPD) PCB
DSC_0730 (copy 1) JPG-mh (1) DSC_0011-copy JPG-mh image DSC_0004-copy JPG-mh

Louder Raspberry Hat

Image
image

Power considerations

Hifi and Loud Raspberry

According to the manufacturer Raspberry Pi Zero requires at least 1 Amp of 5V line, and each of the Loud Raspberry DAC needs at least 1 Amp extra. With the total budget requirement of 3 Amps, it is within specs for a non-PD USB-C 5V power line. I've decided not to use USB-PD for The Loud model. Just make sure your power adapter is capable of 3 Amps (or keep a reasonable volume if it is not).

HiFi Raspberry barely uses extra power compared to what the Raspberry Pi Zero board itself needs. No special requirements are there.

Louder Raspberry

For Louder Raspberry, it is clearly not an option. You'd need a PD-enabled power adapter to run the board. Ideally, you should supply a 20V 3.25 Amp capable power source, common for modern laptops (Dell, HP, and Lenovo all tested and work perfectly). However, pretty much any 9V/12V/20V PD-enabled power adapter will work, most typically phone chargers with a quick charge option. The smallest of the family is a 25W model, which is plenty enough for both Raspberry Pi and DAC.

The interesting part was all the phone and laptop chargers I used for the test (around five different makes of each), sounded great, with no hissing, no popping. (Apart from the Apple ones, they didn’t work. Likely they have Apple-specific PD protocol). This is probably because modern devices have become so noise-sensitive that manufacturers have been forced to do good work on noise levels.

Tested and perfectly working models are (others may be available)
Model Image
65W USB-C Lenovo ThinkPad Laptop Charger Replacement Power Adapter image
65W 45W 20V 3.25A Type-C PD Laptop Charger image
120W Gan Type-C PD Charger image
45W Type-C PD Mobile Phone Wall Adapter image

Because USB-PD is a bit of a Wild West in terms of standards, sometimes not everything goes as designed. Some people have run into this with power adapters that aren’t fully PD-standard compliant. In most cases, the worst that happens is the PD chip doesn’t trigger the 20V mode, so the Raspberry goes into the boot loop, not getting enough voltage on the 5V bus.

Louder Raspberry NOPD

The “hammer-style” solution I came up with is a new NOPD version of the Louder Raspberry that lets you use a barrel power jack to supply raw voltage directly. The catch? Standard 2mm pins can’t handle high currents, so I’ve gone with a 2.5mm pin instead — it’s a bit unusual but still common enough in the laptop world.

image

With this setup, you can supply more than the 20V limit of PD, giving you a bit more power for the speakers. You probably won’t hear much difference (thanks to the way human hearing works), but it could help larger speakers that need a bit more to really “open up." Other than that, the NOPD version works just like the PD version — no software changes are needed.

Serial and USB-PD

One caveat is that, since Raspberry Pi requires 5V to run and the input voltage is in the range of 5 to 20 volts, I failed to find a step-down converter that (a) supports this wide input range and (b) can run in no-dropout mode (meaning keep 5V output on 5V input). If you know one, please let me know. But at this moment you have to supply more than 5V over USB (meaning 9V in PD standards) to start the Raspberry.

Now, you have USB power delivery and the Serial on the same bus, how should this work then? When you're developing, you may not require the full power of the DAC, and it will happily work with 5V input (limited to something like 5W of music power per channel). you just supply 5V to the Raspberry using a micro-USB cable, while USB-C will power the DAC with 5V and give you a Serial console at the same time

image

Relay Driver

HiFi version of the Raspberry Media Center has an internal driver for the external relay. It has a back-facing diode to shunt any coil-inducted currents. Driver is an open-drain output with the following states

Driver Pin State (IO7) Output state Relay connected between OUT and +5V
Floating (pulled low with 100K resistor) or
LOW
High impedance INACTIVE (switched OFF)
HIGH Pulled to GND ACTIVE (switched ON)

Schematics:

image

External relay can be connected directly between OUT and +5V pins (1st and 3rd pins, mid pin being GND)

IR reader

Start by configuring IR device-tree overlay in the /boot/config.txt file

Setup instructions
# Enable IR reader on GPIO23
dtoverlay=gpio-ir,gpio_pin=23

After reboot, you should be able to see /dev/lirc0 device

$ ls -al /dev/lirc0 
crw-rw---- 1 root video 251, 0 Jun 17 21:51 /dev/lirc0

There are multiple ways you can capture IR signals using /dev/lirc0 device, one of them is to use lirc utilities by installing them via

$ sudo apt install lirc -y

Next, we need to pull the remote configuration or create new one by training lirc. First path is much easier, you may find your remote in the library here. Pull it into lirc config by running

$ cd /etc/lirc/lircd.conf.d/ 
$ sudo wget -O aa59-00741a.lircd.conf https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/samsung/aa59-00741a.lircd.conf?format=raw
$ sudo service lircd restart

To be sure, I've updated also /etc/lirc/lirc_options.conf changing 2 lines

driver          = default
device          = /dev/lirc0

Next, capture incoming IR codes by running

$ irw
00000000e0e0e01f 00 KEY_VOLUMEUP Samsung_TV
00000000e0e0e01f 01 KEY_VOLUMEUP Samsung_TV
00000000e0e0e01f 00 KEY_VOLUMEUP Samsung_TV
00000000e0e0d02f 00 KEY_VOLUMEDOWN Samsung_TV
00000000e0e0d02f 01 KEY_VOLUMEDOWN Samsung_TV

RGB Led

The tested method of controlling RGB LED is to use rpi_ws281x library, available as rpi-ws281x-python module. You can install it with pip. This library uses PWN capabilities of the GPIO and does not require any specific device tree configuration. The only configuration that you'd need in any of the provided examples is below

Setup instructions

Install the library first

sudo apt install python3-pip git -y
sudo pip install rpi_ws281x --break-system-packages

Pull the example repo

git clone https://github.com/rpi-ws281x/rpi-ws281x-python/ && cd rpi-ws281x-python/examples

Update any of the example's header with the below configuration

# LED strip configuration:
LED_COUNT = 1         
LED_PIN = 12          
LED_FREQ_HZ = 800000  
LED_DMA = 10          
LED_BRIGHTNESS = 255  
LED_INVERT = False    
LED_CHANNEL = 0       

Now you're ready to run it

sudo python3 ./strandtest.py

IMG_1739 MOV

Unfortunately, this library uses direct access to memory, so you need to run it as root.

Raspberry Pi 5 note

Raspberry Pi 5 is the first one that allows to drive multiple I2S data lines using the same interface. What it means in practice, is that while all older Pis have just 3 I2S lines (CLK, WS, DATA), Pi5 support up to 4 Data lines (CLK, WS, D0, D1, D2, D3), capable of driving 4 independent audio interfaces.

2X Raspberry Pi hats have support for alternative data lines. You need to short some solder bridge to use it though. It allows configuring Hats to use different pins and stack them together to create 4 individual stereo interfaces (8 channels in total) using the same device.

By default, 2X hat uses pins 21,23 for data, with the possibility to switch to pins 25, and 27 with solder bridges and stack 2 boards together.

HiFi Hat (rev C) HiFi Hat (rev D) HiFi-Amped Hat Loud Hat
image image image image

Configuration value that allows this is quite simply

dtoverlay=hifiberry-dac8x

At this point, all Hats with 1X marking is a single DAC version that can be used with every Pi, including Pi 5. The 2X version uses two data lines of the Pi5 and will work out-of-the-box with it. It can be changed to use a second set of data lines, so 2 boards stacked together will utilize 4 DACs or 8 channels of audio. You can short data lines together and use 2X Hat with Pi2/3/4, having 2 parallel DAC channels.

Demo

Loud Raspberry Pi Media Center audio test

Where to buy

You may support our work by ordering this product at Tindie

Press mentions

About

Raspberry Pi Zero based media center (Hardware project)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •