private static string UID = "XYZ"; // Change XYZ to the UID of your Thermocouple Bricklet

    #endregion Fields

    #region Methods

    static void Main()
    {
        IPConnection ipcon = new IPConnection(); // Create IP connection
        BrickletThermocouple t = new BrickletThermocouple(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT); // Connect to brickd
        // Don't use device before ipcon is connected

        // Get current temperature (unit is °C/100)
        int temperature = t.GetTemperature();
        Console.WriteLine("Temperature: " + temperature/100.0 + " °C");

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
        /// <summary>
        /// Ruft die aktuelle Wassertemperatur ab
        /// </summary>
        /// <returns>Temperatur in C</returns>
        internal static double GetCurrentTemperature()
        {
            try
            {
                IPConnection         ipcon = new IPConnection();                       // Create IP connection
                BrickletThermocouple t     = new BrickletThermocouple(UID_TCB, ipcon); // Create device object
                ipcon.Connect(HOST, PORT);
                int temperature = t.GetTemperature();

                ipcon.Disconnect();
                return(temperature / 100.0);
            }
            catch (Exception ex)
            {
                throw new Exception("Fehler beim Auslesen der Temperatur", ex);
            }
        }
Esempio n. 3
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your Thermocouple Bricklet

    static void Main()
    {
        IPConnection         ipcon = new IPConnection();                   // Create IP connection
        BrickletThermocouple t     = new BrickletThermocouple(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 = t.GetTemperature();

        Console.WriteLine("Temperature: " + temperature / 100.0 + " °C");

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }