Skill level:     Intermediate
 

iFOBing A Mazda

by Nate  |  
May 21, 2009  |  

Ditching the Key


I hate keys. I am on a mission to dispose of them all. There is currently a key pad to enter the SparkFun building, a key pad on my home, and RFID to get into the interior rooms at SparkFun. It is my goal to get rid of the last key in my pocket, my Mazda key! I combined the Nike+iPod device and my key fob, with an Arduino Pro Mini, to create the iFOB.

Code: iFOB pde



A few years back we posted a tutorial on how to use the Nike+iPod for active RF identification. The Nike footpod transmits a unique ID every time it is used. I would much rather have a small footpod in my pocket than my full car keys. So how can I get a Nike footpod to unlock my car? It was actually not too hard:

http://www.sparkfun.com/tutorial/iFOB/iFOB-11-M.jpg

You can see the internals of the footpod (it's a Nordic IC!) and the receiver hooked up to our iPod serial board. The iPod Serial board allows direct access to the Apple receiver. Here are the two initialization strings:
0xFF, 0x55, 0x04, 0x09, 0x07, 0x00, 0x25, 0xC7
and
0xFF, 0x55, 0x02, 0x09, 0x05, 0xF0

Once we send these two serial strings to the iPod receiver, the receiver will report a serial string of about 33 hex characters every time a footpod is heard. Within these 33 characters is the unique ID of any footpod within range.

So here in lies the goal of iFOB: design a system that listens for a unique ID (kind of like active RFID) and does something when the correct ID is heard. In this case, unlock the doors to my car.

http://www.sparkfun.com/tutorial/iFOB/iFOB-4-M.jpg

So here is iFOB! In the middle is the Arduino Pro Mini running at 3.3V. The Mini is powering the iPod serial board (at 3.3V) and has serial lines connected (TX and RX) so that the Mini can configure and then listen to serial responses from the iPod receiver.  I used a clear SparkFun enclosure so I could see the status LED on the Mini for debugging.

At the bottom of the picture is the internals from the key fob to my car. I've got one wire connected to ground (the gray one) and two wires connected to the other side of the 'lock' and 'unlock' buttons. When the Arduino Pro Mini tells the red wire to go low, the key fob thinks I am pressing the lock button, and my car locks! Simple enough. The fob currently uses its own 3V lithium coin cell, but I may connect 3.3V from the Mini some day. The coincell lasts for months or years so I'm not too concerned.

On the right is a foot pod used for testing. It's labeled 'AE' (the last hex digits in its unique ID) so that I can tell it apart from the other footpods I had laying about.

This entire device lives inside my car. The Mazda computer is smart enough to ignore the key fob if the car is running so I don't have to worry about spurrious signals from my pocket locking and unlocking my doors while I'm driving.

http://www.sparkfun.com/tutorial/iFOB/iFOB-5-M.jpg

While testing I found the range of the transmitter (the footpod) was really pretty impressive at 50+ feet. This was cool, but I didn't want my car to be unlocking/lock while walking around my house or office. To cut down on the reception, I sabotaged the antenna. I could have hacked into the footpod, but then it wouldn't have fit so nice in my pocket. Instead, I completely wrapped the receiver with a few layers of aluminum foil. This cut the reception down to 20-25ft. Jeesh! What do I have to do to kill the power on these things? These devices are designed and built very well!

http://www.sparkfun.com/tutorial/iFOB/iFOB-6-M.jpg

I needed to pull power from the car's battery so I created a simple wiring harness. I was a bit worried about the iFOB mercilessly frying my electrical system, so I put in an inline fuse for a $1 worth of insurance.

http://www.sparkfun.com/tutorial/iFOB/iFOB-7-M.jpg

Here is the iFOB with antenna snubber (that's heat shrink to hold the foil on), Arduino Pro Mini and the stock FOB for my car. The board on the left is the internals of a USB cigarette adapter. This USB adapter takes in 12-24V from the car's electrical outlet (the now universal cigarette jack), and outputs 5V so that you can charge USB devices. I then wired this 5V to the raw input pin on the Mini. The Mini then regulates this (some what noisy) 5V down to a clean 3.3V, all with pretty decent efficiency. I don't want a power hog draining the car battery!

I removed the housing and USB connector from the cigarette adapter and installed a JST connector. This made i so that I could easily disconnect the iFOB from the car if need be. I was worried that I may need to remove the iFOB if I took my car into the dealer, or if I parked the car for an extended amount of time. It turns out this was a very good addition as I ended up reprogramming the device quite a bit before I got the code working solidly.

http://www.sparkfun.com/tutorial/iFOB/iFOB-8-M.jpg

I decided to intall the iFOB in the passenger side foot well. I figured this would be a good place to find a 12V power wire. I know nothing about cars so I just started pulling back panels until I found wiring. Wow is there a lot of it!

http://www.sparkfun.com/tutorial/iFOB/iFOB-9-M.jpg

Don't cut the red wire!

To find 12V I used my trusty multimeter. Luckily, I found a wire nearly immediately that registered 12V but it was a thin black and gray wire. To be sure this was directly off the battery and not a control wire, I tried to do a continuity test from the positive terminal of the battery to this pin. No good - I didn't get direct continuity. Is it because I am testing the impendance of a rather long wire? I'm not sure. But it's 12V right? I used some nifty automotive quick splice connectors and tapped the black and gray wire. I just need a few mili-amps, no big deal right?

The iFOB behaved very oddly. Sometimes it would work, sometimes not at all. I couldn't figure out what the problem was. I guessed that the power system might be causing the ATmega168 on the Arduino Pro Mini to latchup, so I decided to add a watch dog timer to my Arduino code. The watch dog timer runs in the background of the chip and if the system code freezes, the watch dog resets the chip, clearing out the locked up variable or code. It worked for the Apollo missions - why not now?

http://www.sparkfun.com/tutorial/iFOB/iFOB-10-M.jpg

The iFOB wired up and hanging out in foot well

I'm not sure what the black and gray wire is, but every time I plugged the iFOB into the car, the car would honk. I assumed this was the iFOB powering up (GPIOs tend to twiddle during power up) and accidentally hitting the lock button twice (causes the car to honk). Over time I began to realize I found some sort of 'honk' wire. I also found out that this wire would turn off after an unknown amount of time, kind of like your dome light turns off after the car is locked for 15 seconds. It was too difficult to sit in the car for hours on end to find out if in fact the wire was powering down, so instead I just tapped into the big fat red wire that registered 12V. This is a direct line off the battery. And when I plug in the iFOB, the horn doesn't honk! Hrmm.

After a few more days of testing, frustration continued. The system worked during testing, but during normal, everyday use, it did some very annoying things. Mainly, as I walked up to the car, the doors would lock! What in the world? More testing, and I found out that the Mazda has a neat security feature built in: if an unlock command is received by the car's computer, but a door is not opened within 25 seconds, the computer will automatically re-lock the cars.

Ah hah! The iFOB was picking up my footpod some distance away from the car (like in the stair well down to the parking lot). If it took me 28 seconds to get to my car (from the point at which the receiver picked up the footpod) the car would automatically re-lock after 25 seconds, right before I pulled on the handle. A bit more Arduino code and the iFOB now unlocks the doors every 10 seconds while the footpod is heard, and until the car is started. This extra bit of code fixed the relocking problem.



The system now works great! When you've got a handful of stuff, it's great to know the doors will automatically unlock as you approach. However, I still have use a key to start the car. The next step is get a big red button wired up for button start so that I don't have to carry my key. Someday.

Back to Tutorials

 

Comments

16 comments


Log in to post comments.

chansuke's rank:
+1.4
|   May 21, 2009 at 3:21 PM
Comment rating:
0
I used to install Ignition Interlock Devices (Read: Breathalyzers) on cars, and learned alot from that. Tapping into random wires can be pretty dangerous to your vehicle because depending on the wire you can ground out computer modules which are expensive to fix. http://www.the12volt.com/Default.asp? is a good resource for vehicle wiring.

While theres nothing wrong with putting the device in the passenger side foot well, it would have probably been easier to put it in the driver side kick panel, right below the steering wheel. Thats where we always stashed the IIDs.

If you want any input on the big red start button or vehicle wiring, just shoot me an email chansuke (at) gmail.com
by
Emotion's rank:
+2.2
|   May 21, 2009 at 5:33 PM
Comment rating:
0
Cool idea, but I don't think I'd trust the Nike+Ipod device with my car. Especially since the ID isn't even encrypted.
I guess it would be less convenient, but I'd probably make a RF device and then use
TEA or RC4. Both of which are small enough to implement on an AtMega 168, with enough space left over for some significant key storage.
Then you would have rolling code security. While TEA and RC4 have weaknesses, they are much more secure than simply sending out a code every time you step on the ground.
Or use Bluetooth. That way I could have my cellphone control everything. It's the way of the future! Your new cellphone will be able to be your credit card, TV, computer, keys, music player, alarm clock, and government overseer! (Big Brother is now in your pants...eww)
Anyways, to each his own. I just think that I wouldn't base my security around something for which I sell modules to circumvent.
by
RoboN8r's rank:
+4.6
|   May 22, 2009 at 2:11 PM
Comment rating:
0
That was my first thought as well. It seems like you really need a challenge / authentication code, which would make it much harder for somebody to clone. A rolling one-way code with some kind of cryptographic authentication would be a good start, but you would have to do more rcvr-side work to keep somebody from recording your working code and replaying it later.

The Toyota keyless entry system that my Camry Hybrid has is the coolest improvement to cars since air conditioning. It unlocks when you touch the door handle (with FOB in pocket). I keep on walking up to other types of doors and wondering why they don't unlock for me.

Anyway, nice job on the iFOB, I'll probably try to make my own a few projects from now.
CHaskins's rank:
+12
|   May 23, 2009 at 11:25 PM
Comment rating:
0
When in doubt for power, tap off the cigarette lighter or the fuse pannel.
by
MikeR's rank:
+2.8
|   May 24, 2009 at 8:24 AM
Comment rating:
0
@CHaskins: Be careful, alot of cars turn off their cigarette lighters then the car is off. Mine does, and that would mean that it wouldn't work for this project.

@Nate: At the end of the article you mentioned an extra bit of code that unlocks the car every 10 seconds until the car is started. I didn't see anything that sensed the car being started, so I assume that it constantly does this while you're in the car, it is just ignored while the car is on. If this is the case, that 3v lithium battery will die much faster, you should think about powering off of the 3.3v available from the Arduino.

Also, remember that with this installed, it's pretty hard to leave your car unlocked. It will be unlocking as you walk away and then relock 25 seconds after you're out of range. Probably not a problem since you'd have the iFOB with you, but something to remember.
by Nate is a SparkFun employee
|   May 26, 2009 at 8:33 AM
Mike - I was worried about that car locking/unlocking randomly while I was driving (not real safe). The Mazda computer is smart enough to ignore all FOBs when the key is in the ignition. I've also noticed that driving/sitting is not enough movement (even with a clutch) to set off the accelerometer in the footpod, so after 10 seconds the footpod shuts off.

Car locking question: If the footpod is not heard for 5 seconds (assumes I've walked away), the iFOB hits the lock button. It's there in the code, but I failed to mention it in the tutorial.
by
MikeR's rank:
+2.8
|   May 27, 2009 at 9:59 PM
Comment rating:
0
Ah, so the footfod only transmits when it detects motion(makes sense), and driving the car isn't enough to set it off. That's just about perfect then, isn't it?
by Nate is a SparkFun employee
|   May 26, 2009 at 8:34 AM
I would have much rather used power from the cigarette port but it unfortunately turns off when the car is turned off.
gaccettola's rank:
+1
|   May 27, 2009 at 4:06 PM
Comment rating:
0
I generally like stuff like this, but some tech has in my opinion a long way to go. Off the top of my head keys have a couple of advantages that I'm unwilling to forgo 1) they never ever run out of batteries b) if I fall in a pool or wash my keys they still work. 3) I have to drop a key from the 10th floor to do any harm to it, and even then I've got a good chance. Case in point I have two keys with the little lock/unlock buttons. One key works, the other got washed and doesn't. I dropped the 'bad' key yesterday and it bounced down the stairs then off the deck for a 4 meter fall onto the concrete. The 'key part' was unharmed. I've never had anything with batteries that could take that sort of abuse.

That aside, this is still pretty damn cool.
Good work outta you,
by Nate is a SparkFun employee
|   May 28, 2009 at 8:33 AM
Thanks for reading! I agree batteries and the clothes washer can be death to a good system. Both of these problems (battery life and physical hardiness) can be solved in time. The current footpod is actually nearly indestructible, but you can't easily change the battery (2 year life).
tweeder82o's rank:
+1
|   June  1, 2009 at 10:03 AM
Comment rating:
0
why not put it in your nike+ shoe?
by
JoeR14's rank:
+1.5
|   June  4, 2009 at 7:58 PM
Comment rating:
0
I have heard some stories of people messing around with the wiring under the dash and having the air bags deploy and seriously injure or possibly kill them. idk. I was always skeptical of these claims but it wouldn't surprise me if it was possible.

Great Tutorial btw. Loved the work. Very innovative! One thing you could do is use an add-a-fuse kit which allows you to wire things directly into your existing fuse box in your car. The only thing is some cars don't have extra places for fuses.
Thanks,
Joe
chewy8000's rank:
+1
|   June  8, 2009 at 2:42 PM
Comment rating:
0
So couldn't you theoreticly use the RF capabilities in an iPhone to create a UI to do this? The RF Transceiver is the Infineon GSM/EDGE RF transceiver but - the problem is that the iPhone OS will not let you access it. One other possibility is to "hack" it by going around the OS restrictions of Apple - and access the Infineon chip directly at the lower levels. Would be neat but would definately never end up in the app store :)
by
BaranE's rank:
+1.3
|   June 11, 2009 at 3:53 AM
Comment rating:
0
Hi Nate. First thank you for your great project. Do you have a wiring diagram you can share???
by
ish's rank:
+1.4
|   September  9, 2009 at 2:11 AM
Comment rating:
0
Hi there,
NATE i'm a new guy with an arduino, my job is to install security devices (car alarms,engine kill switches,gps,etc,etc) and i've bought the ipod serial board and the arduino itself (duemilanove atmega328).
The ipod serial board is working good without the arduino once i follow your tuto an loadup the sketch from the same page everything seems to be working fine and then i make all my conections to the arduino board the ipod serial board RED LED lits but none of the TX or RX seem to work.
can you explain to me what i'm doing wrong and please can you say it in english (not speaking in computer language)for a newie guy.

thanks in advance (SORRY FOR MY ENGLISH GUYS STILL LEARNING)
GREAT TUTORIAL
by
Starvin's rank:
+1
|   January  2, 2010 at 9:24 PM
Comment rating:
0
Great idea but very scary way to hook it up to a vehicle! I am a total noob when it comes to most of this EE stuff but right now I am hacking away at my car. Just bought a SCT tuner (reads the PCM and re-writes it). I have a couple items that I would like to make (that's why I am here) for the car but have some questions concerning using items (like an arduino) with the 12V that some of the sensors put out. I would like to make a WOT shift box, (when the gas is all the way to the floor, and the clutch is depressed, send a signal to the vehicle shut down relay to kill the engine for x amount of time to shift without lifting the gas.) and maybe another "widget" or two. What reading would you recommend that I do? Are there better items to use with 12V? or can I use the arduino with a shield that I have yet to read about?

Feedback

What's on your mind?

Please include your email address if you'd like us to respond to a specific question.

submit


If you would like to tell us more, you can fill out our form if you need some psycho-suggestive questions. Go to the form.