Page 1 of 1

RasPi Carputer

Posted: Sat Oct 12, 2013 6:18 pm
by sghsmorgan
I know this has had probably a hundred threads devoted to it, and I've looked through a lot of them! lol I just need a bit more information.

I've found an old DVD player screen that I will use as a head, and I think I'll strap it to my sun visor. I want to mount my pi in the glove box, and hard wire it into the car.

I thought about tapping into cig plug, but it stays on with my car turned off, it will kill my battery. I guess I could hook up a power switch to it, what would be the easiest way to do that safely? Should I use something like this?
http://www.amazon.com/Hardwire-Micro-Su ... B008OVL4E8
Even if I use that though, it wouldn't shut down safely. Any help and ideas would be appreciated!


Also, what would be some good software to run on the pi for GPS, OBD reading, and front & rear cameras?

Re: RasPi Carputer

Posted: Sat Oct 12, 2013 8:00 pm
by dancytron
The standard automotive way to do what you want would be to use a bosch type relay and trigger it off something (like the radio power) that is only on when the car is on or in accessory mode. Power could come straight from the battery with an inline fuse and then go to whatever you are going to use to convert it to 5 volts. http://www.bcae1.com/relays.htm

Re: RasPi Carputer

Posted: Sat Oct 12, 2013 10:03 pm
by sghsmorgan
I see what you are saying, but essentially, that is just like cutting the power from the pi all at once. I want to do a safe shutdown for the pi so that I don't corrupt the SD.

Re: RasPi Carputer

Posted: Sat Oct 12, 2013 11:56 pm
by kyled2012
Hi There sghsmorgan

For a safe shutdown and power-up switch, I'd take a look at Mausberry Circuits (http://www.mausberrycircuits.com/)

They make a few different kinds of power switches that allow safe shutdown and power-up on the raspberry pi.
They also make a switch that can be wired directly to 12v for in-car applications.

I don't work for Mausberry Circuits, but they come highly praised and recommended by people I know, and I have a few of their products on order at this time.

Re: RasPi Carputer

Posted: Sun Oct 13, 2013 1:44 am
by sghsmorgan
That's a little out of my price range. I'm looking for a way to wire it in myself. So as not to have to spend much money on it, I want this to cost as little as possible.

Re: RasPi Carputer

Posted: Sun Oct 13, 2013 4:11 pm
by sghsmorgan
My main issue is the scripting & other software now.

I know how to hook an "accessory wire" to one of the pins, but what script do I need to Start it/ Power it down?

Also, I'm looking for some good Telemetry & GPS software.

Re: RasPi Carputer

Posted: Mon Oct 14, 2013 6:59 am
by sghsmorgan
How's this for wiring the Pi and a USB hub?
http://www.ebay.com/itm/Waterproof-DC-C ... 25831c34a4

Any risk in surges?

Re: RasPi Carputer

Posted: Mon Oct 14, 2013 7:17 am
by Whig
I have 12VDC -> USB adapter and battery guard on my setup.
That 12VDC thingy get's power from battery and so does battery guard which cut power around ~10.88v and then relay tell to Pi (via GPIO) to start shutdown. I also have switch to start that same shutdown manually when I want.
Could that kind of thing work for you?

And if you need script to do that here is script which I use:

Code: Select all

#!/usr/bin/env python2.7
# script by Alex Eames http://RasPi.tv/
import RPi.GPIO as GPIO
import os

GPIO.setmode(GPIO.BCM)

GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)

try:
    GPIO.wait_for_edge(23, GPIO.FALLING)
    cmd = '/scripts/uptime.sh'
except KeyboardInterrupt:
    GPIO.cleanup()       # clean up GPIO on CTRL+C exit
GPIO.cleanup()           # clean up GPIO on normal exit
And on uptime.sh I just have commands which I want to run when I turn off my RasPi and then shutdown -h now on the end of that script.

Re: RasPi Carputer

Posted: Mon Oct 14, 2013 7:27 am
by ame
I built a car computer a while ago. It was basically a 386 motherboard in a metal box. To turn it on and off I used a PIC microcontroller.

The computer PSU was connected to a permanent 12V supply (the car battery, basically), but the PSU could be held in a low-power 'off' state. The PIC was installed in the dashboard, and was responsible for driving a 4 line by 20 character LCD, a 4x4 keypad, and monitoring the state of the car ignition. It was also connected to the permanent 12V supply, and permanently 'on' (consuming about 4mA). A serial cable and a single control line went from the PIC to the PC in the trunk.

When the ignition was turned on, the PIC would set the control line high, which would turn on the PC. The PIC would keep this line high for at least one minute, even if the ignition was turned off again, to allow the PC plenty of time to boot. When the PC was running, it would send data to display on the LCD to the PIC via the serial port. The PIC would send keypresses from the keypad back to the PC via the serial port. When the ignition was turned off, the PIC would repeatedly send a special character, which could not be generated by the keypad) to the PC. When the PC detected this character it would initiate a shutdown. After about one minute the PIC would assume the PC had shut down and turn the control line off, which turned off the PC PSU.

You might be able to modify this circuit:
http://www.mosaic-industries.com/embedd ... controller

Or maybe you just need a PIC or an ATtiny that is on all the time, monitoring the ignition switch.

Re: RasPi Carputer

