This sample demonstrates how to communicate with an I2c device using the Micorosot.IoT.Providers.Lightning.I2cProvider.
It is based on the Weather Station sample and shares the same setup steps and most of the code.
The original sample used the default I2C provider for obtaining the I2C sensor device as follows:
The sample code using the default I2C provider, Weather Station sample.
Now, to enable the use of the Lightning provider, the I2C initialization code needs to be modified to set the Lightning provider as the default provider.
In the initialization code below, if the Lightning driver is enabled on the target device, the Lightning provider will be used. Otherwise, the app falls back to using the default provider.
Enable Lightning on your Raspberry Pi2 or MBM device using the the steps outlined in the Lightning Setup Guide.
Ensure the correct version of the Windows SDK is installed on your development machine. The required Windows SDK can be installed from here.
Clone the source for the WeatherStation sample for Lightning from Github to a local folder.
To setup the connections between the device and the weather shield, refer to the original sample.
Load the solution in Visual Studio.
Select “Weather Station (Universal Windows)” as the Startup Project.
Build the app.
Press F5 to run and deploy the app to your device.
You can use the Deploying an App with Visual Studio for guidance.
Open the Debug Output pane in Visual Studio (Debug->Windows->Output) and you should be able to watch the sensor data as it’s being read by your application.