public MeadowApp() { var bus = Device.CreateI2cBus(); tsl = new Tsl2591(bus); tsl.PowerOn(); tsl.ChangeThreshold = 10; tsl.Channel0Changed += OnLightChange; tsl.StartSampling(TimeSpan.FromSeconds(1)); while (true) { Thread.Sleep(5000); } }
/// <summary> /// Default cnstructor. /// </summary> public MeadowApp() { ConnectToNetwork().Wait(); var i2c = Device.CreateI2cBus(); _sensor = new Tsl2591(i2c); _sensor.Updated += Sensor_Updated; _adafruitLogger = new AdafruitLogger(Secrets.APIO_USER_NAME, Secrets.APIO_KEY); // // Take a new sensor reading every 30 seconds. Note that Adafruit IO has limits on the // number of readings (per minute) that can be sent to their free service. // _sensor.StartUpdating(TimeSpan.FromSeconds(30)); }
public override async Task Start() { switch (SelectedSensor) { case "BH1750": Sensor = (await Bh1750.ProbeAsync(Board.I2c))[0]; break; case "TSL2591": Sensor = await Tsl2591.ProbeAsync(Board.I2c); break; case "VCNL4010": Sensor = new Vcnl4010(Board.I2c); break; } Sensor.AutoUpdateWhenPropertyRead = false; OnPropertyChanged(nameof(Sensor)); }