Posted: Mon Oct 14, 2013 11:54 pm
by sghsmorgan
Whig wrote:I have 12VDC -> USB adapter and battery guard on my setup.
That 12VDC thingy get's power from battery and so does battery guard which cut power around ~10.88v and then relay tell to Pi (via GPIO) to start shutdown. I also have switch to start that same shutdown manually when I want.
Could that kind of thing work for you?

And if you need script to do that here is script which I use:

Code: Select all

#!/usr/bin/env python2.7
# script by Alex Eames http://RasPi.tv/
import RPi.GPIO as GPIO
import os

GPIO.setmode(GPIO.BCM)

GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)

try:
    GPIO.wait_for_edge(23, GPIO.FALLING)
    cmd = '/scripts/uptime.sh'
except KeyboardInterrupt:
    GPIO.cleanup()       # clean up GPIO on CTRL+C exit
GPIO.cleanup()           # clean up GPIO on normal exit
And on uptime.sh I just have commands which I want to run when I turn off my RasPi and then shutdown -h now on the end of that script.
So the battery guard tells the pins (with script) to shutdown the pi when the car battery gets too low? When does it turn on?

Re: RasPi Carputer

Posted: Tue Oct 15, 2013 12:00 am
by sghsmorgan
ame wrote:I built a car computer a while ago. It was basically a 386 motherboard in a metal box. To turn it on and off I used a PIC microcontroller.

The computer PSU was connected to a permanent 12V supply (the car battery, basically), but the PSU could be held in a low-power 'off' state. The PIC was installed in the dashboard, and was responsible for driving a 4 line by 20 character LCD, a 4x4 keypad, and monitoring the state of the car ignition. It was also connected to the permanent 12V supply, and permanently 'on' (consuming about 4mA). A serial cable and a single control line went from the PIC to the PC in the trunk.

When the ignition was turned on, the PIC would set the control line high, which would turn on the PC. The PIC would keep this line high for at least one minute, even if the ignition was turned off again, to allow the PC plenty of time to boot. When the PC was running, it would send data to display on the LCD to the PIC via the serial port. The PIC would send keypresses from the keypad back to the PC via the serial port. When the ignition was turned off, the PIC would repeatedly send a special character, which could not be generated by the keypad) to the PC. When the PC detected this character it would initiate a shutdown. After about one minute the PIC would assume the PC had shut down and turn the control line off, which turned off the PC PSU.

You might be able to modify this circuit:
http://www.mosaic-industries.com/embedd ... controller

Or maybe you just need a PIC or an ATtiny that is on all the time, monitoring the ignition switch.
At first, this seemed to be too complicated for me, but maybe not. I bought a microprocessor/ programmer a while back. I'll look into this, thanks!

Re: RasPi Carputer

Posted: Tue Oct 15, 2013 1:01 am
by sghsmorgan
sghsmorgan wrote:
ame wrote:I built a car computer a while ago. It was basically a 386 motherboard in a metal box. To turn it on and off I used a PIC microcontroller.

The computer PSU was connected to a permanent 12V supply (the car battery, basically), but the PSU could be held in a low-power 'off' state. The PIC was installed in the dashboard, and was responsible for driving a 4 line by 20 character LCD, a 4x4 keypad, and monitoring the state of the car ignition. It was also connected to the permanent 12V supply, and permanently 'on' (consuming about 4mA). A serial cable and a single control line went from the PIC to the PC in the trunk.

When the ignition was turned on, the PIC would set the control line high, which would turn on the PC. The PIC would keep this line high for at least one minute, even if the ignition was turned off again, to allow the PC plenty of time to boot. When the PC was running, it would send data to display on the LCD to the PIC via the serial port. The PIC would send keypresses from the keypad back to the PC via the serial port. When the ignition was turned off, the PIC would repeatedly send a special character, which could not be generated by the keypad) to the PC. When the PC detected this character it would initiate a shutdown. After about one minute the PIC would assume the PC had shut down and turn the control line off, which turned off the PC PSU.

You might be able to modify this circuit:
http://www.mosaic-industries.com/embedd ... controller

Or maybe you just need a PIC or an ATtiny that is on all the time, monitoring the ignition switch.
At first, this seemed to be too complicated for me, but maybe not. I bought a microprocessor/ programmer a while back. I'll look into this, thanks!
But would I need the ATtiny or PIC? Couldn't I have the Pi monitor the ignition?

Re: RasPi Carputer

Posted: Tue Oct 15, 2013 1:40 am
by ame
Yes you can, but really, although the Pi's power consumption is small, it will drain the car battery if it's left on all the time. If you use your car every day then you will recharge the car battery when you drive, but if you don't drive for a few days your battery may go flat.

A PIC or ATtiny will consume a very small amount of current, so even if it's on all the time it will have a negligible effect on the battery. You can write a small program that continuously monitors the ignition and turns the Pi on and off with a relay or a FET, and signal the Pi for a safe shutdown. You can also compensate for the ignition being turned on and off quickly, as I did in my original design.

I suppose another thing you could do is find out if the Pi CPU has a low-power sleep mode and use that (I have no idea if it does). If the Pi is only consuming a few mA then it can be 'on' but not doing anything, then an interrupt on the change-of-state of the ignition line could wake the Pi up to full-power mode.

Re: RasPi Carputer

Posted: Tue Oct 15, 2013 5:05 am
by Whig
sghsmorgan wrote:So the battery guard tells the pins (with script) to shutdown the pi when the car battery gets too low? When does it turn on?
Yes to that first question and to seconds one just put switch which cut the power when pushed and put that to power leads... not a pretty way but it should work...