1

Is it possible to know if there is something plugged on the pins ?

I made a web interface to control the Raspberry pi 3 remotely and I want to activate the pin where the relay is pluged but I don't have a direct access to the Pi. So I would like to know if it is possible to execute a command line or to run a python script and get the good pin.

PS: Sorry for my bad english :/

2

It is theoretically conceivable that a GPIO pin switched to input behaves differently whether it is open (nothing is connected there) to a pin where a relay driving circuit (e.g. a transistor or optocoupler) is connected to. However I'd advise against it. First and formost because that discrimination would be relying upon the floating (open) pin (and its per definition random behaviour) vs. a pin connected to something. See here.

To be honest I do not understand the need to do so. Connecting the relay to the Pi implies knowledge to which pin it is connected. Why not just use that knowledge?

  • The fact is that it's not going to be me who will plug the pin and they will be more than one relay connected to the Raspberry. – NoxrasRomael Apr 15 '16 at 12:06
  • In that case I'd still follow a deterministic approach. Whoever plugs one or more relays in, could determine which pins are used. Put that info in a config file used in your script/program. – Ghanima Apr 15 '16 at 21:20

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.