Beispiel #1
0
        public override async Task Start()
        {
            switch (SelectedSensor)
            {
            case "LM75":
                Sensor = new Lm75(Board.I2c);
                break;

            case "DS18B20":
                Sensor = new Ds18b20(Board.Uart);
                break;

            case "MCP9808":
                Sensor = new Mcp9808(Board.I2c);
                break;

            case "MLX90614":
                var mlx90614 = new Mlx90614(Board.I2c);
                Sensor = mlx90614.Object;
                break;

            case "MLX90615":
                var mlx90615 = new Mlx90615(Board.I2c);
                Sensor = mlx90615.Object;
                break;
            }

            Sensor.AutoUpdateWhenPropertyRead = false;
            OnPropertyChanged(nameof(Sensor));
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            I2cConnectionSettings settings  = new I2cConnectionSettings(1, Mlx90614.DefaultI2cAddress);
            I2cDevice             i2cDevice = I2cDevice.Create(settings);

            using (Mlx90614 sensor = new Mlx90614(i2cDevice))
            {
                while (true)
                {
                    Console.WriteLine($"Ambient: {sensor.ReadAmbientTemperature().Celsius} ℃");
                    Console.WriteLine($"Object: {sensor.ReadObjectTemperature().Celsius} ℃");
                    Console.WriteLine();

                    Thread.Sleep(1000);
                }
            }
        }
Beispiel #3
0
        static async Task Main(string[] args)
        {
            var ft232Device = FT232HDetector.Detect();

            if (ft232Device.Ok)
            {
                Console.WriteLine(ft232Device.ToString());
            }
            else
            {
                throw new Exception("Could not find a device");
            }

            var i2cDevice = new GpioI2CDevice(new I2C_CHANNEL_CONFIG
            {
                ClockRate    = I2C_CLOCKRATE.I2C_CLOCK_FAST_MODE,
                LatencyTimer = 1
            }, channelIndex: 0);

            try
            {
                var gpios = i2cDevice.GPIO;
                await Blink(gpios, 4, 5, 250);

                var tempSensor = new Mlx90614(i2cDevice, 0x2A)
                {
                    TempInF = true
                };

                // Trying to figure out sane values for these:
                gsensor.SetGestureThreshold(0x30, 0x20, 0b11);
                gsensor.SetGainAndIrIntensity(0b11 /* Full Gain */, 0b11 /* Full Intensity */);

                do
                {
                    while (!gsensor.GestureAvailable())
                    {
                        //byte status = await gsensor.ReadStatus();
                        //byte gstatus = await gsensor.ReadGestureStatus();
                        //Debug.WriteLine($"Status: {status.ToString("X")}; GStatus: {gstatus.ToString("X")}");
                        await Task.Delay(10);
                    }

                    //Console.WriteLine("Gesture is available!");
                    //byte[] data = await gsensor.ReadAvailableGestureData();
                    //string hexstring = BytesToHexString(data);
                    //WriteLine($"Gesture Data:\n{hexstring}");

                    var result = await gsensor.ReadGesture();

                    WriteLine(result);

                    //await Task.Delay(1000);
                    //Read(i2cDevice).Wait();
                } while (true);
                //try
                //{
                //	await tempSensor.SetAddress(0x2A);
                //}
                //catch { }

                var temperatures = new List <string>();

                for (int i = 0; i < 100; i++)
                {
                    var ambientTemp = await tempSensor.ReadAmbientTemperature();

                    var objectTemp = await tempSensor.ReadObjectTemperature();

                    Console.WriteLine($"Ambient: {ambientTemp}, Object: {objectTemp}");
                    temperatures.Add($"Ambient: {ambientTemp}, Object: {objectTemp}");

                    await Task.Delay(1000);
                }
            }
            catch (Exception e)
            {
                WriteLine(e);
            }
            WriteLine("Press any key to exit...");
            Console.Read();
        }