static public uint OnBeforeMeasure(object sender, EventArgs e)
        {
            uint id = ((SensorBase.SensorIdEventArgs)e).id;

            if (rgb == null)
            {
                return(0);
            }
            rgb.On((RgbLed.Led)(id % 3));
            Thread.Sleep(20);
            rgb.Off((RgbLed.Led)(id % 3));
            //   rgb.Blink((RgbLed.Led)(id % 3), 50, RgbLed.BlinkRate.VeryFast);
            return(0);
        }
        private async void initialize()
        {
            controller = GpioController.GetDefault();
            resetLights();
            //IoTHub connection
            var key = AuthenticationMethodFactory.CreateAuthenticationWithRegistrySymmetricKey(Config.Default.DeviceName, Config.Default.DeviceKey);
            deviceClient = DeviceClient.Create(Config.Default.IotHubUri, key, TransportType.Http1);

            //RGB LED PWM controller
            if (ApiInformation.IsApiContractPresent("Windows.Devices.DevicesLowLevelContract", 1))
            {
                try
                {
                    //check if the GPIO exists
                    if (controller != null)
                    {
                        var provider = PwmProviderSoftware.GetPwmProvider();
                        if (provider != null)
                        {
                            var controllers = (await PwmController.GetControllersAsync(provider));
                            if (controllers != null)
                            {
                                var controller = controllers.FirstOrDefault();
                                if (controller != null)
                                {
                                    controller.SetDesiredFrequency(100);
                                    var pinR = controller.OpenPin(ledPinNumberR);
                                    var pinG = controller.OpenPin(ledPinNumberG);
                                    var pinB = controller.OpenPin(ledPinNumberB);
                                    rgbLed = new RgbLed(pinR, pinG, pinB);
                                    rgbLed.On();
                                    rgbLed.Color = Colors.White;
                                    Task.Delay(50).Wait();
                                    rgbLed.Color = Colors.Black;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }

            await receiveCommands(deviceClient);
        }