1

-As suggested I reposted my question under the registered account -

-I received an excellent reply from @LecauseAndThePi, I hope he repost his answer again so I can accept it, for now I posted the answer myself and will delete it afterwards -

-Original post as unregistred user : Log / monitor gate (dry contact) with Raspberry PI -

Original question :

Dear Stackexchange Raspberry Pi community,

I hope somebody can help me get started with my first Raspberry project..

It seems doable except this is my first project and I do have sufficient programming / computer skills but no electrical knowledge.

I hoped somebody could help me get this simple project started, let me start with explaining some background information ;

I moved to an other house 6 months ago and I have some people helping me in the house and garden. They all come in through the big automated port at my home.

The idea is to make a logger whenever this port opens (in a later stadium I will add a camera to take a picture..)

The board which controls the port has a TLS contact which means in English it’s contact dry contact.

Everytime the port opens it gives a pulse (can be set anywhere from 1 sec till 240 sec). I want to log this pulse.

The question is how I can connect the Raspberry PI to my board ? Can I connect it directly to the GPIO pins or do I need some sort of circuit ? About the software part I don't worry, but as I said I don't know where to start with the hardware part.

Thanks for all your help !

1

Original answer from LecauseAndThePi, as soon as he reposts it, I will delete mine ;

Okay so, i've only just realized i should have asked what model of pi you are using. I've already drawn this out with reference to rpi2/rpi3 pins layout, however if you are using a different model it should be pretty easy for you to change the connections accordingly. For reference, here is the pin layout for this model https://docs.microsoft.com/en-us/windows/iot-core/media/pinmappingsrpi/rp2_pinout.png.

And here is how you should connect your dry contact to the pi:

https://imgur.com/a/R1Am9

Notice that in this example i'm using GPIO 18, but you could use any GPIO, and set it up as an input programmatically. Also you should set this GPIO with an initial internal pull-down resistor, so that it's not floating when the dry contact is open. You can do this pretty easily programmatically, let me know if you need any help on this too.

So to wrap it up, when the dry switch is open you should see a LOW input at the GPIO, and when is closed, you should see 3.3V, hence HIGH at the GPIO.

  • Some questions about this answer raised my mind ; - Why should I use a resistor ? -> Because I would otherwise short the circuit. – r-d-r-b-3 Oct 9 '17 at 16:20
  • The voltage of the Raspberry PI is 3.3.v and you suggest to use a 10k resistor in my small circuit. How did you calculate this ? – r-d-r-b-3 Oct 9 '17 at 16:22
  • Basically if I wrap your answer up and translate it so I as an electronic noob can understand it ; We create a circuit with 3.3v and put a 10k resistor in it so it can not short cut, after my dry contact sends a puls for 1 sec, it closes the circuit and we see a GPIO high input because the circuit is closed. Right ? Still I wonder why we should use an initial internal pull-down resistor ? Could it be that in the past this was by hardware and we can now do this by programming ? – r-d-r-b-3 Oct 9 '17 at 16:26
  • You told me ; floating input otherwise when you are reading the sattus of the GPIO it may be in an unkown state, can;'t recognizite it as neither HIGH or LOW. I have a hard way of understanding the floating input part. – r-d-r-b-3 Oct 9 '17 at 16:33
0

It would appear the answer given in that diagram is wrong. The 10k resistor should be from the 3.3V rail to the GPIO pin. It is called a pull up resistor and it ensures the GPIO pin sits at 3.3V (logic 1) when the switch is not operated. 10k is just a common value which gives a sufficiently solid pull up without drawing excessive current when the switch closes. When the switch closes, it pulls the GPIO pin to GND (0 logic) and draws current through the 10k resistor.

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.