I have an interesting problem,

I want to mount a camera on the front of a tractor(Sony RX0M2, similar to a gopro). The camera will eventually be used for image processing. A PQ-12 micro linear servo (see here) will be used to turn the camera on/off. It is being run by a Raspberry Pi 4B. All components in this project will be powered by the 12V tractor battery. I have the raspberry pi running my python code to control the servo at startup. I did this by editing the crontabs in the linux terminal. Thus when the tractor turns on-> Pi starts up->Servo extends/retracts pushing the camera power button-> Sony turns on.

However, when the tractor turns off the situation is more complicated. The camera will begin to use its own battery once the power source is removed. I would prefer the camera not drain its battery everytime the tractor is turned off. It would mean the tractor would have to run for 5-10mins next startup just to charge the camera back up to a battery level where it can operate.

I need some way to press that power button on the camera once the system power source is removed. I need to:

a) sense the battery is off. Maybe I could use a small microcontroller? I simple logic gate?

b) Something that charges up while the system has power and can temporarily power the servo during discharge. Perhaps a capacitor. But then again If I do use the Servo ill need a PWM signal. Would the PI zero work here. I think ill need something small since It'll need to be powered during this discharge time also.

Note: I think the Pi 4B can probably run code at shutdown but my assumption has been that this would be after a shutdown prompted by the user in GUI, not by shutting down the Pi via removing the power source. Perhaps this is an erroneous assumption.

Just a beginner here using my mediocre knowledge to develop half-brained solutions. Thanks for the help everyone. If I'm missing any important info just let me know.


It's implied here that the Pi is on the same power as the camera and hence will have it cut without a proper shutdown first. That is a bad idea, and that is the real problem you have to solve -- you either have to operate it such that you do a clean shutdown before you turn the tractor off, or incorporate some circuitry to allow it to continue to run off the battery and initialise a proper shutdown when the tractor is stopped. It can then also turn off the camera during that time. There is then the issue of the power which would be consumed by the Pi after it is shutdown, which is not zero.

One way to do that is to have a microcontroller wired to the Pi which will react to some line going low because the system has shutdown, and then kill the power to both of them.

Which brings up the issue of why the Pi is there. If it is just to control the actuator to turn the camera on, it shouldn't be. Just use a microcontroller. It can run straight off the battery, keep the actuator on while the tractor is running, and and monitor the electrical system for when the ignition is killed to turn the camera off. You probably don't have to worry about the power consumed by the MC when the ignition is off because it should be very trivial -- or you could come up with a circuit to kill that without the shutdown issue because MC's don't run an OS and can just be disconnected.

  • See the answer I posted for reply. – gumby4231 Jul 17 '20 at 16:24
  • It sounds like you are basically developing a prototype. Is it really necessary at this point to then have an automated system for the shutdown? Could you not just have the operator do it (eg., by pushing a button and waiting for an led to go out/on/blink before killing the power) at this stage? Otherwise you are wasting a bunch of effort and resources designing and implementing a circuit that may not be needed in the end, and really isn't necessary to anything else in the project. – goldilocks Jul 18 '20 at 15:31
  • BTW, my assertion that the Pi isn't needed was based it just being used to control the actuator. – goldilocks Jul 18 '20 at 16:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.