Search code examples
asp.net-core.net-coreraspberry-piraspberry-pi3windows-10-iot-core

Can not find .create method using i2cdevice (following GrovePi samples .net core iot)


I have a GrovePi+ starter kit and followed some instructions in the manual. Sadly the GrovePi library only works for UWP app's and not for .net core app's.

Basically what I want to achieve is controlling my led light within a .net core web API. Since I can not use the given library in that application I'm following their samples for .net core apps: https://github.com/dotnet/iot/blob/master/src/devices/GrovePi/samples/Program.cs

I'm following their sample but I have the following problem :

There is not a. Create a method for I2cDevice

but in their sample, they are using a .create method

grovePi = new GrovePi(I2cDevice.Create(i2CConnectionSettings));

enter image description here

I just want to control the LEDs in a .net core web application but it's even impossible to use their samples.


Solution

  • GPIO Support for Raspberry Pi is a new feature in .net core 3.0, please see here. The GPIO packages include APIs for GPIO, SPI, I2C, and PWM devices. You need to build the app with .net core 3.0. And you need to open the sample with Visual Studio 2019, which include the target for .net core 3.0. And you can update the System.Device.Gpio package to latest version.

    enter image description here