chrisbay90
Posts: 4
Joined: Mon Aug 06, 2012 3:40 am

Car tracking / trip logger / war driving / always on raspi

Mon Aug 06, 2012 4:10 am

I've had the idea for a long time to have a system in my car capable of recording every journey make and uploading it to some remote storage for my any time access. As well as have any time 'findme' functions of a car security device. Finally I thought of using the rasbery pi to do this

If anyone is interested, some of the code I have so far is down below.

I also plan to implement OBDII logging and wardriving functions in as well.
Some questions.
The Pi will need a 3G dongle, GPS receiver, wifi receiver and obdII connection.
It should be powered on at all time, as well as haveing a gps fix and data connection all the time.
It should know whether the ignition is on or off
The wifi and obd need only be active when ignition is on.

I have:
A USB GPS receiver, compact 4 port unpowered USB hub. A number (3ish?) of car phone/GPS chargers (12v cig -> 5vUSB, non specified amperage but designed only as chargers)

What hardware do you reccomend for this project, keeping in mind I would like the lowest possible but also this should be designed not to drain the battery while ignition is off (although 90% of the time that is only overnight).

https://sites.google.com/site/chrisbay9 ... ects=0&d=1
Please note however it's in a yucky messy awful alpha stage and probably isn't very readable. As well as being designed to run on a dedicated system so will do things like for a reboot if it loses contact with gpsd and cannot re-establish a connection.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Car tracking / trip logger / war driving / always on ras

Mon Aug 06, 2012 7:57 am

chrisbay90 wrote: It should be powered on at all time, as well as haveing a gps fix and data connection all the time.
It should know whether the ignition is on or off
The wifi and obd need only be active when ignition is on.

this should be designed not to drain the battery while ignition is off
How can it be powered on but not drain the battery ?
Do you mean powered on but hopefully it will still let the car start the next day?

What you can do, is power the Pi off a direct connection to 12V, which is always on
and power the Wifi and OBD from ACC, which will only be on when you turn the key to ACC.
There is also a ON wire which will only get power when you turn the car on.

You will probably want 2 hubs for this actually.
One to power the 3G, GPS and PI itself which is on all the time
and one to power the Wifi and OBD Adapter, which will only be on when you turn the car on.

Other than that, you pretty much already have all the equipment you need, as long as you know how to wire it up.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

YodaTheCoder
Posts: 14
Joined: Fri Jul 27, 2012 5:02 pm

Re: Car tracking / trip logger / war driving / always on ras

Mon Aug 06, 2012 7:58 pm

I'm working on something similar myself, for the Pi power I'm going to give this solar battery pack a try. My car often goes unused for a few days and I don't want to flatten the battery by leaving the Pi running. I'm hoping the solar charger can top up the battery pack during the downtime, but I live in Manchester so I'm not holding my breath.

The plan is to detect when the ignition is on and boot the Pi, then give the system enough time to shut down when the ignition is switched off before cutting the power. I'm thinking optoisolator for the switch and a sufficiently large capacitor to keep it switched on while the Pi goes through it's shutdown routine.

I'm still getting the component parts together and trying stuff out at the moment, but I'm documenting the project here. Any input gratefully received.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Car tracking / trip logger / war driving / always on ras

Tue Aug 07, 2012 4:33 am

YodaTheCoder wrote: The plan is to detect when the ignition is on and boot the Pi, then give the system enough time to shut down when the ignition is switched off before cutting the power. I'm thinking optoisolator for the switch and a sufficiently large capacitor to keep it switched on while the Pi goes through it's shutdown routine.
You can set it up so that the Pi only turns off after it has shut itself down gracefully.
Check this thread for ideas
http://www.raspberrypi.org/phpBB3/viewt ... 27#p104427
Then when you turn the car back on, the Pi gets powered back on automatically.
You would need to have the Pi wired to both ACC and ON though for this to work.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

YodaTheCoder
Posts: 14
Joined: Fri Jul 27, 2012 5:02 pm

Re: Car tracking / trip logger / war driving / always on ras

Wed Aug 08, 2012 8:08 pm

SirLagz wrote:You can set it up so that the Pi only turns off after it has shut itself down gracefully.
Check this thread for ideas
http://www.raspberrypi.org/phpBB3/viewt ... 27#p104427
Then when you turn the car back on, the Pi gets powered back on automatically.
You would need to have the Pi wired to both ACC and ON though for this to work.
Thanks for that, some useful info on there even though I don't quite understand the schematic. I was thinking something like this...

Image

Explanation: Both power supplies come from the car battery. The bottom power supply is switched on when the ignition is on, the capacitor C1 gets charged and the optoisolator U1 switches on transistor Q1 which turns on the power to the Pi.

Optoisolator U2 is used to tell the Pi the status of the ignition. When the ignition is on the GPIO pin will read low. When the ignition is turned off U2 will be off and the GPIO will read high, this will be the signal to the Pi to shut down. C1 should keep U1 on long enough to allow the Pi to shut down, when C1 is discharged U1 will go off and cut the power.

