Unicorn pHAT - incompatible with Retropie?

I’m trying to setup a Unicorn pHAT on a Pi 3 running Retropie. The software seems to install correctly, but when I run a sample script, I get completely random lighting on the Unicorn pHAT: see this video.

I updated everything with apt-update and apt-upgrade, then updated Retropie (with an updated script) using the binary based installation. I ran the Unicorn Hat setup one-liner, with no errors.

I tested the pHAT on a Pi 2 running Raspbian Jessie, and it worked perfectly fine.

What other trouble-shooting steps should I take?


I’m a little rusty on what exactly causes this, so I’ve dug up my reply from another thread on this topic:

I had a support ticket from a guy using Retro Pie with the Unicorn HAT a while ago- it turns out that the two most definitely don’t play well together. The Retro Pie initialises some sound drivers which completely garble the Unicorn HAT output and make it basically impossible to use once you log in.

It’s possible to fix, but the fix is to prevent Retro Pie launching on login- which is kind of counter-productive when your goal is retro gaming.

The fix is generally “use HDMI audio so it doesn’t conflict,” but I don’t recall this working on RetroPie as it should. I don’t know if this is something that can be raised with the RetroPie team, since the system shouldn’t be doing anything over analog audio if it’s set up to output via HDMI.

brentwomble, you might look at Addressing pixels of Unicorn Phat wierdness to see what fun is being had there with the addressing of the 8x4 display. It might just be the code trying to address an 8x8 display rather than any audio conflict?

The Pi uses PWM for it’s audio out through the headphone jack, and the Unicorn HAT/pHAT use PWM for their data, hence the conflicts.

@gadgetoid is correct in saying that HDMI audio should resolve the conflict.

Another fix is to use an I2S audio DAC, like our pHAT DAC for audio and then reassign the data pin for your Unicorn HAT/pHAT to pin 12 (pin 18 is used for the pHAT DAC I2S audio). However, I’ve had some trouble getting pHAT DAC to play nice with Retropie.

The final option is to use a small Arduino to drive your Unicorn pHAT. Is it for lighting? I’ve used a Neopixel strip and ring to light my Picade, with a Trinket Pro driving them.

@gadgetoid @sandyjmacdonald
Setting the audio output to force HDMI in Raspi-config fixed the issue with the Unicorn pHAT. However, this solution doesn’t help with larger project goal: lighting a Picade. I have the 8" screen (connected by HDMI), and the audio runs from the headphone jack through the Picade PCB.

So I guess my best option would be to drive the Unicorn pHAT with a Trinket or Trinket Pro.

I checked the addressing, and it wasn’t the issue. I used test scripts set to the pHAT configuration.

Hi again Brent,

I should have been clearer when talking about the HDMI audio. You should be able to use an HDMI to HDMI adaptor like this to break out the audio from the HDMI and then feed it into the Picade board.

If you want to go down the Arduino route, then you can have a look at the way that I did it in my Picade blog posts here and here.

Can you give some more detail about how you want to light your Picade?

Hi @sandyjmacdonald,

I read your blog posts back when I was preparing to buy a Picade!

I don’t currently have the resources to light up the marquee and controls like you did (although yours looks awesome). I was planning on having the Unicorn pHAT mounted on the Pi, so that the lighting would shine through the various holes in the case. I thought it’d be a cheap and easy mod :)

Breaking out the audio from the HDMI would work, but it seems like a pretty expensive workaround. I’d probably get better audio quality by using the DAC pHAT.

I think the Arduino route is the best choice. Do you think Trinket Arduino library would play nice with the Unicorn library? I don’t have any prior experience with Arduino.


Maybe the best and cheapest way would be to use a separate Pi Zero with Unicorn pHAT for the lighting? A little bird tells me there might be some Pi Zeros available on Monday. ;-)

@sandyjmacdonald Thanks ;)

If other items also come back in stock on Monday, I think will try to connect a pHAT DAC and Unicorn pHAT to a Mini Black HAT Hack3r (soldered as “Black Hat on Top”)

You said you “had some trouble getting pHAT DAC to play nice with Retropie.” Can you elaborate?


Be aware that using the pHAT DAC and Unicorn pHAT together is possible, but not straightforward. Because they both using pin 18, you’ll need to change the Unicorn pHAT to use pin 12, rather than 18. The Mini Black HAT Hack3r is the best way to do this and you’ll need to solder a wire between pin 18 on the Unicorn pHAT and pin 12 on the Mini Black HAT Hack3r. Then, you’ll need to reassign the data pin in the Unicorn HAT library to be pin 12.

I had problems with stuttering with the pHAT DAC and Retropie. I’m sure it solvable, but I’m exactly sure how, currently…

@sandyjmacdonald Thanks for clarifying. Since the DAC/Unicorn solution isn’t going to work well, I’ll go with the Pi Zero solution.

What’s the best way to get the Pi 3 (running Retropie) and the Pi Zero to work together? I don’t want to do anything too fancy, I just want the Pi Zero to shut down when I shut down the Pi 3. Using a Wifi dongle on the Pi Zero seems like overkill if they’re sitting next to each other. Could I connect them via USB?


You might be able to configure the Zero in ethernet gadget mode and then power and communicate with it over USB and SSH from the Pi 3, although the current draw from it and the Unicorn pHAT may be too much without an extra power supply for the Zero. You can certainly communicate over serial if you configure the Zero in serial gadget mode and, again, supplement the power.

If you’re going down then the Arduino route, then it should just come on when you power up the Pi 3, so that’s perhaps easier in that respect.