Closed LongingIngernot closed 8 months ago
Hi @LongingIngernot
What's your wiring diagram?
Sounds like the pin is floating and not set to a defined level when the contact is open.
Do you use a pulldown resistor like in this diagram?
I have it wired to pin 26 and to GND, though I don't have a resistor
Then the pin is floating when the contact is open.
Use a pull-down resistor and change the wiring as shown in the diagram.
Also, can I use a switch device/example to toggle a garage door(acting as momentary) or should I the garage door example?
For this, I recommend using a garage door device. Alexa, for example, has an additional PIN query (for security) that you don't have with a normal switch device.
How would I set it up? Also, could I include a contact sensor with it?
How would I set it up?
This question cannot be answered in general terms and depends on several factors (e.g. the electronics that drive your garage door).
Also, could I include a contact sensor with it?
I recommend using a contact sensor to determine the position of the door (open or closed).
I fixed the floating pin by using the pinMode(CONTACT_PIN, INPUT_PULLUP);
function but Sinric Pro displays the opposite of the state, i.e.when it's open it shows closed on Sinric and vice-versa.
Also, can I integrate a contact sensor in the garage tile/device?
Simply invert the reading by adding a !
in front of digitalRead
it like so:
bool contactState = !digitalRead(CONTACT_PIN);
Also, can I integrate a contact sensor in the garage tile/device?
Yes, but without knowing more about your hardware, wiring, code, etc., these types of questions are too general to answer. This issue is about how to use a reed switch. I propose to open a new issue with detailed information and specific questions.
Hello! I am trying to use an esp32 board to monitor a door's state. The problem is that the reed switch, while contacts are close, it's not doing anything and while they're distant it's constantly fluctuating between open and close.