I am working on a project automating my garage door.
The machine that operates the door provides a 24v out that is only on when the door is open (flashes while the door is moving then stays on for as long as the door stays open)
I intend to use that 24v power to let my Pi know whether the door is open or not.
I bought a step-down chip to get from 24v-> 3.3 (or 3v?) in order to intercept the signal with the pi.
This is the chip:
I need some help on how to actually connect the 3v output to my GPIOs.
With my limited knowledge, i suppose ill need to short my PI GPIO to PI GND
with a resistor to act as a pull down.
Then the stepdown's + to the pi's GPIO and the stepdown's – to the pi's GND?
Do i have it figured out correctly or am i going the wrong way?
Will a 10kΩ resistor be enough?
Thanks in advance.
Best Answer
You do not need to go through this much trouble. This is doable with dirt cheap components at a fraction of price. You can use this opto-isolated circuit:
Consider these changes in the above image:
1) 12 V is actually 24 V in your case.
2) Left GND attached to PC817 is the GND of 24 V signal. Right side GND is not connected to Left side GND. Right side GND is GND of raspberry pi. VCC is 3.3 V which comes from raspberry pi.
3) ARD_GPIO will be a gpio of pi in your case.
Working of circuit:
When door opens and you receive that 24 V signal, the optocoupler will turn ON and you will get a HIGH on your GPIO.
Once the door closes, 24 V will be cut off and you will get a LOW on your GPIO.
RC network of 390K and 0.1uF is used to smooth out the signal. You will have to modify these values to suit your requirements. A minimum of 10K resistor is advisable. You can remove the capacitor altogether. Once you remove it, it will give you a pulsating output when door is opening and will give you a solid HIGH when the door has opened. Solid LOW if door is closed.
This also keeps your pi isolated from 24 V line which is usually a good thing to do.