// Callback function for bricklet callback private static async void BrickletCb(BrickletUVLight sender, long rawValue) { var value = CalculateValue(rawValue); _tinfluxWeatherStation.LastMeasuredUVLight = value; await _tinfluxWeatherStation.WriteToInfluxDb(SensorTyp, SensorUnit, SensorUnitName, value); }
public UVLightSensor(IPConnection ipConnection, string uid, int sensorCallbackPeriod, Station station) { _tinfluxWeatherStation = station; var bricklet = new BrickletUVLight(uid, ipConnection); // Register callback to function BrickletCb bricklet.UVLightCallback += BrickletCb; // Note: The callback is only called every "sensorCallbackPeriod" // if the value has changed since the last call! bricklet.SetUVLightCallbackPeriod(sensorCallbackPeriod); }
private static string UID = "XYZ"; // Change XYZ to the UID of your UV Light Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletUVLight uvl = new BrickletUVLight(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current UV light (unit is µW/cm²) long uvLight = uvl.GetUVLight(); Console.WriteLine("UV Light: " + uvLight + " µW/cm²"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your UV Light Bricklet static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletUVLight uvl = new BrickletUVLight(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current UV light long uvLight = uvl.GetUVLight(); Console.WriteLine("UV Light: " + uvLight / 10.0 + " mW/m²"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletUVLight uvl = new BrickletUVLight(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register UV light callback to function UVLightCB uvl.UVLightCallback += UVLightCB; // Set period for UV light callback to 1s (1000ms) // Note: The UV light callback is only called every second // if the UV light has changed since the last call! uvl.SetUVLightCallbackPeriod(1000); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletUVLight uvl = new BrickletUVLight(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get threshold callbacks with a debounce time of 10 seconds (10000ms) uvl.SetDebouncePeriod(10000); // Register UV light reached callback to function UVLightReachedCB uvl.UVLightReachedCallback += UVLightReachedCB; // Configure threshold for UV light "greater than 75 mW/m²" uvl.SetUVLightCallbackThreshold('>', 75 * 10, 0); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your UV Light Bricklet // Callback function for UV light reached callback static void UVLightReachedCB(BrickletUVLight sender, long uvLight) { Console.WriteLine("UV Light: " + uvLight / 10.0 + " mW/m²"); Console.WriteLine("UV Index > 3. Use sunscreen!"); }
private static string UID = "XYZ"; // Change XYZ to the UID of your UV Light Bricklet // Callback function for UV light callback static void UVLightCB(BrickletUVLight sender, long uvLight) { Console.WriteLine("UV Light: " + uvLight / 10.0 + " mW/m²"); }