<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How do I send an unsigned float over the air as a characteristic value?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3482/how-do-i-send-an-unsigned-float-over-the-air-as-a-characteristic-value</link><description>I have a vendor specific characteristic for the battery voltage in my device, expressed as an actual voltage rather than a percentage. Values are 0.000V to about 4.300V and I need millivolt precision. My voltage variable is simply: 
 #include &amp;lt;float</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Aug 2014 12:33:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3482/how-do-i-send-an-unsigned-float-over-the-air-as-a-characteristic-value" /><item><title>RE: How do I send an unsigned float over the air as a characteristic value?</title><link>https://devzone.nordicsemi.com/thread/12613?ContentTypeID=1</link><pubDate>Thu, 14 Aug 2014 12:33:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:569321f3-4636-4c41-b9a8-545586f7420f</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Works perfectly! Thanks Pål.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I send an unsigned float over the air as a characteristic value?</title><link>https://devzone.nordicsemi.com/thread/12612?ContentTypeID=1</link><pubDate>Thu, 14 Aug 2014 11:43:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c42ce93-d408-4cbc-a230-a348273228b8</guid><dc:creator>P&amp;#229;l H&amp;#229;land</dc:creator><description>&lt;p&gt;What about this one?&lt;/p&gt;
&lt;p&gt;&lt;a href="http://stackoverflow.com/questions/13469681/how-to-convert-4-bytes-array-to-float-in-java"&gt;stackoverflow.com/.../how-to-convert-4-bytes-array-to-float-in-java&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;byte[] bytes = { };
float f = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getFloat();
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I send an unsigned float over the air as a characteristic value?</title><link>https://devzone.nordicsemi.com/thread/12611?ContentTypeID=1</link><pubDate>Thu, 14 Aug 2014 11:43:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f57c6db-0c19-4275-8a30-1abb9303f77a</guid><dc:creator>Knut Eldhuset</dc:creator><description>&lt;p&gt;The byte order could be different from what the Android app expects. A quick test with Python:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; import struct
&amp;gt;&amp;gt;&amp;gt; struct.unpack_from(&amp;quot;f&amp;quot;, &amp;quot;\00\80\89\40&amp;quot;)
(6.706954991386738e-10,)
&amp;gt;&amp;gt;&amp;gt; struct.unpack_from(&amp;quot;f&amp;quot;, &amp;quot;\40\89\80\00&amp;quot;)
(0.0001758192665874958,)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which is correct?&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>