Pan Tilt Hat Motion Eye OS action buttons

My head wants to implode but I figured it out by trial and " LOTS " of errors.

EDIT: This was all done via SSH from putty running on my Windows PC. I couldn’t copy any files to the SD card in a reader plugged into My other raspberry PI due to permission issues.

I SSH’d in and logged in as root then did the following from the terminal session.

First I create the up_1 file by creating the following bash script with:

nano /data/etc/up_1

In that file I put my command to run my python file

/usr/bin/python /data/etc/

Then make it executable with
chmod +x /data/etc/up_1

Then I create my up python file by running

nano /data/etc/

In that I put my up python code


import pantilthat


Then make it executable with
chmod +x /data/etc/

Log out of putty and reboot.

Wash rinse and repeat for each button you want.

There is sometimes a bit of a delay before something happens, or I may have to click the button a couple of times but it does eventually make the pan tilt move. At least its sort of working?

Great work! I’m going to give it a try. A bit of a slog, though.

I’m going to reimage my card and go though it all again, now that I think I have a working solution. Right now its iffy if it will work first time clicking a button. Some times I have to click a button multiple times to get a reaction from the Pan Tilt. Or there is a several second delay. Which might be because of all the trial and error getting it done. I found this last night that points to data/etc

Redid everything from scratch and same deal. The Buttons are there, but it takes multiple clicks to get the Pan Tilt to move? And I have no idea why?

I am also tempted to try button control one day so I am following your exploits with some interest and hope you manage to solve it for me too. As long as I don’t need a PHD in wizardry ;-)
I noticed that my Pi-Zero motioneye webcams have a good 2-second delay between a moving object in vision and the display in a web page (there is a radio-controlled wall clock I can see clearly and it is 2-seconds ‘slow’ on my web page view).
Is that delay complicating things for your experiments?
For interest, what credentials do you use to SSL into motion Pi?

I’m not sure what is going on? I’m running Motion Eye on a Pi 3A+ which should be more than capable.

What I’m seeing now, is when I click a button, the pan tilt moves, but doesn’t move all the way to where I want it to go? How is that possible? If I keep clicking the button it will stutter over and eventually stop at the correct position?
I didn’t have this issue when testing it in Raspbian. It did the one quick move to the desired position I had in my python code. I used this code

from picamera import PiCamera
from time import sleep
import pantilthat


camera = PiCamera()
camera.rotation = 180
camera.resolution = (1280, 720)


I just kept changing the Pan(0) and Tilt(0) values and rerunning the file. It moves to where to set it and gives a 10 second preview of what its looking at. When I found the position I wanted I just wrote down the values. Quick fluid moves. Same power supply used for both Raspbian and Motion Eye?

EDIT: Fixed it I edited each of my py files and added
from time import sleep at the top, and sleep(10) as the last line.
Now it’s just one click and it goes where I told it too. =)

Sorry I’m a bit late here, but there is a google group for MotioneyeOS. I used it last year when I was setting up Motion Eye. If you use it and login, then you will get loads of other emails from that group about anything at all.

I do like Motion Eye, I have yet to find anything else as good. And its easy to use once setup. The setup is a bit of a pain though, IMHO. I’m using Pi 3A+'s which don’t have an Ethernet Port. I plug a USB hub in that has an Ethernet port in for the first boot up. Turn on the WIFI and use that on the next reboot. I also use static IP’s to make finding them easier. for camera 1, camera 2 etc. Then I just create IE shortcuts to each camera on my taskbar.

Great job you have done alphanumeric.
I have been reading this thread and trying to understand what´s in front of me trying to get pantilt functions implemented. I have a need only to include up/down left/right buttons. But before getting it running, it would be great if you could post a picture of the web-GUI so I know whats expected on the screen


What happens in the Web GUI is the action buttons just appear in the lower right hand corner. There is no menu item to turn them on or off. As you add the up_1, right_1, etc files the buttons appear on the screen. Then you just click them to have what you programmed into the up_1 etc file happen. Here is a screen clip I just did, suns not up yet so you won’t see what the cameras looking at but the buttons are there.

Ok, understood,Thank you very much

Hopefully, in future releases of Motion Eye, this gets easier. Doing it all remotely via s SSH was a bit of a pain for me.

I totally agree but anyhow I followed your rundown procedure and got my four arrow-buttons. But sofar no servos moving. That will be my exercise tomorrow. Attached my screengrab.

No action clicking any arrow-button. Only get Error message “An error occured. Refreshing is recommended”. I have no idea how to continue ?

I got the same error message during my trials and tribulations. For me it happened when I tried to put my python code in the up_1 file. I changed tactics and created an file. Then ran that from the up_1 file. My up_1 file looks like this.

/usr/bin/python /data/etc/

And my file is this


from time import sleep
import pantilthat


I also did a chmod +x /data/etc/up_1 and chmod +x /data/etc/ to make both files executable. I “think” you only need to do it to the _1 files but I did both and my buttons are working.

Thanks to alphanumeric, I now have my up-down left-right buttons working according to your latest advice. Nice… Next I need to think how to use the PRESETS 1 to 9.

I find it very satisfying when you finally sort something like this out, and get it working “the way you want it to work”. Sometimes its a struggle, sometimes its a lucky guess, either way when its done its fun. =)

I finally got some sense of how to define preset-buttons . Attached screengrab of up-down left-right and preset 1 2 3

My up left and right buttons are basically presets. Pressing one of them moves my pan tilt to a specific position. Up has it look straight out and slightly down at my driveway. Right has it pan to the right to look at my front yard. etc. I could have used 1,2,3 but the arrows work better for me.
I didn’t bother doing the pan left right up down incrementally with a button press. It’s not something I need with what I’m doing. And that appears to be the really tricky bit.

Yes I agree, I am slightly confused about how to get up-down-left-right stepping the servos incrementally. I thought basically that was the meaning. As far as I understand pantilthat.pan(x) and pantilthat.tilt(y) x and y are degrees from center positions. So actually up-down-left-right .py files are more or less presets. So needs more studies indeed… Anyhow quite interesting exercise