Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Arduino Modbus library doesn't support floats

  • Hello everybody.

    I'm using jpmzometa modbus library with mango and works like a charm, but it has a little big... issue: it doesn't support floats.

    If I make an analog read I will get a 0-1023 value and I can send it with the library but I need to make some operations in mango to convert it to the temperature, pressure,.. value.

    But sometimes 4 byte precision is needed to send or receive calculations.

    How can I make some trick to send and receive floats? Think in a network with 15 arduinos sending/receiving 10 floats each one.

    Thank you.

  • Just to confirm, this is not a Mango question, correct? I assume you would need a Modbus impl for Arduino that supports floats.

  • Yes, you're right.

    And, if somebody is listening... I would need a Modbus library for Arduino that supports floats.

    But, mlohbihler, is it possible to make a trick to use 2+2 bytes to get a 4 byte float?

    Thank you

  • I'm not sure of the capabilities in Arduino, but i suppose at the least you could get fixed decimal precision, if not floating point. If you can take a value in Arduino that is, say, a decimal(10,5), i.e. 5 orders of magnitude on each side of the decimal place. With 4 bytes you can store from 0 to 4,294,967,295, or 0 to 42,949.67296 if you divide by 100000. So, multiply the number by 100000 and store in 2 x 2 bytes. Then in Mango read the number as a 4 byte unsigned int and give it a multiplier of 0.00001. I think that should do it.

  • The problem with the library is it doesn't support 4 byte types. The writer of the library says that the canonical (and old) rtu specification doesn't support 4 byte types.

    thank you