I'm planning on making an alarm for my back door that will sound if I leave it ajar, as often happens. I want to use a Raspberry Pi so I can keep it modular and customizable, so I need to use the pins of a USB to detect if it's open. I'm planning on simply breaking a circuit when I open the door and completing it when it's closed. Attached is my rough plan.
The brown are metal contacts that will touch when the door is closed. 1 will go to data. There should be positive voltage at that point because there's a resistor before 2, Ground. 3 is the USB's power supply, +5V. I'll put a large resistor after it to avoid unnecessary power usage.
Will this work? Hopefully, it'll be a clear difference between 0V (open door) and some positive amount, depending on my resistors. I am concerned that USB is entirely digital. Can I choose some voltage that the Raspberry Pi will read as ON?
Also, on the other side, I'm going to use a data channel from the second USB to enable a transistor, activating a speaker. What do I do with that USB's GND pin?
The brown are metal contacts that will touch when the door is closed. 1 will go to data. There should be positive voltage at that point because there's a resistor before 2, Ground. 3 is the USB's power supply, +5V. I'll put a large resistor after it to avoid unnecessary power usage.
Will this work? Hopefully, it'll be a clear difference between 0V (open door) and some positive amount, depending on my resistors. I am concerned that USB is entirely digital. Can I choose some voltage that the Raspberry Pi will read as ON?
Also, on the other side, I'm going to use a data channel from the second USB to enable a transistor, activating a speaker. What do I do with that USB's GND pin?
Attachments
-
4.9 KB Views: 1