<div class="highlight highlight-source-c++" style="box-sizing: border-box; margin-bottom: 16px; background-color: #ffffff; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; overflow: visible !important;">
   <pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace; font-size: 11.9px; margin-top: 0px; margin-bottom: 0px; overflow-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: #f6f8fa; border-radius: 3px; word-break: normal;"><span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> get float values from DHT sensor</span><span class="pl-k" style="box-sizing: border-box; color: #d73a49;">float</span> temperature = dht.getTemperature();
<span class="pl-k" style="box-sizing: border-box; color: #d73a49;">float</span> humidity = dht.getHumidity();
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> convert float value into 16 bit integer value (LSB first MSB last)</span><span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">uint8_t</span> tempData[<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">2</span>];
<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">uint16_t</span> tempValue;
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> multiply by 100 to get 2 digits mantissa and convert into uint16_t</span>
tempValue = (<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">uint16_t</span>)(temperature *<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">100</span>);
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> set  LSB of characteristic</span>
tempData[<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">0</span>] = tempValue;
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> set MSB of characteristic</span>
tempData[<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">1</span>] = tempValue&gt;&gt;<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">8</span>;
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> set characteristic value</span>
pCharacteristicTemp-&gt;<span class="pl-en" style="box-sizing: border-box; color: #6f42c1;">setValue</span>(tempData, <span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">2</span>);
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> convert float value into 16 bit integer value (LSB first MSB last)</span><span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> multiply by 100 to get 2 digits mantissa and convert into uint16_t</span>
tempValue = (<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">uint16_t</span>)(humidity *<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">100</span>);
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> set  LSB of characteristic</span>
tempData[<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">0</span>] = tempValue;
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> set MSB of characteristic</span>
tempData[<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">1</span>] = tempValue&gt;&gt;<span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">8</span>;
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> set characteristic value</span>
pCharacteristicHumid-&gt;<span class="pl-en" style="box-sizing: border-box; color: #6f42c1;">setValue</span>(tempData, <span class="pl-c1" style="box-sizing: border-box; color: #005cc5;">2</span>);
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> notify client about new temperature value</span>
pCharacteristicTemp-&gt;<span class="pl-en" style="box-sizing: border-box; color: #6f42c1;">notify</span>();
<span class="pl-c" style="box-sizing: border-box; color: #6a737d;"><span class="pl-c" style="box-sizing: border-box;">//</span> notify client about new humidity value</span>
pCharacteristicHumid-&gt;<span class="pl-en" style="box-sizing: border-box; color: #6f42c1;">notify</span>();</pre>
   </div>
<p style="box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; background-color: #ffffff;">I use this in my&nbsp;<a href="https://github.com/beegee-tokyo/ESP32-Weatherstation/blob/master/src/temperature.cpp" style="box-sizing: border-box; background-color: initial; color: #0366d6; text-decoration-line: none;" target="_blank">ESP32 Weatherstation</a>&nbsp;application</p>