smarmengol / Modbus-Master-Slave-for-Arduino

Modbus Master-Slave library for Arduino
GNU Lesser General Public License v2.1
473 stars 328 forks source link

float type data #55

Closed aasirmutwalli22 closed 2 years ago

aasirmutwalli22 commented 4 years ago

What I have to do if float array is needed to poll

uint16_t modbus_array[] = {3,2,3.2}; bus.poll(modbus_array, sizeof(modbus_array) / sizeof(modbus_array[0]));

ulkersinan commented 3 years ago

you can multiply 10 or 100 Ex: dht temp value 10.25 -->> *100 = sending value on array :1025 And divide 100 after communication and convert float again while printing. -->> 1025/100 = 10.25

PS: Sorry for my bad english.

githubShuaiGe commented 2 years ago

Is there any other way

arthurtaras commented 2 years ago

@githubShuaiGe It is a bad idea to use floats with voltages and money so I don't think they have a place in this library. You can store a dividend integer in one register and a divisor integer in another (10, 100, 1000, etc.). You can retrieve both registers at the same time and convert into decimal closer to the user interface where you will have more computing power and lower cost of error.