user81667: 
Hi professers, i am trying to read the data from DDSU666-H ( Smart metter) CHINT using modbus RTU, i only get the raw data but i don't know how to convert it to float , in the code below is about Voltage , real data is 233,4V but in the serial is like this, can some one help me to convert this one to float 233,4V, thank you so much!

 Here is my code, i get it from modbusmaster library.
/*

  RS485_HalfDuplex.pde - example using ModbusMaster library to communicate
  with EPSolar LS2024B controller using a half-duplex RS485 transceiver.

  This example is tested against an EPSolar LS2024B solar charge controller.
  See here for protocol specs:
  http://www.solar-elektro.cz/data/dokumenty/1733_modbus_protocol.pdf

  Library:: ModbusMaster
  Author:: Marius Kintel <marius at kintel dot net>

  Copyright:: 2009-2016 Doc Walker

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

#include <ModbusMaster.h>

/*!
  We're using a MAX485-compatible RS485 Transceiver.
  Rx/Tx is hooked up to the hardware serial port at 'Serial'.
  The Data Enable and Receiver Enable pins are hooked up as follows:
*/
#define MAX485_DE      50
#define MAX485_RE_NEG  52

// instantiate ModbusMaster object
ModbusMaster node;

void preTransmission()
{
  digitalWrite(MAX485_RE_NEG, 1);
  digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
}

