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

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

        // Set Period for air pressure and altitude callbacks to 1s (1000ms)
        // Note: The air pressure and altitude callbacks are only called every second
        //       if the air pressure or altitude has changed since the last call!
        b.SetAirPressureCallbackPeriod(1000);
        b.SetAltitudeCallbackPeriod(1000);

        // Register air pressure callback to function AirPressureCB
        b.AirPressure += AirPressureCB;

        // Register altitude callback to function AltitudeCB
        b.Altitude += AltitudeCB;

        System.Console.WriteLine("Press key to exit");
        System.Console.ReadKey();
    }