The Device Network
Your IP Address is:


  • How to skip repeated parameter values?

    Posted on Tue November 27, 2012

    to make your sketch more professional

    The sensors which we use in our Arduino projects often sends the same value. For example a temperature sensor can sends the same value in a few hours because the temperature does not change.


    So we always send the same values​​, we spend traffic on local network and the Internet. Using of controller and server resources are not economical in this mode. We fill the database with unnecessary values.

    There is a simple solution of this problem. We have subclass KSduinoParameter in KSduino library. This class help us to send unique values only.

    KSduinoParameter class constructor has parameters ‘accuracy’ and ‘repeat time’. With this parameters we can set accuracy of sending parameter. For example our sensor sends not unic but similar values: 2.31, 2.32, 2.33, 2.31 and we don’t like to send this similar values to server. To do this we can set ‘accuracy’ value to 0.05 and KSduino library will send values which different to 0.05 or -0.05.

    On the other hand, we need to send at least one value per hour then KSduino calculate our hours average values. For this case we can use the ‘repeat time’ parameter of KSduinoParameter class. Set it to 15*60 and your device will send value every 15 minute despite the fact that the value ​​have not changed.

    KSduinoParameter i3 (&ksd, "i1", 0.05, 15*60);

    So if we set parameter accuracy to 0.05 and repeat time to 15*60 then we will send only changed to 0.05 values and one value after 15 min of omission period.

    The KSduinoParameter class is described at Documentation:

    And demonstated in KSduino library examples. See the simple_06 example:

    Switch the ‘Online parameter’ off at the Edit device parameter page for parameter which uses KSduinoParameter class.


    The parameters online circle will be yellow when we are waiting value, green when we are receiving value and gray if device is offline.

  • comments powered by Disqus
Created with KSNews


Copyright © 2012-2013, The KSduino Project