Raspberry Pi - Sound Trigger

Messages
1,090
Name
Euge
Edit My Images
Yes
Hi,

Not sure where to post this so thought here would be the best start... Has anyone else on here been playing about with the RPi to trigger their camera / flash? I have setup a pretty cheap water droplets kit based on this guys website:

http://www.davidhunt.ie/?p=2770

It works great.. however I really want to capture images of things smashing up, so thinking that i need either or a Sound or Light sensor trigger... There are some you can buy from ebay that I could adapt to work with the RPi but where is the fun in that... Bearing in mind my electronics background is 'I know there are 2 ends on a battery' I am after some electronic guidance as i dont know where to start!

What I want to do is when a sound is heard or a light beam broken do the equivalent of a person pressing a switch... I can then use the RPi to listen for that input and programatically (is that a word?) trigger my flash / camera to take a photo.

Cheers
Euge

P.S if you are stuck with the water drops thing I can attempt to help as it was a steep learning curve
 
If there is any guidance you can share for the water drop trigger that would be great. I'd like to build one but the instructions on the link are very high level indeed. Eg what exactly did you buy and do you have any more detailed instructions as to how to put it all together?

Thanks
Mike
 
Why not just use sound to directly trigger the camera? I don't see the advantage of having a processor controlling it.


Steve,
 
Mike - I will put together a shopping list if you like and circuit diagram in non electronics terms... might take me a couple of days as a few other things to get done first :)

Steve - I have a sound trigger for the camera already but the missing component is a delay... I only want a 0.5 second delay to get a slightly different point of destruction which I was experimenting with moving the sensor further from the sound source, but that proved tricky as there is a limit to the distance it will detect the sound from. I have now actually bodged the sound sensor to link into the RPi but now want a more 'sensitive' sensor. Think my new hobby is electronics as not touched a camera for a few days LOL

Cheers
Euge
 
Steve - I have a sound trigger for the camera already but the missing component is a delay.

In that case, the RPi would be fine. as would a PIC. I would personally do it with a simple variable delay circuit controlled using a capacitor and variable resistor, but however you do it, it adds an extra dimension of control and sounds like an interesting project.

EDIT: Like these -

http://www.doc-diy.net/photo/sound_trigger/
http://www.the-f-stop.com/flash-trigger/


Steve.
 
Last edited:
Sorry for the delay... anyway, here is a Getting started guide to go along with this website http://www.davidhunt.ie/?p=2770 for water drops.. This is aimed at people like me who know nothing about Electrics. I havent gone into details on how to install the software side of things as sure there are plenty of sites for that already.

1) My Shopping List

Note: This is a list of the things I purchased to get my project running, i am sure you can get the same things cheaper elsewhere or even in a single shop...
2) Stuff I already had
  • Soldering Iron (dont know how to use it but i own one :))
  • 12v Power Supply

3) Step 1
  • Get the software installed on your Raspberry PI, you need to install WiringPI2, there are plenty of sites talking through this
  • Transpose the code from David Hunts site into a file with a .py extension
  • make the file executable (sudo chmod +x FILENAME)
  • Run the program from a command line
    • sudo python FILENAME.py
  • If you have errors then Python is pretty good and pointing you in the right direction... just read the error message carefully and remember its CASE SENSITIVE!!!
  • Get the Shutter Release working, its the simplest of circuit
4) Shutter Release
  • Cut the Shutter Release that I purchased so that i had the connector for the camera a length of cable and 3 open wires.
    • Red = Shutter
    • Yellow = Auto Focus
    • White = Ground
  • The Pin outs may vary depending on brand but thats what I found on the web for mine (canon 5d3) and it worked
  • Connect the GPIO Breakout board to the PI and create the circuit (if you dont know what the components are look in the booklet that comes with the Electrical starter kit...)
View attachment 5485

  • The above diagram does differ slightly from the example by David Hunt as I have modified my setup to fire a flash and a camera... more on that later.
  • You should now be able to connect the Camera to your shutter release cable and to the RPi and when you run the program now it should take a picture!

5) Solenoid
  • As with the shutter release create the circuit. The bit that had me stumped was the diode, On Davids website he refers to it as a flywheel dioide, but from what I can tell you can just use any Diode..But more than happy for an expert to correct me on that one!
View attachment 5666
  • The power supply for the solenoid needs to be 12v, i had an old power adapter which i cut up and used, you can also buy a battery pack to fill with some AA batteries. Maplin is the best place on the high street to look for this, otherwise plenty of web sites.

I think thats everything, let me know if you need assistance and i will try and help :)

Cheers
Euge
 
Last edited:
hi thank you for explaining daves post simply i have been emailing with him but still stuck.

your post makes a lot more sense.

just waiting of my solenoid to arrive (which is tomrrow) but going to test the system with led to make sure it works.

my shutter release triggers when the 3 wires come in contact is that the same for yours. i think i will connect them individually and pass a currtent though each one simultaneously.

is that what you have done?
 
Just to mention that darren - cowasaki - has a company that sells ready made triggers without the need for an Rpi. tinkering is fine, but personally i'd rather pay and use the time to take photo's
 
Just to mention that darren - cowasaki - has a company that sells ready made triggers without the need for an Rpi. tinkering is fine, but personally i'd rather pay and use the time to take photo's

I think one of the main differences is cost though - although the above doesn't cost nothing, the parts are a lot cheaper than a pre built version. Its fine if you can afford a few hundred pounds for a dedicated trigger (indeed solenoid kit is £249), but if people are starting out or just do water etc shots ever now and again, this is a great idea
 
It depends on how you cost your time though - if you have acres of spare time then yes build one (some folks love to tinker) personally if spare time is limited and precious it makes more sense to pay for a prebuilt trigger so as to dedicate the time you have to photography.

