Hi,
How could I read a single Byte with the ModbusMaster function? So far I have only been able to make readings of floating numbers.
Hi Nanopo,
To read is a single Modbus register use the "ModbusOption" parameter to indicate if it is a 16-bit signed integer (1) or a 16-bit unsigned integer (3). The variable array the data is to be stored in will need to be declared as "Long". The "Length" paramater can be set to 1 for a single register.
Since a Modbus register is made up of two bytes (16-bit) then you will need to manipulate the data after it is received. To split a single Modbus register into two bytes you can perform the following operation:
Public register As Long Public high_byte As Long Public low_byte As Long high_byte = (register AND &HFF00) >> 8 low_byte = register AND &H00FF
It was very useful, thank you.