I have no background in electronics so I've no idea if this will work, and I haven't calculated the value of any of the resistors or the capacitor or the transistor, so any input will be useful.

chrisbay90
Posts: 4
Joined: Mon Aug 06, 2012 3:40 am

Re: Car tracking / trip logger / war driving / always on ras

Fri Aug 10, 2012 8:07 am

SirLagz wrote: How can it be powered on but not drain the battery ?
Do you mean powered on but hopefully it will still let the car start the next day?

What you can do, is power the Pi off a direct connection to 12V, which is always on
and power the Wifi and OBD from ACC, which will only be on when you turn the key to ACC.
There is also a ON wire which will only get power when you turn the car on.

You will probably want 2 hubs for this actually.
One to power the 3G, GPS and PI itself which is on all the time
and one to power the Wifi and OBD Adapter, which will only be on when you turn the car on.

Other than that, you pretty much already have all the equipment you need, as long as you know how to wire it up.
Thank you very much for you help.

Yes, I worded that post poorly. The project requires the Pi to be always on but not delplete the battery to an unexceptable level. Wehter that is possible is another aspect.

Can one simply take a 12v-5v cigarete lighter->usb charger and chop the end off and attach the wires to the two power wires of the hub to power it? If that is the accepted method, am I correct in presuming only the two data wires would connect to the Pi's USB port?

Is it okay to power the pi from the Hub? Or is it better to use 3 power supplies. On to Pi, one to hub one and one to hub 2.

As for sensing when ignition is on. Are there any suggestions on this? I was thinking of checking to see if the devices on hub 2 are available as a measure of whether ignition is on or hot, however I feel like this could be flakey. Can one wire the the 12v ignition or even the 5v psu (that is on ignition) into the GPIO or something to tell if it is on or not?

hsiboy
Posts: 6
Joined: Thu Aug 09, 2012 11:57 am

Re: Car tracking / trip logger / war driving / always on ras

Mon Aug 13, 2012 4:07 pm

@YodaTheCoder

You need to be mindful of the drain on the battery (and your capacitor if your circuit is wrong) during starting/engine cranking.

I'm building a similar thing to you (and i'm also in manchester), and one of the things i'm working on right now, is the powering of the Pi. I'm using signals on the ODB connector to determine when to sleep. The Pi protected from the voltage brownout during cranking by a large capacitor and a diode (which in turn feeds a 5v smps).

The ancillary circuits (GPS for example) are controlled by the Pi.

I'm running linux and talking to the car via perl.

Cheers,

hsiboy

YodaTheCoder
Posts: 14
Joined: Fri Jul 27, 2012 5:02 pm

Re: Car tracking / trip logger / war driving / always on ras

Mon Aug 20, 2012 12:55 pm

Using the OBD to signal power on is a good idea, unfortunately my OBD device is bluetooth so it's a no-go. At the moment I've installed a manual switch on my USB Pi power cable, I'll eventually replace it with some sort of microcontroller power-on/delay off setup.

Will the 12v to 5v USB adapters I'm using offer protection from spikes/low-power when starting the engine?

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Car tracking / trip logger / war driving / always on ras

Mon Aug 20, 2012 2:39 pm

YodaTheCoder wrote:Using the OBD to signal power on is a good idea, unfortunately my OBD device is bluetooth so it's a no-go. At the moment I've installed a manual switch on my USB Pi power cable, I'll eventually replace it with some sort of microcontroller power-on/delay off setup.
What you want, is a relay that is triggered when you turn the key to acc/on, and then is kept open by GPIO.
Don't need a microcontroller
12V -> Adapter -> Relay -> Pi
\ - - - - - - - - ACC / - - \ GPIO

Something similar to that.
Turning the key to ACC powers the Pi on, which then powers the GPIO, which then keeps the relay closed which keeps the Pi powered even when the car is off.
Have another GPIO pin wired to ACC with some resistors so that it can detect when the voltage goes low, i.e. ACC is now off. Which then triggers a script to start shutting it down.
One of the last things the Pi should do when shutting down is to stop sending voltage to the GPIO pin that is holding the relay closed, which will then let the relay open and power down the PI.
The 12V should be always powered. Can tap it off the line to the stereo in the car.

^ If that makes sense ^
Will the 12v to 5v USB adapters I'm using offer protection from spikes/low-power when starting the engine?
Depends on the quality of the adapter.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
Mortimer
Posts: 924
Joined: Sun Jun 10, 2012 3:57 pm

Re: Car tracking / trip logger / war driving / always on ras

Mon Aug 20, 2012 2:53 pm

I can't make sense of that circuit diagram, other than get a idea of what you are trying to achieve.

The GPIO part will not work, it may work of the non-GPIO end of R6 was connected to the other end of R5.

The power switching section will probably not work either. It is not usual to drive a load from the emitter of an NPN transistor, especially with a fluctuating load, which with peripherals going on and off line you will probably have.
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

chrisbay90
Posts: 4
Joined: Mon Aug 06, 2012 3:40 am

Re: Car tracking / trip logger / war driving / always on ras

