I hate to create so many threads for one project, but you guys have been so helpful.
Ok, so I 'think' I have this right. What I'm trying to accomplish is to control a car's keyfob with the arduino. I have a digital pin pulse high for when I want to press a button on the keyfob. Right now it lights an LED for testing.
The keyfob will be powered by the 3.3v off of the arduino, so the ground will already be shared. As for the buttons on the fob, they come from somewhere? and they go directly to ground on the other side. (0 ohm to neg battery terminal) Am I correct in thinking I can use an 2N2222 and connect the base to the digital pin with a 1k resistor, the collector to the other side of the button, and the emitter to the shared ground? Should this not act the same as a button closing the two together?
It seems all I can find here are circuits where the transistor is switching some power supply. I mean, it's kind of the same, but different.
Thanks in advance. If I don't hear back by when my extra keyfob comes in (eBay), I'll just try it and post the results here. I'm trying really hard not to test with one of the fobs I already have. The thing is, as long as I have two of them working, I can easily program more to my car myself. If I blow one before the other gets here, I have to go to the dealership and spend dollars that would be better spent on components!
So I take it that since neither of you said it was a bad idea overall, then it must be ok.
About the opto-isolator suggestion, would a transistor allow current going in the base to leave out the collector if the base input is a higher voltage than what's coming in the collector? If so, would a simple diode on the collector help that?
Again, the keyfob battery will be removed and it will be powered by the 3.3v from the arduino. So the Arduino ground, the keyfob negative terminal, and the other side of the button are all directly connected.
When the keyfob is wired to the 3v out of my diecimila, it doesn't work. I mean, pressing the buttons in the traditional way doesn't work.
I don't understand, it's powered by a 3v battery. This battery puts out 3.3v. I wire it to 3.3v, and no go. Connections were good, I don't follow. I even (boldly) tested it from 5v power, still no good. STill functions by the battery, though.
If I power the fob from battery (eek!), should the transistor still work as set up before? Should I still then link the grounds between the fob and arduino?
I'm not following why the fob in the first place. Is it because that's the simplest way to tap into the car's electronics -- to pretend to be the OEM keyfob?
This battery puts out 3.3v. I wire it to 3.3v, and no go
Either the connections were not good, you didn't have 3v3 in the first place, or you broke it while you were doing it.
I even (boldly) tested it from 5v power, still no good.
That might have broken it altogether!
Put simply you were not doing what you thought you were doing. In my experience when this sort of thing happens it is often the bit that is so obviously right, that contains the error.
I'm not following why the fob in the first place. Is it because that's the simplest way to tap into the car's electronics -- to pretend to be the OEM keyfob?
Yes, that's exactly what I'm doing. I want to make a keypad that unlocks my Dodge Caliber just like my old Lincoln had.
I have my code finished already. I have a five digit code, you can pad the beginning with as many keypresses as you like, and when the right combination is in, the green led blinks. If you press a specific button next within four seconds after the combination, the green led will blink again. If you press the last two keys together, the red led lights. This all acts exactly like my Lincoln's keypad did. Except obviously instead of green and red, I want lock and unlock.
The benefit of tying into the keyfob is two fold:
Way easier install. No wires in my door to splice into so my door doesn't have to be torn apart during testing. In fact, I can have it fully functional and not even connected to my car at all.
Via the keyfob, I can have it unlock only the driver's door, and optionally the other doors. (first and second unlock press) The cars unlock button on the door will only do all doors.
That might have broken it altogether!
Yes, that was risky, and pretty stupid. The fob still works, though. I popped the battery back in and it works fine.
In my experience when this sort of thing happens it is often the bit that is so obviously right, that contains the error.
Honestly I was hoping that someone had some really in-depth electrical reason why what I was trying to do wouldn't work. Something I didn't know.
I took a couple jumper wires from the kit for universal breadboards, plugged one into the 3v and one into the ground on my Arduino. The other ends I soldered onto the pads that the battery presses against. I even measured the voltage from the pads (not over the solder) and got just the voltage I expected. The ONLY thing I could imagine was that I had reversed polarity from the battery. But I checked and double checked that it was right.
I hear you on tearing open the doors. My Camry had no keypad or keyfob. I added one, currently via Arduino.
Had to tear open the door to figure out what the wires looked like for the electric locks (not documented in the Chilton's, of course!) And it's an all-doors solution at the moment.
Sounds like an ingenious hack to just plug into the keyfob. I've got a funny suggestion, though. Why not go all Steampunk and build a solenoid that physically pushes down the key?
(Or you could do similar and just replace the key with a relay...that gets rid of trying to figure out voltages and so forth).
Darn, I was hoping I'd be the first to do this one.
So tell me, you added a keypad? What did you use for the actual keypad part? I was looking at a keypad that ford made to be stuck on, and just using it for the weather proof keys and disabling the insides.
I had thought about using 5v relays but that seems like it would add alot of size, and moving parts don't last as long.
I will definately not be going steampunk. This should be invisible except for the interface.
No, no...I have a couple of matched keyfob transmitters and receiver units kicking around. Been buying them on eBay. Basically just hooked a 12v driver circuit and auto relay to the receiver. Arduino is in there just to be a power supply and timer and to allow me to do more complicated tricks in the future. My real intention is to add a relay that connects the starter circuit for a timed interval (long enough to start the car) then disables it again. I just haven't gotten around to splicing into the starter wire yet. In the long range, I hope to add some semblance of an actual alarm on top of everything else.
However I have just had a thought. What if the buttons on your fob are not simple ground to make but are part of a scanning matrix. In that case you would need to take both lines from your button and connect them together to allow signals to pass through them. In this case what you would need is an analogue switch something like a 4016 (4 in a package).
If you have access to an oscilloscope you can look at the signals on the buttons of your fob.
Am I right in thinking that a single 4016 could switch for both buttons
Yes there are four independent switches with independent controls. Wire the control line to the arduino outputs and connect the ground (of the 4016) to the common ground. Also make sure the fob's supply ground is common. Then take the two wires from the fob's buttons to separate in/out of one of the switches.
To be clear, I haven't used the arduino to simulate the button press yet. I was simply trying to power the fob and press the button the normal way. I like to change one thing at a time, you know? But if I can't power the fob, I'm not sure I want to contine in the same direction. That is, I don't want to have to pull the door apart when the battery dies.
Wire the control line to the arduino outputs and connect the ground (of the 4016) to the common ground.
Should I put a 1K resistor on the control lines?
Edit: I'm starting to reconsider this. I may just wire into the door after all. At least I'll start looking at it. If I can't figure out how to power that fob, I may have to.
Wiring into the door opens up the possibilty of having a code to roll down/up my windows!
Of course, I have to overcome the issue of my windows not working with the key off...
Having glanced in my service manuals, I see that getting to the door/window controls is easy, and there is a 12v source right on them. Also, it's really laid out what I have to do to simulate a keypress. I'll still have to tear the door apart to put in the keypad eventually, though.
To conserve space, I think I'll see how hot the nano gets when powered off 12v. As long as I'm not actively driving anything most of the time, it shouldn't get too hot I wouldn't think, but I can power it off of a 12v adapter in the house for a while to see.
Man this project of mine is ever changing. Maybe this weekend I can put some time into it to help solidify it.