Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to open a handle to the device when opening GPIO pin

Everytime I open a GPIO pin I get this exception:

WinRT information: Failed to open a handle to the device.
A resource required for this operation is disabled.

I can't seem to find much information for this on the internet. Probably because UAP is still in a preview. And I don't think something is wrong with my code, it is almost the same one from the Blink example:

GpioController gpio = GpioController.GetDefault();
if (gpio != null)
{
    var ledpin = gpio.OpenPin(11);
    ledpin.Write(_light ? GpioPinValue.High : GpioPinValue.Low);
    ledpin.SetDriveMode(GpioPinDriveMode.Output);
}
like image 876
Arn Vanhoutte Avatar asked Jun 01 '15 17:06

Arn Vanhoutte


People also ask

How do I find my GPIO pin number?

The Linux GPIO number for a certain GPIO pin can be determined by adding the GPIO pin index to the port base index. For instance: i. MX6 GPIO2_4 (port 2, pin 4) is: 32 + 4 = 36.

What is GPIO pin?

A GPIO pin is a generic pin whose value consists of one of two voltage settings (high or low) and whose behavior can be programmed through software. A GPIO port is a platform-defined grouping of GPIO pins (often 4 or more pins).


1 Answers

Only a subset of pins are available to usermode. Most pins are reserved by the system and cannot be accessed from usermode.

As far as I know pin 11 is not available. Try pin 12 or 13.

List of available Pins:

GPIO#   Power-on Pull   Header Pin
4       PullUp           7
5       PullUp          29
6       PullUp          31
12      PullDown        32
13      PullDown        33
16      PullDown        36
17      PullDown        11
18      PullDown        12
19      PullDown        35
20      PullDown        38
21      PullDown        40
22      PullDown        15
23      PullDown        16
24      PullDown        18
25      PullDown        22
26      PullDown        37
27      PullDown        13
35      PullUp          Red Power LED
47      PullUp          Green Activity LED

Pi2 layout

Edit: Added missing GPIOs

like image 136
S.Spieker Avatar answered Oct 06 '22 00:10

S.Spieker