private static string UID = "XYZ"; // Change XYZ to the UID of your PTC Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletPTCV2 ptc = new BrickletPTCV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current temperature int temperature = ptc.GetTemperature(); Console.WriteLine("Temperature: " + temperature / 100.0 + " °C"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletPTCV2 ptc = new BrickletPTCV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register temperature callback to function TemperatureCB ptc.TemperatureCallback += TemperatureCB; // Set period for temperature callback to 1s (1000ms) without a threshold ptc.SetTemperatureCallbackConfiguration(1000, false, 'x', 0, 0); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your PTC Bricklet 2.0 // Callback function for temperature callback static void TemperatureCB(BrickletPTCV2 sender, int temperature) { Console.WriteLine("Temperature: " + temperature / 100.0 + " °C"); }