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.