A quick and dirty vehicle entry/start sketch for Arduino
-
I've got a minor code update, I've re-written it to reflect what it's actually doing and made it so that a single inlay can switch through all three states - on, cranking, off.
It's still extremely rough and ready and if anyone else wants to do it better then go for it, I'd welcome the input.int triggerPin1 = 2; int triggerPin2 = 3; int triggerPin3 = 4; int carRunState = 0; #include <Wire.h> #include <PN532_I2C.h> #include <PN532.h> PN532_I2C pn532i2c(Wire); PN532 nfc(pn532i2c); void setup(void) { pinMode(triggerPin1, OUTPUT); pinMode(triggerPin2, OUTPUT); pinMode(triggerPin3, OUTPUT); Serial.begin(115200); Serial.println("Hello! I'm a Car!"); nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { Serial.print(versiondata); Serial.print("PN53x key scanner board not online"); while (1); // halt } // Got ok data, report state Serial.print("Reader Online, "); // Set the max number of retry attempts to read from a card // This prevents us from waiting forever for a card, which is // the default behaviour of the PN532. nfc.setPassiveActivationRetries(0xFF); // configure board to read NFC tags nfc.SAMConfig(); Serial.println("Waiting for a valid key"); } void loop(void) { String ringUid; boolean success; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type) // Wait for an ISO14443A type cards (NFC Ring, Mifare, etc.). When one is found // 'uid' will be populated with the UID, and uidLength will indicate // if the uid is 4 bytes (Mifare Classic) or 7 bytes (NFC Ring or Mifare Ultralight) success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength); if (success) { // Display some basic information about the card // Serial.print(" UID Length: "); Serial.print(uidLength, DEC); Serial.println(" bytes"); Serial.print(" UID Value: "); for (uint8_t i = 0; i < uidLength; i++) { Serial.print(".."); Serial.print(uid[i], HEX); ringUid += String(uid[i], HEX); } Serial.println(ringUid + "\n"); if (ringUid == "4db5e2b62880" || ringUid == "48fc02b62880" || ringUid == "4c9232b62880"){ Serial.println("Key accepted!"); } if ((ringUid == "4db5e2b62880" || ringUid == "48fc02b62880" || ringUid == "4c9232b62880") && (carRunState == 0)){ Serial.println("PERMISSION GRANTED, SYSTEMS ON"); digitalWrite(triggerPin3, HIGH); // sets latching relay trigger on for ignition mode in car to allow start delay(200); // waits briefly digitalWrite(triggerPin3, LOW); // removes latching relay trigger carRunState = carRunState++; } else if ((ringUid == "4db5e2b62880" || ringUid == "48fc02b62880" ||ringUid == "4c9232b62880") && (carRunState == 1)){ Serial.println("ENGINE CRANKING"); digitalWrite(triggerPin1, HIGH); // triggers output for engine starting delay(2000); // waits for a second digitalWrite(triggerPin1, LOW); // removes triggered output Serial.println("ENGINE CRANKING COMPLETE"); carRunState = carRunState++; } else if ((ringUid == "4db5e2b62880" || ringUid == "48fc02b62880" ||ringUid == "4c9232b62880") && (carRunState > 1)){ Serial.println("SYSTEM OFF, SLEEP TIME"); digitalWrite(triggerPin2, HIGH); // Trigger latching relay to reset for vehicle OFF delay(200); // waits briefly digitalWrite(triggerPin2, LOW); // Removes latching relay reset trigger delay(3000); carRunState = 0; } } }
-
I've chopped down the prototyping board to make the thing a bit easier to manage. It could be a lot smaller, but I'll leave it as it is for now in case I want to change anything more. In it's current state I'm going to temporarily install it in the vehicle and use it for a few days before making some permanent modifications to the car including removal of the steering lock.
For those who are going to cry "But easier to steal now dude" I have a well hidden GPS locator/remote disable unit installed. It'll text me if it moves and I can shut it down then find it. -
Using a single inlay to switch modes, temporary installation in the car.
-
Okay, 8 days later I've decided that while it basically works it needs two additional features - something to act as an interlock to stop the ring reading at all while you're in full flight and something to tell the arduino that the engine is already running.
During my testing I've had the arduino reset itself a few times which puts it back to the start of the cycle and means that instead of switching off the car it attempts to re-engage the starter motor. Not full of cool when you do that in public.
I'm thinking I'll take a feed from somewhere on the back of the instrument panel, probably the tachometer, and use that as part of the if statement for engine cranking and for shutdown.
The other thing I will do is use the handbrake as a lock-out for the reader unit, so that the reader itself will only work when the handbrake is engaged.
With those two issues out of the way I should be ready to do the nasty and remove the original ignition and steering lock. I may replace the lock at a later date if I can get my hands on an electric one. -
@Lokki This is great work so far my friend! You have touched on 2 of the issues I have wrapping my head around. One was the steering lock. I really would like to bypass the key altogether. Along that line was one thing not mentioned yet. If your car has a chip in the key. How to bypass it. It seems like you could tell the system the key was in using the arduino. The third and major issue of proper maintaining of states when in drive mode. That one reason why I wanted to incorporate my remote starter for this as it already performs this function. (And also can be used for unlocking the doors) Same issues would be that it still need the key turned to on in order for you to put it into gear after using fob and to unlock wheel. I imagine this scenarios. From in the car place tag over reader. Short pause move to on. Long pause move to on then start. Arduino tells proper circuit key is in and unlocks wheel. May need an electronic steering wheel lock. As I see it 'on' (and 'off') coding would point to ignition just as you said, but 'start coding points to pins running relay and stater fob. Hence engine will only stop while gear is in park. That way you can still use 2nd remote fob to start car, but wheel will still remain locked and engine will stop if attempting to put into gear without tag. Adding a cheap cellphone and DTMF or IOIO board would allow remote from anywhere to start, unlock doors. Especially when you are out of range. If you had an OBD reader to your arduino, it could read the states of things like the tach as you mentioned doing to feedback engine state. Be useful for recording car variables and for tracking using phones GPS. It seems simple in my head as a block diagram.
-
Hi @LoganFive - you've pretty much hit the nail on the head there. All this would be greatly simplified when you're working with a car that has a current-style OBD port.
The vehicles I own tend to be on the older side of things, by choice. I have a 27 year old Skyline and a 44 year old Valiant, so the way I'm working at it is both more simplified and yet a little more difficult in some ways.
You may need to get an electrical diagram of your vehicle to see what exactly you need to do to get around that key of yours, you'll want to know whether it's the ignition barrel stopping the car being started or the computer stopping the car being started. Once you've got that sorted out you can go ahead and circumvent to your heart's content.If you wanted to you could use a navspark. They have onboard glonass/gps and are arduino compatible.
One note for anyone who is reading this though: If you perform any mods on your car, then it's on your own head. I expect this decision to be made with a full understanding of any and all ramifications.
I'm doing this because I understand what I'm altering and what I plan to alter as it's affected by both law and common sense. I take no responsibility for any lemming-like behaviour from anyone else, that's on your own heads! -
@Lokki I know what you mean on older cars. My '69 Torino GT was so much easier to work on in the engine compartment! A guy could get his hands in and work on just about anything without having to pull a bunch of crap out first!
-
@LoganFive yeah I hear that. The skyline is a little cramped but the old A body chrysler is brilliant for working on. I've got photos from my last rebuild where I'm standing in the engine bay beside the engine... do that in a modern car!
-
@Lokki On your issue of safety. I was thinking of how backup cameras use the reverse gear or reverse light to switch the screen to the vga input. This i thought could translate into running a line from the brake circuit to a pin on the arduino that would lockout the NFC reader unless the brake was engaged.
Also. I have my power regulator, plenty of dev boards, and just got my NFC boards in the mail. Some of the pieces came together quickly. Just gotta get to work.
-
I was thinking of using the switched earth line from the handbrake indicator to actually switch the power to the reader unit instead, to lock it out completely. That way absolutely nothing can go wrong.
-
@Lokki good idea, just to be sure! what about the steering wheel lock issue? have you found a way to replace it with an aftermarket electric one? I really don't want to disable the lock pin in the ignition cylinder.
-
I haven't been able to sort that out yet, I'm either going to completely remove it forever because I don't particularly care whether it's there or not, or if I'm lucky I'll find an electronic one at a wrecking yard cheap, and retrofit that.
I've got gps tracking and remote shutdown+doorlock so the steering lock is an optional extra to me - I will try to achieve something there though, purely for you guys. ;-) -
@Lokki Sometimes when doing mechanical work, or for towing, it may be required to lock the steering wheel, or I would have thought to just shave the pin on the cylinder, or remove the disc, whichever I found in there. I really want to keep the key ignition process in tact as I need to have my Aztek valeted quite often. I had an interesting thought. And yes, many of my ideas seem strange. I was going to get a non chipped key made to have in case i lock myself out. The key should also be able to unlock the wheel, but won't engage the ignition. Then I planned on cutting the top down to leave enough to 3D print (I hope to have a printer finished soon) a cap that is low profile that also extends around the side flanks of the ignition cylinder. The parts that give you leverage when turning the key. But now I just realized that the key would have to click forward at least to the 'ON' position or the pin would re-engage the steering lock at what would most likely be a very inopportune time. I would have to try it when all is hooked up to see what the result would be. The point it that I could use it as I want to unlock the wheel and then when nI need to turn it over to someone else, I can pull the low profile key out and give them the real key. The low profile nature of the structure is to not make it so obvious that a key is there. they may not get anywhere, but I still would not have to deal with broken windows.
I also plan on making a cellphone as part of my setup, so I can use security software such as Airdroid to report GPS and such.
-
Yeah that would work. You only need to move it that one click out to come off the lock position and then you're golden.
As for locking the steering wheel, the lock tends to never be at a point where the wheels are naturally straight and always to be at a point where the wheel is slightly left or right of center. Anyone who tows or works on a vehicle in that way is a step beyond foolish in my opinion... Wheel chocks and wheel locks are pretty standard equipment in any sane work environment, locking the steering wheel simply isn't appropriate in any case I can think of.
Besides, there are still a lot of cars out there that never had and never will have a steering lock. There are no special things that need to be done to accommodate them!
It's purely an anti theft device, and as such your insurance provider may not like the removal of the steering lock. -
For gps tracking and remote shutdown I just use one of the cheap Chinese gps units with a prepaid sim card. It works pretty well! I may end up building my own unit at some point but the Chinese ones are so cheap it was easier to just buy and install that - it also has remote audio and a few other nice features.
-
@Lokki I was also thinking of when my mechanic did front end work. But the wheel didn't really need to be locked to keep the tires in an outward or inward position. Thanks for making me realize that. I may head down to NAPA tomorrow and look at a ignition cylinder to see just where the locking pin is for it. Hopefully it also has an easily removable cylinder. i saw where some had a tab on top that if you drilled an access hole just above, you could press down and pull the cylinder out without access inside the column.
I had planned on using an android phone and apps like tasker to make a few tasks remote by cellular. Like starting from phone when my vehicle is valeted and I want it warmed up or cooled down, but the standard remote won't work. Give me remote OBD readings also. Maybe incorporate it into the dash instead of hiding it so I can customize my dash display. double duty as an HUD? I have a shield that will connect the phone to my arduino project. The 1Sheeld. If there was a cheap enough phone that had NFC, I could have just used that instead of having to buy the NFC boards. Mount Phone in dash for nav, music, speed, etc. Flip up to start vehicle. Once I go hands on, something will work out. thanks for being the invaluable resource you are @Lokki !
-
Ah cool, that does sound good - a large phablet with a 3D printed fascia in the dash could work very well as media center and vehicle controller. That'd be an interesting thing to see pictures of!
And no worries, I love helping out with these things, especially when I'm getting shown new ways to look at something I've only ever seen a certain way. You're inadvertently making my other projects more interesting. ;-) -
@Lokki Yay! I'm helping too! :)
I seriously figured when I replace the factory double DIN head unit I would put in a single DIN stereo and use the space above for the tablet unit. A mechanical, automatic tray design would just be very cool. With some accent LEDs inside for effect.
I do make people think in new ways. In strange and unusual ways. -
That does sound very cool. The best part of this is its all achievable with arduinos and 3d printers now. The only limit is our imagination really!
-
Removal of steering lock and locking ignition barrel:
Shear bolts removed by drilling a hole and using an 'easy-out' screw:
This is the catch that actually locks your steering wheel:
Here is the actual ignition switch where it lives on the back of the locking barrel. I'm keeping this for the moment, it'll be hidden away out of sight.
Here is the switch removed from the barrel, yours may have more screws: