ZPMMaker
Posts: 109
Joined: Sun Aug 23, 2015 11:04 am
Location: Australia

Pressing a button to turn on a camera using RPi3 and motors

Fri Dec 15, 2017 5:59 am

Hello,

I'm building a remote camera network and need a way to turn the camera on robotically, i.e. I need something that will - when my software detects that the camera is turned off - push the power button on the camera, and then retract.

I am completely new to robotics, and certainly don't know my way around the GPIO pins, but I have figured out I probably need a linear actuator, preferably stepped (so that I can tell how far it has moved).

Is my thinking correct so far?

If so, can anyone please recommend specific hardware for achieving this?

The camera is a Ricoh Theta V... it is controllable by an RPi using its USB API, but it does not automatically switch on when it is plugged in via USB.

The button on the camera is about 4mm in diameter, and probably only needs to be pushed in about 1/2mm. It then needs to stay there (pushing down the button) for a specific period of time (e.g. 1-2 seconds, I'll have to experiment to know the precise duration needed), and then it needs to retract so that it isn't pushing down the button.

As the camera will be set up in a remote location (literally the other side of the planet), I'd prefer to use parts with a long service life. That said, I imagine I will only need to turn the camera on perhaps a dozen times per year, total.

...or am I barking up the wrong tree and is there a far easier way to turn the camera on (without human intervention)?

Thanks in advance. :)
Dave

Davies
Posts: 150
Joined: Sat Apr 04, 2015 4:24 pm

Re: Pressing a button to turn on a camera using RPi3 and motors

Sun Dec 17, 2017 1:15 pm

im surprised you cant turn the camera on through software, but a quick google didnt come back with anything..
maybe you could use a car door lock actuator to press the button? they are 12v but possibly better than rigging up a motor?
https://www.ebay.co.uk/itm/Universal-He ... .l4275.c10
that would be controlled by a relay
https://www.ebay.co.uk/itm/2-Channel-3- ... SwCU1Y31ZG
then if you had a good 12v power supply
https://www.ebay.co.uk/itm/Power-Supply ... LWZcdr7axA
you could also power the raspberry with a 12v-5v converter, allowing you to use just the one power cable
https://www.ebay.co.uk/itm/Doppel-12V-A ... SwXY5ZSdru

in python i would use something like this to gain the recorded name of the camera(ensure the camera is on and connected)(i think running "lsusb" from terminal may return the same info)

Code: Select all

import re
import subprocess
device_re = re.compile("Bus\s+(?P<bus>\d+)\s+Device\s+(?P<device>\d+).+ID\s(?P<id>\w+:\w+)\s(?P<tag>.+)$", re.I)
df = subprocess.check_output("lsusb")
devices = []
for i in df.split('\n'):
    if i:
        info = device_re.match(i)
        if info:
            dinfo = info.groupdict()
            dinfo['device'] = '/dev/bus/usb/%s/%s' % (dinfo.pop('bus'), dinfo.pop('device'))
            devices.append(dinfo)
print devices
to show the currently connected devices, once you know the name of the device from the list given you could then use something like..

Code: Select all

import re
import subprocess
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.OUT, initial=0)
device_re = re.compile("Bus\s+(?P<bus>\d+)\s+Device\s+(?P<device>\d+).+ID\s(?P<id>\w+:\w+)\s(?P<tag>.+)$", re.I)
df = subprocess.check_output("lsusb")
devices = []
for i in df.split('\n'):
    if i:
        info = device_re.match(i)
        if info:
            dinfo = info.groupdict()
            dinfo['device'] = '/dev/bus/usb/%s/%s' % (dinfo.pop('bus'), dinfo.pop('device'))
            devices.append(dinfo)
        if "Insert Camera_Name_Here" in devices:  # or maybe, if "Insert Camera_Name_Here" in dinfo['device']
	    print "connected"
        if not "Insert Camera_Name_Here" in devices:  # or maybe, if not "Insert Camera_Name_Here" in dinfo['device']
	    GPIO.output(21, 1)
	    time.sleep(2)
	    GPIO.output(21, 0)
which would turn on the relay module and send out the door lock actuator, which would need to be mounted in a manner which it would press on the power button, this should turn the camera on when it wasnt already registered in the usb list (lsusb)
the last code is untested, if you have any issues with it please post back
if the door actuator holds the power button down after the relay has released you may also need to utilise the second relay to engage reverse on the actuator, but i would stay away from this if possible as then the switch on time would also include any time the actuator is moving back and forth for.

if your new to programming and decide to use python it may be worth downloading JetBrains Pycharm as that program has helped me massively with learning python as it points out most basic errors, grammar, spacing, poorly utilised variables etc are all highlighted.. but youll need to youtube pycharm setup or pycharm interpreter setup to get everything working with the version of python you would use etc.

ZPMMaker
Posts: 109
Joined: Sun Aug 23, 2015 11:04 am
Location: Australia

Re: Pressing a button to turn on a camera using RPi3 and motors

