RS-485 modbus library

Thank you for the suggestion. I have my data publishing to the cloud properly now. I am still just having issues with the data type. When I return a hex value it is “4A53” and the decimal is “19027”. The data is apparently being stored as a weird float16 number, and when I run the hex number through a float16 converter provided by the manufacture of the slave device, I get the proper result of “12.6484” which in this case refers to battery voltage. Any ideas how I can make this conversion happen inside of my code? I would rather fill my database with the already converted value than the hex value.

You can try this library for a C++ implementation of half-precission float (aka float16)

I also think there is a ModBus lib floating around in this forum that features float16 functions already.

Thank you sir, I’ve been wrestling with this all day and will hopefully get it to compile with the modbus master library for the electron. I had yet to dabble with compiling in visual studio so it’s been yet another learning experience. In the meantime if you come across that library containing float16 functions you might save me from a late night…

A post was merged into an existing topic: Particle ModbusMaster Library with two slaves

@luisgcu did you ever figure out in code where that 2ms delay was?

I’m trying out the SensorModbusMaster library for the first time today and ran into a compiler problem in Workbench. Line 612 of SensorModbusMaster.cpp reads:

int bytesRead = _stream->readBytes(responseBuffer, 135);

When trying to compile I get this error:

error: invalid conversion from 'byte* {aka unsigned char*}' to 'char*'

EDIT: fixed by changing line 612 to:

int bytesRead = _stream->readBytes((char *)responseBuffer, 135);

Still curious about the 2ms delay though. :wink:

1 Like

hi @fishmastaflex you can use these library that we forked from SensorModbusMaster and made the right corrections to work with esp32 and Particle Photon.
ModbusLibrary1
Modbus library 2

I downloaded the git and pushed it as a private library and am getting a weird compiling issue for the boron. Any experience? Was using another library and having to write out basically this library from it.

Why not just post the message?

1 Like

I was wondering specifically what they changed to make the library compile, RS-485 modbus library was the solution.

However there seem to be some issues with it shifting my bits a bit, guessing due to whatever is built in to what it does for rs485, when I’m using strict ttu serial