#HELP# building an Pan-Tilt Webinterface for Pimoroni Pan-Tilt HAT FULL KIT with Webcam Server


Ok, thanks for the info. Actually I’m busy doing exactly this right now. But if you’d have had a version w/o neopixel support I might have used that one. Thanks a lot anyway.


Hi Dave
I do have another question though: For HTTP_PORT and WS_PORT could I use any other unassigned port numbers than 8082 and 8084 respectively or is there a requirement to use exactly these?
Thanks, Fritz


No requirement other than the usual UNIX limitation that ports <1024 require root privileges to open. Other than that, use whatever you like.


Great. Thanks a lot.


Hi there. Thanks for the great info on this thread. Special thanks to @waveform for your work. I’ve managed to get it all up and running and it works perfectly on my local network. I’ve done the port forwarding stuff on my router but when I view it from an external computer I get the main page but not the video. It doesn’t get past the ‘loading…’ message. Any ideas?


Hi Chris, you’ll need to forward both ports (HTTP and WS, i.e. 8082 and 8084 by default), and tweak the index.html so that the websocket address is external (it’s your internal IP by default). There’s a bit more info in this ticket on the pistreaming github which should point you at the right bit to modify.

Good luck!


Result! Thanks Dave.


I would like to integrate the pan-tilt hat + camera into home-assistant running on another pi.
I can add the video stream as a generic IP camera but to control the pan-tilt I could use a shell command or preferably MQTT. Before I reinvent the wheel I wonder if anyone has implemented this or similar?


Quick update, am able to add the pan-tilt interface to the home-assistant front end as an ipanel. Works well from my wall tablet but would still be nice to add MQTT control


Got basic control of the pan-tilt from Home-assistant, discussed on https://community.home-assistant.io/t/pan-tilt-zoom-pi-camera/24202/3


Hi, tried this twice now and the camera works fine but don’t get the ‘Initializing HAT’ message when I run it and, sure enough, there are no pan or tilt controls. Help.


All sorted. For some reason, the git clone didn’t work and the server.py file was different/corrupted from the original.

For anyone one else running this on Raspbian Stretch, you have to enable I2C through raspi-config as well.


Whenever I try to run server.py I get an error that it can’t find the pantilthat. I have installed the software that’s required so, what am i doing wrong?

pi@raspberrypi:~/pistreaming $ python3 server.py
Traceback (most recent call last):
  File "server.py", line 17, in <module>
    import pantilthat as hat
ImportError: No module named 'pantilthat'


Had to install the python3 library using

pip3 install pantilthat

and that got that error fixed. however, now I’m running into this:

Traceback (most recent call last):
  File "server.py", line 259, in <module>
  File "server.py", line 199, in main
    hat.servo_enable(1, False)
  File "/usr/local/lib/python3.5/dist-packages/pantilthat/pantilt.py", line 394, in servo_enable
  File "/usr/local/lib/python3.5/dist-packages/pantilthat/pantilt.py", line 79, in setup
  File "/usr/local/lib/python3.5/dist-packages/pantilthat/pantilt.py", line 117, in _set_config
    self._i2c_write_byte(self.REG_CONFIG, config)
  File "/usr/local/lib/python3.5/dist-packages/pantilthat/pantilt.py", line 208, in _i2c_write_byte
    raise IOError("Failed to write byte")
OSError: Failed to write byte

Yes, I have I2C enabled.


This is a new one- I wonder if you’re running a server with something like Reloader that’s causing multiple instances of the script to run simultaneously and clash horribly with each other.

If you isolate the setup script for Pan Tilt HAT into its own script without any web front-end, does it work?


Yeah, on a fresh install of raspbian it works fine. Must be some latent program I was running before on that RPi.


This is wonderful! Thanks! I am trying to access port forwarding via the Dataplicity remote access service. How would I configure the streaming and control functions to work with this platform?


Hi FolkZ,
does anyone have a working code for the NeoPixel Stick - RGBW.
I would like to use it in the web interface with the Pantilt Hat from Pimoroni.
The code of Waveform80 in the Pistreaming web interface is not working properly; the control for white does not work at all and it also only illuminates 6 LEDs in the control for ‘ALL’.

GrEeTz from Germany


Followed the 5 steps above (Over ssh) but I get the following error

Initializing HAT
Traceback (most recent call last):
File “server.py”, line 259, in
File “server.py”, line 199, in main
hat.servo_enable(1, False)
File “/usr/lib/python3/dist-packages/pantilthat/pantilt.py”, line 395, in servo_enable
File “/usr/lib/python3/dist-packages/pantilthat/pantilt.py”, line 72, in setup
self._i2c = SMBus(1)
FileNotFoundError: [Errno 2] No such file or directory

Any ideas?


Hi! This may be of interest to no-one at all! I have a gui written in Go that controls the pantilt head, If the use of Go itself is not of interest, the interpretation of the i2c controls via the periph package might be of help?