Ashnook13
Posts: 51
Joined: Wed Sep 26, 2012 3:43 pm

Change GPIO pin state via command line

Mon Dec 11, 2017 6:03 am

I have a program running controlling a security camera. It records whenever it sees movement vis a PIR setting a gpio pin high. I want to be able to simulate the PIR detection whilst I am away from the camera by setting the GPIO pin high for a short time (or some other way???) This is done so I can take a video on demand.

Can this be done and if so how?

Thanks, Brian

User avatar
joan
Posts: 12917
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Change GPIO pin state via command line

Mon Dec 11, 2017 8:14 am

Any number of ways.
  • write a small program interfacing with a GPIO library and make it executable.
  • write a shell script to use the sysfs interface to the GPIO.
  • use the wiringPi gpio utility.
  • use the pigpio pigs utility.

Ashnook13
Posts: 51
Joined: Wed Sep 26, 2012 3:43 pm

Re: Change GPIO pin state via command line

Mon Dec 11, 2017 8:24 pm

Thanks for those suggestions, I have started looking at them.

Question, will they, or some of them, fool the program that is running to think there is a positive signal on one of the GPIO input signals as would be seen when the PIR shorts +5v to the GPIO input?

Thanks.

pcmanbob
Posts: 2572
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Change GPIO pin state via command line

Mon Dec 11, 2017 8:39 pm

First off you PIR sensor should not be shorting 5v to the gpio input pin , the PIR sensor should be outputting 3.3v. Connecting 5v to the gpio will damage you pi.

So having got that out of the way, the simple way to set up a remote trigger is to set another gpio pin to output and connect it the the input used for the PIR using a 1K resistor.

Now any time you want to remotely trigger you PIR/camera all you need do is drive this gpio output high for 1 second or how ever long you want.
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help

Ashnook13
Posts: 51
Joined: Wed Sep 26, 2012 3:43 pm

Re: Change GPIO pin state via command line

Mon Dec 11, 2017 8:45 pm

OK, Thanks again, you are right and it is actually the 3.3v from the GPIO bus, NOT 5v, my mistake, I am just running two wires from the PI to the isolated relay on the PIR.

Your output/1KR/input idea is a good one and I will implement this when I return home.

I am away for a little while and wondered if I could activate it from here so I can see the snow situation at home. Alternatively I will get someone to walk up the drive and trigger it!
Cheers.

Return to “Advanced users”

Who is online

Users browsing this forum: No registered users and 29 guests