Does .Net Core 3.1 have an event driven method of detecting GPIO pin changes?

535 Views Asked by At

I'm creating a .Net Core 3.1 console app to read to and write from GPIO pins on an Orange Pi Zero (similar to a Raspberry Pi Zero). It is running Armbian Focal (Ubuntu). I'm using .Net Core's System.Device.Gpio library.

I have managed to get the reading to and writing from the GPIO pins working - no problem. But the way I am reading the pins is by doing a gpioController.Read() inside a loop. I was wondering if System.Device.Gpio has an event driven method of reading a GPIO pin? In other words, if a pin goes from high to low, or low to high, that an event - let's call it "gpioPinStateChanged" - is triggered. Is there such a thing?

I know I could create my own even notification system, but I was wondering if .Net Core perhaps had something built in? I've looked at a dozen code samples, and none of them have anything like that, so I'm guessing there isn't...

Thanks

1

There are 1 best solutions below

1
On

Following 0andriy's comments, I saw that you can indeed register events to detect GPIO pin state changes. Thanks to his post, I also found another great post of someone doing the same. He uses GPIO pin change events to calculate the RPM of a fan. http://blog.timwheeler.io/building-a-pwm-fan-controller-with-dotnet-iot/