I'm not saying don't build one - i'm just pointing out that the prebuilt option is there for those who might prefer it
 
hi thank you for explaining daves post simply i have been emailing with him but still stuck.

your post makes a lot more sense.

just waiting of my solenoid to arrive (which is tomrrow) but going to test the system with led to make sure it works.

my shutter release triggers when the 3 wires come in contact is that the same for yours. i think i will connect them individually and pass a currtent though each one simultaneously.

is that what you have done?

Good point I didn't mention this.. I put the Ground and Auto Focus wires together and then when the circuit is made with the shutter wire the camera is fired. A point to make is that you should not have any power running across the trigger wires, the camera is fired when the circuit is connected.
 
I found the site very useful. I built the rig and got some good shots its a lot cheaper than using the pre built timers and triggers.

http://www.davidhunt.ie/?p=2770

Nice shots :)

I have amended my code to do a couple of additional things:
1) Pass parameters in the command line to change the delay for shutter and drops
2) enable it to fire the flash and a camera which seems to help gain better control over the delay.

I will post that later tonight if thats of use
 
It depends on how you cost your time though - if you have acres of spare time then yes build one (some folks love to tinker) personally if spare time is limited and precious it makes more sense to pay for a prebuilt trigger so as to dedicate the time you have to photography.

I'm not saying don't build one - i'm just pointing out that the prebuilt option is there for those who might prefer it

Agreed.. for me its the challenge of getting it working as much as getting the photo. 8 Hours well spent :)

Another advantage of the RPi is flexibility, once you have sussed out the delay triggers for Water Drops, the next thing is Sound and Light triggers so you can start playing with other types of high speed photography at low cost.
 
Below is the updates code that I have used to fire both the camera and a separate flash. The trigger for the flash is exactly the same as a camera shutter, I got a PC Sync cable to connect to my flash and the connected that directly into the breadboard.

I have used slightly different pins on my set up so be aware of that... also i have used "import wiringpi2" you may need to change this line depending on what you are using.


#!/usr/bin/env python

import wiringpi2 as wiringpi
from time import sleep
import sys

def main():

gpio = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_GPIO)

#set RPI Pins for control
shutterpin = 27
solenoidpin = 17
flashpin = 22

#Set the pins for Output
gpio.pinMode(shutterpin,gpi.OUTPUT)
gpio.pinMode(solenoidpin,gpi.OUTPUT)
gpio.pinMode(flashpin,gpi.OUTPUT)
wiringpi.pinMode(shutterpin,1)
wiringpi.pinMode(solenoidpin,1)
wiringpi.pinMode(flashpin,1)

#Define imputs from Command Line
shutterdelay = sys.argv[1]
shutterdelay= float(shutterdelay)

flashdelay = sys.argv[2]
flashdelay = float(flashdelay)

dropdelay = sys.argv[3]
dropdelay = float(dropdelay)

#Fire Camera (Ensure shutter speed is longer than flash delay
#gpio.digitalWrite(shutterpin,gpio.HIGH)
#sleep(0.01)
#gpio.digitalWrite(shutterpin,gpio.LOW)

#Open and Close first Drop
gpio.digitalWrite(solenoidpin,gpio.HIGH)
sleep(0.06)
gpio.digitalWrite(solenoidpin,gpio.LOW)

#Wait for Drop to Fall
sleep(dropdelay)

#Fire Camera (Ensure shutter speed is longer than flash delay
gpio.digitalWrite(shutterpin,gpio.HIGH)
sleep(0.01)
gpio.digitalWrite(shutterpin,gpio.LOW)

#Open and Close second Drop
gpio.digitalWrite(solenoidpin,gpio.HIGH)
sleep(0.06)
gpio.digitalWrite(solenoidpin,gpio.LOW)

#Fire Camera (Ensure shutter speed is longer than flash delay
#gpio.digitalWrite(shutterpin,gpio.HIGH)
#sleep(0.01)
#gpio.digitalWrite(shutterpin,gpio.LOW)

#Wait for impact
#sleep(0.12)
sleep(flashdelay)

#Fire Flash
gpio.digitalWrite(flashpin,gpio.HIGH)
#sleep(0.1)
gpio.digitalWrite(flashpin,gpio.LOW)​

if __name__=="__main__":
main()



When you run this from the command line you will need to pass 3 variables..

var 1 => Shutter Delay (usually 0, this isnt actually needed)
var 2 => Flash Delay (Time after the 2nd drop of water to wait before firing the flash)
var 3 => Drop Delay (How long to wait after the first drop before releasing the 2nd Drop)

The setup aims to Drop both droplets of water at your chosen interval and then open the camera (set this to F22, ISO 100, 1/100 second) then wait for the perfect moment to fire the flash. The flash will then expose the image and the shutter will then close. You need to ensure that when you open the camera shutter without the flash its a black image. If its not there is too much ambient light. This will ensure that the flash is controlling the exposure. When using a flash gun use the lowest power option possible, this will ensure the quickest 'exposure'. Try not to go above 1/16th power.

So an example of the command line to run this would be:

sudo python waterdrops.py 0 0.36 0.06

0 Shutter Delay
0.36 Delay after the 2nd drop before firing the flash
0.06 Delay between Drops 1 and 2

The advantage of this is that you can quickly tweak your settings when you are trying to find the right moment..

Hope that helps / Makes sense!

Cheers
Euge
 
Last edited:
also i am brand new to the raspberry pi to make a code file what program do i use or do i do it in the command line
 
arrr i can't seam to get it to work. either the camrea tiggers all of the time or not at all
 
ok worked it out now every thing is working
thanks for your help. i decied not to trigger the flash but just the camrea as the flash sync from my camera is not an issue
 
Back
Top