1

i'm using ModbusMaster library (Repo) to read from a device some registers.

Many of them are float and i've no problem to read them using the following code:

  //for float conversation
  union
    {
      uint32_t i;
      float f;
    }u;
    uint8_t result = node.readInputRegisters(address, 2); // for 3000xx registers
    Serial.println("Result : " + String(result));// to get error type
    if (result == node.ku8MBSuccess)
    {       
         u.i=(((unsigned long)node.getResponseBuffer(0x01)<<16) | (node.getResponseBuffer(0x00)));// shifting 2nd register to left & stiching with 1st register
    }
    Serial.println("Reading is "+String(u.f));

But i have the energy registers that are 64 Bit unsigned int and i can't figure out how to adapt the above code in order to read them.

Anyone has a solution?

1
  • 1
    64bit must be stored in two registers. so (r1 << 32) | r2 or (r2 << 32) | r1 Commented Jun 5, 2020 at 16:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.