Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3771

Troubleshooting • Pi 5 with PI4J detecting an external relay closure

$
0
0
I have a Raspberry Pi5 running Debian 6.6.62 running a Java (Spring Boot) application using Java 17 and the PI4J library version 2.7.0.

I want to connect a digital input on the board to the NO (normally open) "alarm" contacts on my home alarm panel. When I check the alarm panel contacts with an Ohm meter, I see the contacts are normally open and when the alarm is triggered, they close and stay closed until the alarm is reset.

I have the alarm contacts wired to the Pi's 40-pin header as follows:

Code:

    PIN                                         Connector       Alarm Panel    ----------------------------------------------------------------------------------------------                                    R=1K Ohms     18 (GPIO 24) -----------------\/\/\/\/-------- >   >------ 32     17 (3.3V) ------------------------------------ >   >------ 33
I create the digital input using this:

Code:

DigitalInputConfigBuilder diAlarmConfig = DigitalInput.newConfigBuilder(PiAlarmMonitorApplication.pi4j).id("alarm").name("Alarm").address(GPIO_INPUT_ALARM).pull(PullResistance.PULL_DOWN).debounce(debounceTime);DigitalInput diAlarm = PiAlarmMonitorApplication.pi4j.create(diAlarmConfig);
I then add a listener using this:

Code:

diAlarm.addListener(e -> {if (e.state() == DigitalState.HIGH) {logger.debug("Alarm circuit tripped!");} else {logger.debug("Alarm circuit reset.");}});
The problem I'm having is that when I connect bare wires in place of the alarm panel contacts (such that the 1K resister is still in the circuit), the listener works as expected. When the contact is closed, the listener returns a state of High and when I release the contact the listener returns a state of LOW.

When I connect it to the alarm panel relay contacts, it goes crazy. When I trigger the alarm, I get hundreds of High/Low transitions within a very short period of time (just a few seconds).

I tried increasing the debounce time to 5 seconds (specified in microseconds, according to the documentation) and this prevented the false triggers, but the event with a state of Low didn't arrive until I disconnected the pi from the alarm panel.

I'm assuming the problem is with the relay used on the alarm panel. Is there something different I can do with the circuit to cause it to be more tolerant of this alarm panel's relay?

Perhaps I can wire up another relay, external to the panel, driven by the panel's contacts, but I think without some type of buffer circuit, it will just flip back/forth as well.

Statistics: Posted by MarkEHansen — Thu Jan 02, 2025 12:49 am



Viewing all articles
Browse latest Browse all 3771

Trending Articles