<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Rounding sensor values]]></title><description><![CDATA[<p dir="auto">I noticed my light sensor was very sensitive and tended to report sensor values back to the gateway much more frequently than I needed. So I added an Excel Ceiling function (rounds up a number to a specified roundup value) to my sketch. For my light sensor, I was only interested in changes of light values greater than 10. So after adding the function I only get light values to the nearest 10 points, e.g., 30, 40 etc. This really cuts down on reporting of insignificant light level changes to the gateway (which would be especially important on battery power). Will provide the code if any interest.</p>
]]></description><link>https://forum.mysensors.org/topic/492/rounding-sensor-values</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 11:39:19 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/492.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Oct 2014 01:21:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Rounding sensor values on Wed, 15 Oct 2014 17:56:34 GMT]]></title><description><![CDATA[<p dir="auto">OK another try:</p>
<p dir="auto">here's the rounding (up) function, to be placed after the loop function in the sketch:</p>
<p dir="auto">int Ceiling(int input, int ceilTo)<br />
//input is the integer number to be rounded<br />
//ceilTo is the desired rounding (up) value<br />
{</p>
<pre><code>   if ((input % ceilTo) != 0) 
    {  
        return ((int)(input / ceilTo) * ceilTo) + ceilTo;  
    }  
    else  
    {  
        return (input);  
    }  
}  
</code></pre>
<p dir="auto">After the sensor input is read in the sketch, e.g. light level, insert the line</p>
<p dir="auto">lightLevel = Ceiling(lightLevel,10);</p>
<p dir="auto">Rounds all light level values upwards to the nearest 10. Depending on your rounding value, this will reduce the number of times the sensor sends an update to the gateway since updates are only sent when the value is different from the one previously sent.</p>
]]></description><link>https://forum.mysensors.org/post/5640</link><guid isPermaLink="true">https://forum.mysensors.org/post/5640</guid><dc:creator><![CDATA[Dan S.]]></dc:creator><pubDate>Wed, 15 Oct 2014 17:56:34 GMT</pubDate></item><item><title><![CDATA[Reply to Rounding sensor values on Wed, 15 Oct 2014 14:12:41 GMT]]></title><description><![CDATA[<p dir="auto">oops! found an error in my code. Will repost after thoroughly debugging this time. Sorry!</p>
]]></description><link>https://forum.mysensors.org/post/5632</link><guid isPermaLink="true">https://forum.mysensors.org/post/5632</guid><dc:creator><![CDATA[Dan S.]]></dc:creator><pubDate>Wed, 15 Oct 2014 14:12:41 GMT</pubDate></item><item><title><![CDATA[Reply to Rounding sensor values on Wed, 15 Oct 2014 01:47:48 GMT]]></title><description><![CDATA[<p dir="auto">@Dan-S. said:</p>
<blockquote>
<p dir="auto">porting of insignificant light level changes to the gateway (which would be especially important on battery power). Will provide the code if any interest.</p>
</blockquote>
<p dir="auto">Hey @Dan-S.   I would be interested in seeing the code - so yes pls!</p>
<p dir="auto">Have you seen used the MAP function in arduino?<br />
<a href="http://arduino.cc/en/reference/map" rel="nofollow ugc">http://arduino.cc/en/reference/map</a><br />
I think it might do the same as what you are wanting to do....</p>
<p dir="auto">Cheers,<br />
Greg</p>
]]></description><link>https://forum.mysensors.org/post/5609</link><guid isPermaLink="true">https://forum.mysensors.org/post/5609</guid><dc:creator><![CDATA[gregl]]></dc:creator><pubDate>Wed, 15 Oct 2014 01:47:48 GMT</pubDate></item></channel></rss>