I cannot get the Pan-Tilt Hat to work

I have assembled the Pimoroni Pan-Tilt Hat (holding an Official v2 Camera) onto a Pi3. I am using the Official Pi3 PSU.

The camera works perfectly but I cannot get the Pan-Tilt to move at all, in either direction.

As far as I am aware, I have loaded all the software required but I must admit to being a little bit lost in terms of which software I should start off with. I have enabled i2C.

Is there a simple test I can try on each of the Servo’s just to make sure they are operating correctly on their own.

All the items were bought brand new, a week or so ago.

If you downloaded the examples you should just be able to run ‘smooth.py’ by typing the following at the terminal:

python smooth.py

The other alternative is to load up a terminal and type python to entire the Python development environment. Then type:

from pantilthat import * pan(50) tilt(50)

Hopefully that should get it moving.

Any issues give me a shout.

@major_tomm
Thank you for your reply. Sorry, I should have explained better.
I am a beginner with Python(3) but I have written quite a few programs previously, before I got the Pan Tilt Hat.
I have run the example program, ‘smooth.py’ but the Servo’s do not move at all. However, the program produces a continuous downward stream of numbers, such as:
-87
-88
-89
-89
-89
-88
-88
-87
-87
-86
-85
etc

so to me, the software is running without a problem, hence my question as to whether the servo’s could be tested separately.

I don’t think there’s a way to wire the servos up without the HAT in between. Might be worth checking you’ve got the servo’s hooked up correctly (with the metal contacts on the leads pointing away from the board) and that the HAT is sitting correctly on the Pi?

@major_tomm
That was the problem!
I had connected the servos’s with the metal contacts pointing towards the board. I cannot understand why because I was conscious of that possibility. I was first of all surprised that the connectors would fit both ways and then I thought I had seen a picture showing the plain side, away from the board.
Anyway, it is working now and thankfully not damaged due to having been connected incorrectly.
Thanks again,

1 Like

Glad it’s all working! I was playing with mine yesterday, got it to scan the room until it discovered a face and then ‘lock-on’ to that face until it left.

Yes, it is an impressive piece of kit. I have been playing with the effects that the camera can produce, for example:
In Terminal mode.
raspistill -ifx sketch -o image.jpg

I can now start to get the Pan Tilt side of it operating in my own Python Programs.

@major_tomm
I meant to ask before.
Is your Face recognition software, a Python program?

It is indeed. Based off of the pimoroni example, except I’ve added in the ‘roaming’ feature. Don’t currently have great internet access but will upload it when I get a chance.

@major_tomm
That would be interesting, thanks.

I’m not sure if this is the right place to detail my problems, but it seems like a good place to start.

Connected up my pan-tilt system fine.
Used Pimoroni Dashboard to install the pan-tilt library etc. See below:

Checking environment…

Checking hardware requirements…

I2C already enabled

Checking packages required by I2C interface…
…Python 2 smbus installed and up-to-date
…Python 3 smbus installed and up-to-date

Pan-Tilt HAT comes with examples and documentation that you may wish to install.
Performing a full install will ensure those resources are installed,
along with all required dependencies. It may however take a while!

Checking for dependencies…

Installing python-pantilthat…
…install ok installed
…Installing python3-pantilthat…
install ok installed

Checking for additional software…
python-picamera is already installed
python3-picamera is already installed

Downloading examples and documentation…

The examples directory already exists on your system!
We’ve backed them up as examples-backup, just in case you’ve changed anything!

Resources for your Pan-Tilt HAT were copied to
/home/pi/Pimoroni/pantilthat

All done. Enjoy your Pan-Tilt HAT!

Press Enter to continue…

I loaded smooth.py into Thonny to run from there.

These is the error

Traceback (most recent call last):
File “/home/pi/Pimoroni/pantilthat/examples/smooth.py”, line 6, in
import pantilthat
File “/usr/lib/python3/dist-packages/pantilthat/init.py”, line 15, in
pantilthat = PanTilt(i2c_bus=SMBus(1))
File “/usr/lib/python3/dist-packages/pantilthat/pantilt.py”, line 63, in init
self._set_config()
File “/usr/lib/python3/dist-packages/pantilthat/pantilt.py”, line 100, in _set_config
self._i2c_write_byte(self.REG_CONFIG, config)
File “/usr/lib/python3/dist-packages/pantilthat/pantilt.py”, line 191, in _i2c_write_byte
raise IOError(“Failed to write byte”)
OSError: Failed to write byte

Any ideas?

Note that I’ve been able to get Adafruit BME280 I2C Temperature Humidity Pressure Sensor to function either.

Is it possible there’s a problem with the I2C interface on my RPi 3?

Although I haven’t done loads of stuff with the RPi so far, everything else (not I2C related) seems to work.

Hope you can help…

It sounds like I2C isn’t enabled. Try enabling it in the Raspberry Pi configuration menu, then rebooting.

Thanks for the input Sandy.
I2C is definitely enabled.

i2cdetect -y run from terminal doesn’t show anything up on I2c. Same with the temperature probe.

It works perfectly on a Pi zero-w so suspect I2c on the Raspberry Pi 3 model B V1.2 running Raspbian GNU/Linux 9 (stretch) has been damaged somehow.