(Another) Multiple HAT Question


#1

Hi, I have the wonderful STS-Pi which is being driven via an Explorer HAT Pro, I’d like to add an ultrasonic detector (HC-04), which I could probably wire directly to the breadboard on the Explorer HAT…

My question is, I’d like to also add the Pan/Tilt HAT - can this be done?

Cheers,

Andrew


#2

Yes, Pan/Tilt HAT uses just i2c, which is a 2-pin data bus it would happily share with Explorer HAT.

Be careful reading an HC-04 alongside these devices, though, since the overhead of both Python libraries could lead to unreliable timings and results from your distance sensor.

It’s more expensive, but I would personally use something like this: https://www.adafruit.com/product/164 since it’s much easier to work with.

That said people have got it working;

See: Unreliable HC-SR04 with Explorer HAT Pro


#3

Yes, we figured two ways to get it working:

  1. Use an analogue sensor such as a Sharp IR rather than HC-SR04 as timing is not an issue. Instead you measure voltage on an analogue pin and put through a simple equation to solve this. The post gadgetoid links to contains my code, and I wrote a blog post that covers this in some detail sans code as well: http://rasptut.co.uk/files/george-visits-digimakers-whiskers.php .

  2. Use RPi.GPIO with the HC-SR04, a link to code can be found also on the page Gadgetoid links to (see post by nevsie dated Jan 26).

Read the links and feel free to ping me a message if you need any help.


#4

Thank you both for your replies - sorry I’ve not been here sooner - I’ll look into these as soon as I can.

Just an observation - I don’t think this is mentioned at https://shop.pimoroni.com/products/pan-tilt-hat - maybe advise purchasers to get a 30cm ribbon cable for the camera as the 15cm one is a bit tight…

Cheers,

Andrew