Pan-tilt-zoom pi camera

I’ve just picked up one of these pan-tilt hats and should be easy enough to add to HASS using https://github.com/pimoroni/pantilt-hat
I will first add the pan-tilt hat and the aim is to control the motion via sliders from the HASS front-end.
The next stage of the project will be to add zoom and I have ordered a cheap zoom lens. This should be possible to zoom via a servo https://www.amazon.co.uk/gp/product/B00OFVGIF6/ref=od_aui_detailpages00?ie=UTF8&psc=1.
Cheers!

image
https://learn.pimoroni.com/tutorial/sandyj/assembling-pan-tilt-hat

2 Likes

OK got the pan-tilt + camera working in the HASS front end using an ipanel and this fork of a project discussed on this thread. Nice to be controlling a robot from HASS :grinning:
Picked up a dirt cheap camera on Amazon.

OK got pan-tilt control from HASS using the command line switch:

switch:
  platform: command_line
  switches:
    pan_tilt:
      command_on: 'python /home/pi/Desktop/basic_pan_tilt_RC.py -90 -20'
      command_off: 'python /home/pi/Desktop/basic_pan_tilt_RC.py 50 -20'

and the script basic_pan_tilt_RC.py:

import pantilthat
import sys
import time

pan_angle = int(sys.argv[1])
tilt_angle = int(sys.argv[2])

if __name__ == "__main__":
    pantilthat.tilt(tilt_angle)
    pantilthat.pan(pan_angle)
    time.sleep(0.5)

VIdeo on Youtube:

Will next create a custom component.
Ideas for automations include triggered sweep of an area and motion tracking.
Cheers

4 Likes

OK I got a custom component up for this now. Can home the stage and call a service to set the pan-tilt. Added sliders to interactively control the pan-tilt.
Still need to make sliders update value after a home.

Great work.
As I imagine it will only work locally? I mean if the pi with the hat and camera are the same running HASS.

I have mine on a second rpi by a window with mjpeg-streamer and running the pimoroni pantiltweb.
I still need a better solution to stream and even control the camera that does a poor job on auto.

HI @ferazambuja yes camera and pan-tilt should be on the same pi. I will roll this out as an official component at some point soon. Any feedback or feature requests welcome

I will load a hassbian image on the pi that I have the camera and give it a try :slight_smile:

Maybe the MQTT Statestream/Eventstream, I don’t know If it can control things.

1 Like

If you want to control the pan tilt from another HA you can use the HA rest API

I have to check that out :slight_smile:

1 Like