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
      uint32_t i;
      float f;
    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
    64bit must be stored in two registers. so (r1 << 32) | r2 or (r2 << 32) | r1
    – Juraj
    Jun 5, 2020 at 16:51


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.