void setup()
{
  pinMode(MAX485_RE_NEG, OUTPUT);
  pinMode(MAX485_DE, OUTPUT);
  // Init in receive mode
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);

  // Modbus communication runs at 115200 baud
  Serial1.begin(9600);
  Serial.begin(9600);

  // Modbus slave ID 1
  node.begin(12, Serial1);
  // Callbacks allow us to configure the RS485 transceiver correctly
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);
}
void loop()
{
  uint8_t i, result;
  uint16_t data[2];
  union
  {
    uint32_t j;
    float f;
  } u;
  // Read 16 registers starting at 0x3100)
  Serial.println("-----------------------");
  result = node.readHoldingRegisters(0x2000, 2);
  if (result == node.ku8MBSuccess)
  {
    for (i = 0; i < 2; i++)
    {
      data[i] = node.getResponseBuffer(i);
    }
    Serial.println(data[0]);
    Serial.println(data[1]);
    u.j = ((unsigned long)data[1] << 16 | data[0]);
    Serial.println(u.f);
  }



user7508: Seems the data sheet does not specify the endianness. Or maybe it does,
but you are not showing it. From the numbers you get, it appears that
the floats come in big-endian order, whereas your code assumes
little-endian.
Change the assignment of u.j as follows:
u.j = ((unsigned long)data[0] << 16 | data[1]);


81667: <p><a href="https://i.stack.imgur.com/3FwyI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3FwyI.png" alt="Here is the modbus register Map i find from CHINT" /></a></p>
<p>Hi professers, i am trying to read the data from DDSU666-H ( Smart metter) CHINT using modbus RTU, i only get the raw data but i don't know how to convert it to float , in the code below is about Voltage , real data is 233,4V but in the serial is like this, can some one help me to convert this one to float 233,4V, thank you so much!
<a href="https://i.stack.imgur.com/1Uwo8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Uwo8.png" alt="enter image description here" /></a></p>
<pre> Here is my code, i get it from modbusmaster library.
&#47;*

 &nbsp;RS485_HalfDuplex.pde - example using ModbusMaster library to communicate
 &nbsp;with EPSolar LS2024B controller using a half-duplex RS485 transceiver.

 &nbsp;This example is tested against an EPSolar LS2024B solar charge controller.
 &nbsp;See here for protocol specs:
 &nbsp;http:&#47;&#47;www.solar-elektro.cz&#47;data&#47;dokumenty&#47;1733_modbus_protocol.pdf

 &nbsp;Library:: ModbusMaster
 &nbsp;Author:: Marius Kintel &lt;marius at kintel dot net&gt;

 &nbsp;Copyright:: 2009-2016 Doc Walker

 &nbsp;Licensed under the Apache License, Version 2.0 (the &#34;License&#34;);
 &nbsp;you may not use this file except in compliance with the License.
 &nbsp;You may obtain a copy of the License at

 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http:&#47;&#47;www.apache.org&#47;licenses&#47;LICENSE-2.0

 &nbsp;Unless required by applicable law or agreed to in writing, software
 &nbsp;distributed under the License is distributed on an &#34;AS IS&#34; BASIS,
 &nbsp;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 &nbsp;See the License for the specific language governing permissions and
 &nbsp;limitations under the License.

*&#47;

#include &lt;<b>ModbusMaster</b>.h&gt;

&#47;*!
 &nbsp;We&#39;re using a MAX485-compatible RS485 Transceiver.
 &nbsp;Rx&#47;Tx is hooked up to the hardware serial port at &#39;Serial&#39;.
 &nbsp;The Data Enable and Receiver Enable pins are hooked up as follows:
*&#47;
#define MAX485_DE &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;50
#define MAX485_RE_NEG &nbsp;52

&#47;&#47; instantiate ModbusMaster object
<b>ModbusMaster</b> node;

void preTransmission()
{
 &nbsp;digitalWrite(MAX485_RE_NEG, 1);
 &nbsp;digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
 &nbsp;digitalWrite(MAX485_RE_NEG, 0);
 &nbsp;digitalWrite(MAX485_DE, 0);
}

void setup()
{
 &nbsp;pinMode(MAX485_RE_NEG, OUTPUT);
 &nbsp;pinMode(MAX485_DE, OUTPUT);
 &nbsp;&#47;&#47; Init in receive mode
 &nbsp;digitalWrite(MAX485_RE_NEG, 0);
 &nbsp;digitalWrite(MAX485_DE, 0);

 &nbsp;&#47;&#47; Modbus communication runs at 115200 baud
 &nbsp;<b>Serial1</b>.begin(9600);
 &nbsp;<b>Serial</b>.begin(9600);

 &nbsp;&#47;&#47; Modbus slave ID 1
 &nbsp;node.begin(12, <b>Serial1</b>);
 &nbsp;&#47;&#47; Callbacks allow us to configure the RS485 transceiver correctly
 &nbsp;node.preTransmission(preTransmission);
 &nbsp;node.postTransmission(postTransmission);
}
void loop()
{
 &nbsp;uint8_t i, result;
 &nbsp;uint16_t data[2];
 &nbsp;union
 &nbsp;{
 &nbsp;&nbsp;&nbsp;uint32_t j;
 &nbsp;&nbsp;&nbsp;float f;
 &nbsp;} u;
 &nbsp;&#47;&#47; Read 16 registers starting at 0x3100)
 &nbsp;<b>Serial</b>.println(&#34;-----------------------&#34;);
 &nbsp;result = node.readHoldingRegisters(0x2000, 2);
 &nbsp;if (result == node.ku8MBSuccess)
 &nbsp;{
 &nbsp;&nbsp;&nbsp;for (i = 0; i &lt; 2; i++)
 &nbsp;&nbsp;&nbsp;{
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data[i] = node.getResponseBuffer(i);
 &nbsp;&nbsp;&nbsp;}
 &nbsp;&nbsp;&nbsp;<b>Serial</b>.println(data[0]);
 &nbsp;&nbsp;&nbsp;<b>Serial</b>.println(data[1]);
 &nbsp;&nbsp;&nbsp;u.j = ((unsigned long)data[1] &lt;&lt; 16 | data[0]);
 &nbsp;&nbsp;&nbsp;<b>Serial</b>.println(u.f);
 &nbsp;}

</pre>
 7508: <p>Seems the data sheet does not specify the endianness. Or maybe it does,
but you are not showing it. From the numbers you get, it appears that
the floats come in big-endian order, whereas your code assumes
little-endian.</p>
<p>Change the assignment of <code>u.j</code> as follows:</p>
<pre class="lang-cpp prettyprint-override"><code>u.j = ((unsigned long)data[0] &lt;&lt; 16 | data[1]);
</code></pre>
