Unicorn pHAT output display "corrupt" and incorrect


I just bought a Unicorn hat for my brand new Pi Zero and am really excited, I’ve been meaning to play with the Pi for a long time!

I’m posting this because I can’t find a similar issue searching the forums. Everyone either has a Python syntax error or no output at all but I’m getting a sort of corrupted output on mine.

For example running simple.py from my examples folder should cause the LEDS on the hat to turn on and stay on but is instead causing the LEDS to flash at an irregular rate, sometimes just a few in the bottom right (looking at it with the usb out of the pi at the bottom) and sometimes all of them, though the top row never seems to go above half-brightness.

I’m an experienced solderer but I’m worried that I have somehow overheated and damaged my hat. I soldered the pins quickly with a high wattage iron, taking breaks between to let the board cool so I figure it must be one of the following:

  • The hat is faulty
  • I overheated something beyond repair
  • my soldering has a dodgy connection on one or more pins.

I’m hoping an experienced user of the hat can guess at the issue from my symptom description so I can work out whether all is lost or not!

I’ve just gone through with a multimeter and done a continuity check for each GPIO pin between the Pi and the hat with no issues found. There are no pins bridged accidentally by solder.

I’m really looking forward to playing around with this so I’m sort of hoping someone recognises this as a fixable software issue :/

Many thanks!


I am using a Raspberry Pi Zero running Raspbian OS.
The Python scripts are being run without syntax errors via SSH terminal.

It sounds like the usual problem of audio interfering with the timing on GPIO18… did you run the one-line installer like so:

curl -sS https://get.pimoroni.com/unicornhat | bash

and if so did you get the prompt at the end to route your audio to the HDMI port?
(it IS necessary to allow the script to do that for the Unicorn HAT/pHAT to work in recent Raspbian environments)

… yes, I’m pretty sure that is the issue, starting X is doing something that disrupts the unicorn HAT/pHAT on the latest Jessie, though I’m not sure we ever got to the nature of the actual problem. Force routing audio to the HDMI port should do the trick though.

I tried running that via terminal in raspbian on the pi and got an error saying something along the lines of “sorry, your operating system isn’t supported”

can you post the output of:

cat /etc/os-release

ah, I see, there is a bug in the installer (recently revised), it will be fixed in short order, however you can run the following and choose option 2 to the same effect:

curl -sS https://get.pimoroni.com/audio | bash

You will want to reboot the Pi before you try again.

After running your audio script with option 2, which the program told me successfully set the audio output to HDMI, and restarting the Pi, I am still getting the same issue :(

The output looks like this:
Enter an option [0-2]:2

Audio output mode changed!

Do you wish to test your system now? [y/N] y

speaker-test 1.0.28

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 256 to 16384
Period size range from 256 to 16384
Using max buffer size 16384
Periods = 4
was set period_size = 4096
was set buffer_size = 16384
0 - Front Left
Write error: -5,Input/output error
xrun_recovery failed: -5,Input/output error
Transfer failed: Input/output error

I don’t have anything plugged in to the HDMI which might be why it failed?

The requested output for my os-release:
pi@raspberrypi:~/unicorn-hat/examples cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs" pi@raspberrypi:~/unicorn-hat/examples

ah, yes, sorry, I thought the whole ‘magic glue’ occurred in the audio script but there is more to it:

echo "hdmi_force_hotplug=1" | sudo tee -a /boot/config.txt

… which essentially means that you will want to add:

hdmi_force_hotplug=1 to the /boot/config.txt file (you can do it manually if you prefer or run the command above)

Fantastic! It’s working great now!

Thanks so much for your help, it was greatly appreciated!


1 Like