Use GPIO Pins With HAT Attached

Hi there, Just wondering if anyone has any ideas on how I can attach an ultrasonic sensor to my Pi using the GPIO pins? I have purchased this sensor (Weatherproof Ultrasonic Sensor with Separate Probe | DFRobot SEN0208 | Core Electronics Australia) however my Pi already has a TV tuner HAT (Raspberry Pi TV HAT | Core Electronics Australia) attached to the header connector. So there is no way for me to connect the ultrasonic sensor to the GPIO pins. Is it as simple as me purchasing one of these larger header connectors (Raspberry Pi Extra-Long Stacking Header (2x20 pins) | Core Electronics Australia) and connecting to the GPIO pins that would then be protruding out the top of the hat? also avoiding pin clashes. Thanks


Hi Thomas, welcome to the forum!

Since your HAT has a header with holes all the way through, generally it is that simple :slight_smile:
As for pin clashes, the fantastic site can help, as it lists which pins each HAT uses.

Since this sensor has a simple pulse train output, any pin should be fine I believe, but if you switch it into UART mode (info in the wiki) then you’ll be restricted to one of the many UART interfaces.

if you have any followup questions, let me know :slight_smile:

P.S. I know this doesn’t help, but when ordering stuff online I like to plan out all the connections and pin modes and stuff like that in advance with a diagram - there are some surprising gotchas when you’re cramming so much stuff into a 2x20 header!

1 Like

Thanks very much James, I plan to use the ultrasonic sensor in the default mode 0, but thanks for the info. Cheers