Ejemplo n.º 1
0
        // Callback function for bricklet callback
        private static async void BrickletCb(BrickletMoisture sender, int rawValue)
        {
            var value = CalculateValue(rawValue);

            _tinfluxWeatherStation.LastMeasuredMoisture = value;
            await _tinfluxWeatherStation.WriteToInfluxDb(SensorTyp, SensorUnit, SensorUnitName, value);
        }
Ejemplo n.º 2
0
        public MoistureSensor(IPConnection ipConnection, string uid, int sensorCallbackPeriod, Station station)
        {
            _tinfluxWeatherStation = station;
            var bricklet = new BrickletMoisture(uid, ipConnection);

            // Register callback to function BrickletCb
            bricklet.MoistureCallback += BrickletCb;

            // Note: The callback is only called every "sensorCallbackPeriod"
            // if the value has changed since the last call!
            bricklet.SetMoistureCallbackPeriod(sensorCallbackPeriod);
        }
Ejemplo n.º 3
0
    private static string UID = "XYZ"; // Change XYZ to the UID of your Moisture Bricklet

    #endregion Fields

    #region Methods

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

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

        // Get current moisture value
        int moisture = m.GetMoistureValue();
        Console.WriteLine("Moisture Value: " + moisture);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
    private static string UID = "XYZ"; // Change XYZ to the UID of your Moisture Bricklet

    #endregion Fields

    #region Methods

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

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

        // Register moisture value callback to function MoistureCB
        m.Moisture += MoistureCB;

        // Set period for moisture value callback to 1s (1000ms)
        // Note: The moisture value callback is only called every second
        //       if the moisture value has changed since the last call!
        m.SetMoistureCallbackPeriod(1000);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
    private static string UID = "XYZ"; // Change XYZ to the UID of your Moisture Bricklet

    #endregion Fields

    #region Methods

    static void Main()
    {
        IPConnection ipcon = new IPConnection(); // Create IP connection
        BrickletMoisture m = new BrickletMoisture(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 1 second (1000ms)
        m.SetDebouncePeriod(1000);

        // Register moisture value reached callback to function MoistureReachedCB
        m.MoistureReached += MoistureReachedCB;

        // Configure threshold for moisture value "greater than 200"
        m.SetMoistureCallbackThreshold('>', 200, 0);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
 // Callback function for moisture value reached callback
 static void MoistureReachedCB(BrickletMoisture sender, int moisture)
 {
     Console.WriteLine("Moisture Value: " + moisture);
 }