Electrical – Help selecting zener diode and resistor values (reduce voltage to talk to raspi GPIO)

gpioraspberry pi

Hi i am trying to connect the obstruction sensors on my garage door to the GPIO pins on a raspberry pi computer so i can monitor the state.

Since the garage door sensors runs on 6v and my raspi runs on 5v i was told to use a zener diode tied to ground, and a resistor to connect it to the raspi without frying it.

Is this hardware going to do what i want safely? (drop the 6v down to 5v so i can read the signal on the Pi and do something in software when i see a state change)

thanksenter image description here

Best Answer

Raspberry Pi has 3.3V I/O, so applying 5V to a GPIO will fry it.

You could use a simple voltage divider. Two 10K resistors, for example.

Using an optoisolator such as a 4N35 would be safer, as below, because you would not need to tie the ground of the RPi together with the ground of the garage door opener.


simulate this circuit – Schematic created using CircuitLab

When the +6V (relative to the 0V) is present, the infrared LED inside the 4N35 turns on, illuminating the phototransistor and causing it to conduct, making the GPIO go low. When the +6V input is less than about 1V, the LED is off and the GPIO goes high.