Assume there is a piece of metal. I would like to identify, with a microcontroller, if another metallic object is touching this piece.

I want to apply this for a smart hook that "knows" if a keychain is hanging on it.

Is there a standard way of sensing such changes?

I have an idea to connect the piece to a leaf of a capacitor and to measure the momentary change of voltage when the metals touch or deattach. Is this a good idea?

Edit: Long time after asking the question I stumbled into this project which looks like what I was asking for in the first place. https://www.reddit.com/r/MSP430/comments/4clen1/capacitive_touch_sensor_circuit_and_code/

  • \$\begingroup\$ Thanks for posting the update. The author has basically built a toggle switch. For your application you still couldn't tell if keys had been placed or removed. Did you ever try the double-hook idea? \$\endgroup\$ – Transistor Apr 24 '16 at 19:57

Normally a set of keys won't carry any electrical charge. If the keys aren't charged there won't be a transfer of charge to your capacitive detector and hence there won't be a voltage change and you won't be able to detect anything.

If, on the other hand, the keyholder has just shuffled across the carpet in a low humidity environment they could be carrying many kilovolts of charge and this would not bode well for your electronics.

You might be able to come up with some circuit that detected the capacitance of the human body but only if they were touching the metal keyring as they hung them up. If holding the plastic part of the key or wearing gloves, or had dry, dirty insulated hands then you wouldn't detect them either. If you did detect skin touch your next problem would be trying to figure out whether they had hung up the keys, removed them or hung them up and immediately removed them, etc.!


simulate this circuit – Schematic created using CircuitLab

Figure 1. Twin-hook keyring detector. New and improved version with static protection.

The circuit shown in Figure 1 will feed a 'high' to the GPIO pin on your micro. When a metallic keyring is attached the GPIO pin will be pulled low.

Obviously, you have a bit of work to do in designing the hook to be reliable, non-oxidising metal, etc., but it's got to be simpler and more reliable than capacitive sensing. I reckon that two parallel hooks about 10 mm apart on an insulating backboard should do the trick.

Place an insulating bridge between the open ends of the twin hook to prevent the keys being hung on one or other single hook.

  • \$\begingroup\$ +1. The first sentence requires a lot of clarification, but the rest is gold. Two hooks with a thin insulator between them is a clever solution. \$\endgroup\$ – DrFriedParts Mar 6 '16 at 22:49
  • \$\begingroup\$ How's it read now, Boss? I wrote a short essay. \$\endgroup\$ – Transistor Mar 6 '16 at 22:58
  • \$\begingroup\$ Ha! Thanks for the effort. Actually though, it's still a little incorrect. A set of keys carries lots of charge, just not net charge. The charges can and will be redistributed when they come in contact with the hook. For example, if the hook has a net charge, the presence of the additional conductor (keys) will cause the net charges to be redistributed over a bigger mass. Depending on the system design this behavior is detectable. You could also approach it the same way capacitive touch screens work detecting the presence of the additional conductor in a psuedo-static electric field. \$\endgroup\$ – DrFriedParts Mar 7 '16 at 0:33
  • \$\begingroup\$ To be clear, the simple double hook idea is genius and easily the superior solution to the OP's problem. \$\endgroup\$ – DrFriedParts Mar 7 '16 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.