Mon Dec 18, 2017 9:09 am

Davies wrote:
Sun Dec 17, 2017 1:15 pm
im surprised you cant turn the camera on through software, but a quick google didnt come back with anything..
maybe you could use a car door lock actuator to press the button? they are 12v but possibly better than rigging up a motor?
https://www.ebay.co.uk/itm/Universal-He ... .l4275.c10
that would be controlled by a relay
https://www.ebay.co.uk/itm/2-Channel-3- ... SwCU1Y31ZG
then if you had a good 12v power supply
https://www.ebay.co.uk/itm/Power-Supply ... LWZcdr7axA
you could also power the raspberry with a 12v-5v converter, allowing you to use just the one power cable
https://www.ebay.co.uk/itm/Doppel-12V-A ... SwXY5ZSdru

in python i would use something like this to gain the recorded name of the camera(ensure the camera is on and connected)(i think running "lsusb" from terminal may return the same info)

Code: Select all

import re
import subprocess
device_re = re.compile("Bus\s+(?P<bus>\d+)\s+Device\s+(?P<device>\d+).+ID\s(?P<id>\w+:\w+)\s(?P<tag>.+)$", re.I)
df = subprocess.check_output("lsusb")
devices = []
for i in df.split('\n'):
    if i:
        info = device_re.match(i)
        if info:
            dinfo = info.groupdict()
            dinfo['device'] = '/dev/bus/usb/%s/%s' % (dinfo.pop('bus'), dinfo.pop('device'))
            devices.append(dinfo)
print devices
to show the currently connected devices, once you know the name of the device from the list given you could then use something like..

Code: Select all

import re
import subprocess
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.OUT, initial=0)
device_re = re.compile("Bus\s+(?P<bus>\d+)\s+Device\s+(?P<device>\d+).+ID\s(?P<id>\w+:\w+)\s(?P<tag>.+)$", re.I)
df = subprocess.check_output("lsusb")
devices = []
for i in df.split('\n'):
    if i:
        info = device_re.match(i)
        if info:
            dinfo = info.groupdict()
            dinfo['device'] = '/dev/bus/usb/%s/%s' % (dinfo.pop('bus'), dinfo.pop('device'))
            devices.append(dinfo)
        if "Insert Camera_Name_Here" in devices:  # or maybe, if "Insert Camera_Name_Here" in dinfo['device']
	    print "connected"
        if not "Insert Camera_Name_Here" in devices:  # or maybe, if not "Insert Camera_Name_Here" in dinfo['device']
	    GPIO.output(21, 1)
	    time.sleep(2)
	    GPIO.output(21, 0)
which would turn on the relay module and send out the door lock actuator, which would need to be mounted in a manner which it would press on the power button, this should turn the camera on when it wasnt already registered in the usb list (lsusb)
the last code is untested, if you have any issues with it please post back
if the door actuator holds the power button down after the relay has released you may also need to utilise the second relay to engage reverse on the actuator, but i would stay away from this if possible as then the switch on time would also include any time the actuator is moving back and forth for.

if your new to programming and decide to use python it may be worth downloading JetBrains Pycharm as that program has helped me massively with learning python as it points out most basic errors, grammar, spacing, poorly utilised variables etc are all highlighted.. but youll need to youtube pycharm setup or pycharm interpreter setup to get everything working with the version of python you would use etc.
Hello; thanks very much for that detailed suggestion! That's very helpful! :)
As it turns out, I am already running my RPi off a 12V source (well, actually, it's a battery that has both a 12V plug and a 5V USB port), so this should work out perfectly.

Many thanks!

Davies
Posts: 150
Joined: Sat Apr 04, 2015 4:24 pm

Re: Pressing a button to turn on a camera using RPi3 and motors

Mon Dec 18, 2017 12:02 pm

no problem, hope it works for you.
a couple points i didnt make, the code was written in python 2.7.13, if you set the pycharm interpreter to 3.5 it will highlight errors.. it may be worth sticking with the same version if you are using the code i posted.
also its set up for bcm gpio, not board.. so itll use its internal numbering bcm21 is pin40
https://www.raspberrypi-spy.co.uk/wp-co ... 00x900.png

ZPMMaker
Posts: 109
Joined: Sun Aug 23, 2015 11:04 am
Location: Australia

Re: Pressing a button to turn on a camera using RPi3 and motors

Tue Dec 19, 2017 1:34 pm

Davies wrote:
Mon Dec 18, 2017 12:02 pm
no problem, hope it works for you.
a couple points i didnt make, the code was written in python 2.7.13, if you set the pycharm interpreter to 3.5 it will highlight errors.. it may be worth sticking with the same version if you are using the code i posted.
also its set up for bcm gpio, not board.. so itll use its internal numbering bcm21 is pin40
https://www.raspberrypi-spy.co.uk/wp-co ... 00x900.png
Ah, fantastic. Thanks for clarifying that one - very much appreciated! :)

Return to “Automation, sensing and robotics”