Fri Aug 24, 2012 1:04 pm

If anyone is interested, I have now made my code available through svn
svn://baylis.kicks-ass.net/srv/svn/trackingTest
I registered that name some time ago as an amused teenager :P

@hsiboy I am very interested to hear what you have so far.

chrisbay90
Posts: 4
Joined: Mon Aug 06, 2012 3:40 am

Re: Car tracking / trip logger / war driving / always on ras

Fri Aug 24, 2012 4:51 pm

or
http://baylis.kicks-ass.net/svn/

Again, very interested in the work other have mentioned. Please share details.

rooster
Posts: 100
Joined: Thu Aug 02, 2012 8:09 pm

Re: Car tracking / trip logger / war driving / always on ras

Wed Oct 03, 2012 5:17 pm

YodaTheCoder wrote:I'm working on something similar myself, for the Pi power I'm going to give this solar battery pack a try. My car often goes unused for a few days and I don't want to flatten the battery by leaving the Pi running. I'm hoping the solar charger can top up the battery pack during the downtime, but I live in Manchester so I'm not holding my breath.

The plan is to detect when the ignition is on and boot the Pi, then give the system enough time to shut down when the ignition is switched off before cutting the power. I'm thinking optoisolator for the switch and a sufficiently large capacitor to keep it switched on while the Pi goes through it's shutdown routine.

I'm still getting the component parts together and trying stuff out at the moment, but I'm documenting the project here. Any input gratefully received.
I have a PI in the car powered by the lighter socket. if I turn on the ignition it boots, if I turn off it turns off. I haven't had any problems with not gracefully shutting down. I use a GPS dongle and bluetooth OBD. Just having problems getting the data out without connecting ethernet (wifi works but is intermittent - if it doesn't work on boot, I have to connect with ethernet to try and get the wifi working)

R

thojoh370
Posts: 2
Joined: Thu Oct 04, 2012 12:26 am

Re: Car tracking / trip logger / war driving / always on ras

Sat Jan 12, 2013 9:03 pm

rooster wrote: I have a PI in the car powered by the lighter socket. if I turn on the ignition it boots, if I turn off it turns off. I haven't had any problems with not gracefully shutting down. I use a GPS dongle and bluetooth OBD. Just having problems getting the data out without connecting ethernet (wifi works but is intermittent - if it doesn't work on boot, I have to connect with ethernet to try and get the wifi working)

R
I know this is an awkwardly old thread, but I am messing around with similar things and I'm curious as to how you interfaced with the OBD-II adapter over Bluetooth - did you do it using the command line (preferred) or GUI? I have a working BT dongle for the Pi and a BT-enabled OBD-II adapter. Also I'm very sorry if I'm essentially considered stealing the thread here... :?

burakpi
Posts: 6
Joined: Tue Jan 22, 2013 5:41 pm

Re: Car tracking / trip logger / war driving / always on ras

Tue Jan 22, 2013 5:43 pm

Hi;

I also want to build a Carputer for my Ford Fiesta.

I want to know, if there is a way to run the engine by Pi when you are out of the car?

syndicate
Posts: 50
Joined: Tue Jul 31, 2012 5:19 am

Re: Car tracking / trip logger / war driving / always on ras

Tue Jan 22, 2013 8:52 pm

Well for those of you still interested in developing solutions for OBD and communicating to the car. There is a development board that may be of interest. It even has power save options so you could run this thing for weeks. As far as the RPI and using a 3G dongle PM me for the solution. I worked out a Linux Image step by step that will allow you to plug in a 3G dongle and use a dial program. The development board will allow you to plug your own bluetooth module up to it and is compatible with the

https://www.sparkfun.com/products/10393(bluetooth mate).

It has a standard FTDI USB to serial port that allows for a simple terminal connection to the STN1170 chip from: http://www.obdsol.com/

The power modules has power saving features and allows for 12V, 12V switched, 5V, 5V switched, 3.3V, 3.3V switched, and 3.3V_2 for external connections. The board can be powered from the car or be powered from a 12V AC adapter. Uses filtering PTC and TVS circuits and a 5V switching regulator with low quiescent current.

Supports single wire CAN, medium speed CAN, high speed CAN, ISO, and J1850 protocols. That includes OBDII and some non OBDII protocols.

If any of you are interested in a development board please let me know. These boards are still under QA testing but are so far functional :)

Image
Image

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Car tracking / trip logger / war driving / always on ras

Sun Jan 27, 2013 2:48 pm

burakpi wrote:Hi;

I also want to build a Carputer for my Ford Fiesta.

I want to know, if there is a way to run the engine by Pi when you are out of the car?
There is definitely a way to do it, though I'm not sure of the specifics.
There are devices called turbo timers that do exactly that - keep the car on even with the key out, and counts down to turn the engine off.
From what I know, they tap into the ignition loom and supply 12v to the ignition wire even though the key has been taken out.
This simulates that they key is still in there.
You could probably use the GPIO to activate some heavier duty relays to keep 12V going to ignition.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

Return to “Other projects”