GPIO / System.Device.Gpio / RegisterCallbackForPinValueChangedEvent / Rising and Falling Continuously with circuit closed

64 views Asked by At

I have circuit associated with a value. When the circuit is closed, I know the valve is open, when the circuit is open, the value is closed.

I used this circuit to monitor pin 21

   gpioController.RegisterCallbackForPinValueChangedEvent(
       applicationConfiguration.ValveMonitoredOnGpioPin,
       PinEventTypes.Falling | PinEventTypes.Rising,
       OnPinEvent);

When the circuit closes, I would like a Rising event, and when the circuit opens, I would like a Falling.

The log is showing me this for each invocation of onPinEvent:

log

Is this normal behaviour? I have a power step down, which drops the voltage from 9V battery, to 3.3V. How would I determine if this is the root cause, and the multi-meter shows a steady 3.3 (or the drop cadence of rise and fall is too fast)?

I could throttle the events, but I need to know when the value opens, and when it closes, and throttling could only give me the last event over a period of time.

I'm using the Iot.Device.Bindings V3.1.0. My hardware is a Raspberry PI, running x64 Linux

#4 [internal] load metadata for mcr.microsoft.com/dotnet/runtime:8.0.0-bookworm-slim-arm64v8
#4 DONE 0.6s
#5 [stage-1 1/4] FROM mcr.microsoft.com/dotnet/runtime:8.0.0-bookworm-slim-arm64v8@sha256:e27430698f71060810be0e1ff6632d80748d4aaa20466d3371c6191981a32a36
#5 DONE 0.0s
#6 [build-env  1/10] FROM mcr.microsoft.com/dotnet/sdk:8.0@sha256:0b4b20f78ab869a9fa6a8496053b4e2cb7339b8f748775c8c502f8eb7f2d8576(
0

There are 0 answers