3
\$\begingroup\$

The plan is to place a Raspberry Pi in a vehicle togheter with a camera and fully automate the startup/shutdown of the raspberry. So - what is the best way to detect that the vehicle is running?The first thing that comes into my mind is - check if the alternator outputs some voltage. The first problem appears when starting car.The alternator produces some voltage. This can be solved with some electronics (RPi power controller RPipc), to give power to the raspberry after 20 seconds when the alternator starts producing some voltage.

The second problem is shutting down raspberry. Again - RPipc can monitor alternator output and if alternator is not producing any output (or below some voltage), then send a signal to raspberry GPIO and then the script stops all apps and shuts down raspberry pi.After one minute (some time) RPipc turns off power to the raspberry pi.

Power to raspberry pi can be provided via some relay witch is controlled by RPipc.

At this moment i do not plan to place some ODB2 tool to vehicle and attach it to raspberry pi. And my car ODB connector is under a cover in the front of the center console: ODB connector location If i want to permanently add the ODB diagnostics tool, i am going to need to solder another connector.

EDIT:
Also RPipc must wake up after it receives a signal from the alternator and cut power when the vehicle is turned off. But my question is about how to detect if the vehicle is turned on (engine is running).

EDIT 2: Here is schematics for voltage feeder

\$\endgroup\$
  • \$\begingroup\$ do you want circuit to detect the alternator and boot RPi after 20secs and shutdown RPi when there is alternator stopped running? \$\endgroup\$ – yogece Oct 26 '13 at 15:23
  • \$\begingroup\$ @yogece yes. My plan is to build some circuit. There is no other options to do that. Because raspberry pi must properly shutdown (not just remove power). \$\endgroup\$ – Guntis Oct 26 '13 at 15:43
  • 1
    \$\begingroup\$ possibly monitor the pulses from tachometer \$\endgroup\$ – user107576 Apr 21 '16 at 9:33
5
\$\begingroup\$

Most cars have 2 12V lines, a permanent one (12V from the battery) and switched, which is active after half a key turn in older cars, and after the ignition button activation in newer cars. You can use a voltage divider and connect it to a digital IO to detect it. Also, add a varistor to it, car voltage lines have nasty spikes which can easily fry your electronics.

Detecting whether a motor is running or not, you need to sample the 12V line and see if it is above 12V. Usually, the alternator generates 13 to 14V.

\$\endgroup\$
  • \$\begingroup\$ Second 12V line is not activated when ignition is on position 2? My car is 1999 year volvo c70. \$\endgroup\$ – Guntis Oct 26 '13 at 15:41
  • \$\begingroup\$ It depends on the car, there are way too many variations to consider. A more noble way to detect a running motor is an accelerometer. \$\endgroup\$ – Lior Bilia Oct 26 '13 at 16:13
  • \$\begingroup\$ How i can get it done with accelerometer? \$\endgroup\$ – Guntis Oct 26 '13 at 16:16
  • \$\begingroup\$ You measure the car's vibrations, analyze them and decide whether it is the motor, normal acceleration or the neighborhood's hoodlums trying to steal your car :) \$\endgroup\$ – Lior Bilia Oct 26 '13 at 16:18
  • \$\begingroup\$ :D Next week i go to local university and discuss this case with some teachers. And then report back results :) \$\endgroup\$ – Guntis Oct 26 '13 at 16:22
2
\$\begingroup\$

I would just use the 12 volts controlled by the ignition switch - the time that the ignition switch is on, but the engine is not running, should be insignificant.

Alternatively, you could monitor the oil pressure warning switch - you will only have oil pressure when the engine is running.

\$\endgroup\$
  • \$\begingroup\$ Oil pressure is another good point. When vehicle is in starting process, all electronic is deactivated. \$\endgroup\$ – Guntis Oct 30 '13 at 9:24
  • \$\begingroup\$ The battery discharge (charge indicator) is also a convenient point to determine if the engine is running. It will respond a tiny bit faster than the oil pressure I expect but not much. Certainly just measuring the 12 supply to see if it is above 13V or so is going to be the easiest and can be done from any power point. \$\endgroup\$ – KalleMP Sep 13 '17 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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