Unicorn Hat Auto config User Pins

I have a unicorn hat and a Raspberry Pi 3. In my project I want to use both the unicorn hat and a PIR sensor.
I also want my unicorn hat auto detected using the hat EEPROM.
If I plug it direct into the Raspberry Pi 3 it runs perfectly

I have worked (from https://pinout.xyz/pinout/unicorn_hat) out that to get the hat working and not autodetected I need to connect the following pins:
Pin 2 (5v Power)
Pin 9 (Ground)
Pin 12 (BCM 18) data

However in this mode the hat runs with only half the lights blinking.
I want it to autodetect so I don’t want to change the

I assume if I connect all the pins it will do what I need since it works when plugged in directly but I want to work out which pins are used.
I have tried connecting the following:
Pin 27 (BCM 0) ID_SD)
Pin 28 (BCM 1) ID_SC)

This didn’t work.

I added
Pin 1 (3v3 power)
in case the eeprom chip used this but same result.
In this case sometimes when I turn on the raspberry pi 3 random unicorn hat lights come up lit

I then realised there was a second 3v pin so I tried connecting:

Pin 17 (3v3 power)

Again no result (Although the unicorn hat lights haven’t started in the lit state so something may be different)

I realise the gnd pins are all connected to each other so no point trying them.

I have googled for a data sheet for the unicorn hat or some other kind of documentation which could help but no avail.

Can anyone tell me which pins are required, or am I down to trail and error and connecting them all and unconnected them one at a time until I work out which one.


It’s an educated (I looked at the board files) guess, but you might want to try physical pin 6, Ground. Due to just how dense Unicorn HAT is, I believe the other ground pin is routed directly to the pixels and just the pixels.

Since we use ground planes, a schematic wouldn’t have helped here, it requires careful study of the production files to trace where the ground connection ends up. We might consider adding this information to Pinout.xyz, but we favour keeping it clean and didn’t expect anyone would care much about the EEPROM.

In future the best way to suss out what to hook up is to use a diode check on a multimeter, and figure out where the VCC and GND pins of the EEPROM are connected. In cases like this, Ground is a likely culprit, and on a board as dense as the Unicorn HAT the ground plane is swiss-cheese.

Thanks for the response.
I retried with the following pins connected:
Pin 2 (5v Power)
Pin 6 (Ground)
Pin 9 (Ground)
Pin 12 (BCM 18) data
Pin 27 (BCM 0) ID_SD)
Pin 28 (BCM 1) ID_SC)

But this didn’t work. I didn’t think it would because if I run a continuity test between pins 6 and 9 I get a beep which I makes sense because they are both ground so presumably are already connected together.

Are there any other pins you suggest I try?

All of the pins along the bottom edge of the EEPROM - facing toward the breakout header - are grounded. If you can continuity test between them and the legs of each ground pin from the GPIO header, you should find the missing ground. With any luck that’s the problem, but I’m not 100% sure.

I tried tracing the ground plane visually to find out what might be up, but it hurt my brain/eyes. I can’t help but think I’m missing something simple and obvious :D

I have been doing some more unsuccessful tests.
I have a continuity tester on my multi-meter which beeps if there is a connection between two points.
I have confirmed as you mention that the four pins on the bottom of the chip labelled F006412 are connected to the GND pad at the edge of the Unicorn Hat.

I then tried every GND pin on the header but I did not get any continuity at all. I then expanded my search and confirmed that no pin at all is connected to the GND pad (and the 4 base pins of that chip.)

I thought I had found the problem so I then proceeded to place the unicorn hat directly into the raspberry pi 3 and repeated the test. Again there is no continuity between the GND pad on the board and any pin at all.
(Even though when plugged directly in to the raspberry pi it the EEPROM is read.)

I realised when looking at the hat at an angle I can see the traces so I took a photo. It seems traces run only around the area of pins 1-12 and pins 27 and 28. In frustration I connected all pins 1-12 and pins 27 and 28. Again it is not working.

This is proving to be a challenging puzzle!

I think I must have misjudged where the soft-start circuit is involved in Unicorn HAT.

To avoid an inrush of current to all the many, many capacitors on the board, and the resulting brownout of the Raspberry Pi, the Unicorn HAT has a transistor gate hooked up to a capacitor/resistor pair which charge and slowly open the board to current flow.

This transistor gate is opened by 5V power being applied to the board, and connects the board to the single ground pin; physical pin 9.

So, I clearly have been missing something obvious, because at a second glance it’s clear none of the other ground pins are physically connected to Unicorn HAT! D’oh. Sorry!

So the EEPROM is connected to 3v3 power (pin 1) but also needs 5v power to open its ground connection (pin 9)… whew!

Unfortunately that places us back to square one, because I think those are the pins you’ve been connecting?

One day we’ll be able to clean up and publish our schematics, which would help considerably with things like this!

I repeated all my tests last night and had the same result.
I have relented and decided to use the software code change rather than reading the EEPROM. (I need to get on with my next goal which is getting a PIR sensor and unicorn hat working at the same time from the same Pi.)
Thanks for your help with this, I would be interested if others manage to find out the combination of pins required.

Actually, there is one extra bit of information when I was doing my tests.
I was struggling to get my PIR sensor working. It is plugged in to physical pin 7 (BCM4)
When I used one software library I was getting weird results and I spent ages adjusting the sensitivity and timing on the PIR sensor which changed the result but still wasn’t working.

I then switched to using the GPIO library but my results were even stranger. My software was saying the pin was going on and off and on and off very fast.
I thought I had the wrong pin selected or something so I gave up as it was late.

I am at work now so not playing but doing some in work research. It seems the pin was correct but I noticed on this page https://pinout.xyz/pinout/gpclk that physical pin 7 is used for some kind of clock. This may be why I was getting the strange results whilst trying to read the PIR sensor.

Further the page also points to two extra pins being involved in the clock (Physical 29 and 31.) Neither of these were connected in any of my tests.

Could it be that the EEPROM reading requires these pins to be connected as well?

I guess I have more tests to run tonight, can you look at the schematic and see if this is pluasable?

My use case shows another point. I think for every HAT it is very important to have a complete list of all the pins that are used. (Rather than a minimum list of pins that if you connect will make it work) This way people wanting to do projects which combine hats and sensors can determine what will and won’t work together.


I don’t know if it’s related, but Physical Pin 7, AKA BCM 4, is the default pin used for the 1-Wire bus. If you have enabled 1-Wire on your Pi (in Raspberry Pi Configuration -> Interfaces) then it can cause all sorts of havoc with devices connected to that pin. It shouldn’t affect Unicorn HAT in any way, though.