--Bird--
Posts: 2
Joined: Sun Apr 12, 2020 1:21 pm

understanding hats and the GPIO interface / learning the jargon

Sun Apr 12, 2020 2:04 pm

I'm going to buy a Raspberry Pi 4 B and a Zero W. I'm not so dexterous, so I'm getting the Zero with the header already added.

I'm a little confused by the different ways hats and accessories connect to the Pi. I've done a lot of googling, but there is a 'chicken & egg' problem of not knowing the right words/jargon to google! :oops: (I'm experienced in software, but a noob with regard to electronics.)

Observations/questions...

1. The GPIO "pins" (the "header"?) protrude upwards from the Pi board;
2. Some hats have the corresponding part that I'd expect on the underside - don't know the name for this? - a female plastic part, where each GPIO pin goes into a corresponding hole. E.g. https://www.aliexpress.com/item/32961967517.html This makes sense!
3. Some hats have both the female plastic part on the underside and pins (pointing upwards). E.g. https://www.amazon.de/gp/product/B07T35X4P4/ What are the pins for on top? Because I read in several places that you can't generally 'stack' hats. :?
4. Some accessories (like cameras) seem to come with a ribbon cable, but seemingly no 'plastic thingy' at the Pi end to interface with the GPIO header. E.g. https://www.raspberrypi.org/products/pi-noir-camera-v2/ Do you need to buy your own 'thingy' to connect the ribbon to the Pi? From looking at lots of these things on Amazon, often the 'thingy' is depicted in illustrations of the fully assembled Pi+hat, but not indicated in the parts list for the hat.

If I'm misusing some of the terms ('header' etc) please correct me!
Sorry for the web links on my first post, hope that's not against forum policy.

drgeoff
Posts: 10676
Joined: Wed Jan 25, 2012 6:39 pm

Re: understanding hats and the GPIO interface / learning the jargon

Sun Apr 12, 2020 6:12 pm

The flat flex cable on the RPi camera and the RPI screen are inserted into the respective dedicated sockets for them on the RPi board. The Zeros (all versions) do not have the display socket. The Zeros have a smaller camera socket than other RPis and require a different cable.

alphanumeric
Posts: 2528
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: understanding hats and the GPIO interface / learning the jargon

Sun Apr 12, 2020 6:27 pm

The official spec for Hats states something along the lines of "there can be only one". That is true if they follow the official spec and use an ID eprom. Plug two hats with ID eproms in and the Pi can't read them and doesn't know how to configure them.
That being said, you can still stack them and set them up manually in your code. Which you will have to do anyway if they don't have an id eprom. When stacking hats you have to make sure there are no pin conflicts. If two devices try to use the same resource you will have issues. There are some shared buses like i2c though. I go here to see what pins a hat uses.
https://pinout.xyz/#
There are a lot of non standard Hats and pHats and Mini Hats etc out there. Plus you can connect devices to the GPIO pins that aren't a Hat. Like breakout boards using jumper wires.

alphanumeric
Posts: 2528
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: understanding hats and the GPIO interface / learning the jargon

Sun Apr 12, 2020 6:30 pm

The official Pi Camera and NOIR Camera come with the required cable to connect them to the CSI connector on the Pi. Same deal with the Official Pi touchscreen. It comes with the required cable to connect it to the DSI connector. Plus there are tons of aftermarket cables of various lengths out there if you need or want a longer of shorter one. As mentioned above the Zero has a smaller CSI connector and no DSI connector. The cable for it came with the Official Pi zero cases I have bought. Plus its available as a separate item on a lot of Pi related retail shops.

deepo
Posts: 574
Joined: Sun Dec 30, 2018 8:36 pm
Location: Denmark

Re: understanding hats and the GPIO interface / learning the jargon

Sun Apr 12, 2020 6:35 pm

You got it!
A header exposes an electrical interface to the world.
The 40 pin Raspberry Pi header has a number of pins that exposes the interfaces that the RPi has.
Some hats have both the male and female parts, allowing a different hat can be stacked on top of the hat. This is because some hats only use some of the pins, while other hats use other pins. So they could co-exist on the same RPi.
But you are correct, generally you can't stack hats, but in some cases it works.
Sorry, I can't help with the ribbon cable headers.

/Mogens

alphanumeric
Posts: 2528
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: understanding hats and the GPIO interface / learning the jargon

Sun Apr 12, 2020 6:39 pm

I quite often use Proto Hats to get access to the GPIO pins to make adding breakout boards easier. Stuff like this.
https://www.adafruit.com/product/2310 There is a no eprom and with eprom version.
If i want to stack a hat on top of it i use a stacking header with it. Female on the bottom male on top. Pi > Proto > Hat.

hippy
Posts: 7459
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: understanding hats and the GPIO interface / learning the jargon

Sun Apr 12, 2020 8:05 pm

HATs can be thought of as add-ons which have an ID Eeprom fitted. Having that ID Eeprom precludes two or more HATs being stacked.

Any number of add-ons without ID Eeprom may be stacked on a Pi, even with a HAT fitted, providing there is no electrical conflict with any GPIO pins other add-ons or a HAT uses.

It gets a bit muddied because some manufacturers, retailers and users call their add-ons HATs when they aren't - If it has not got an ID Eeprom it isn't a HAT.

Proto-HATs live in the Twilight Zone; they are usually add-ons with the capability of having an ID Eeprom fitted. Without an ID Eeprom they are not HATs. With an ID Eeprom they are.

The official PoE HAT can also be stacked with another HAT because that uses a different ID mechanism. I think. Even if not the RPF invented the rules and can choose to redefine them, can call something a HAT even if it wouldn't be other than by that naming.

--Bird--
Posts: 2
Joined: Sun Apr 12, 2020 1:21 pm

Re: understanding hats and the GPIO interface / learning the jargon

Sun Apr 12, 2020 11:59 pm

Very detailed and enlightening replies. :) Thank you all very much for your time!

User avatar
Burngate
Posts: 6290
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: understanding hats and the GPIO interface / learning the jargon

Mon Apr 13, 2020 10:30 am

hippy wrote:
Sun Apr 12, 2020 8:05 pm
The official PoE HAT can also be stacked with another HAT because that uses a different ID mechanism. I think.
All HATs use the I2C bus that comes out on header pins 27 & 28. One address on that bus is queried at boot-up, to identify the HAT, and if more than one was connected, they'd all try to answer at the same time, creating garbage.

The PoE HAT uses a different address on that bus, so they can co-exist.

That's what I think.

Return to “Beginners”