Sorry to disturb the community.
But I am in trouble w/ my OPTA Wifi module and RS485 MODBUS
Indeed, randomly, and following the request sent by through ModbusRTUClient.requestFrom function, the CRC calculated is bad (I add a sniffer into the technical chain in order to check all the RS485 data, reason why I can see it).
Of course, I use the lastest ArduinoRS485 (V1.1.0) & ArduinoModbus (V1.0.9).
To be clear, and for example, here is some requests (correct and bad) sent from OPTA module to add-on :
01 03 00 04 00 01 C5 CB => correct CRC
02 03 00 04 00 01 C5 F8 => correct CRC
03 03 00 04 00 01 C4 E9 => bad CRC ! Must be C4 29
04 03 00 04 00 01 C5 DE => bad CRC ! Must be C5 9E
05 03 00 04 00 01 C4 CF => bad CRC ! Must be C4 4F
06 03 00 04 00 01 C4 FC => bad CRC ! Must be C4 7C
07 03 00 04 00 01 C5 ED => bad CRC ! Must be C5 AD
08 03 00 04 00 01 C5 D2 => bad CRC ! Must be C5 52
09 03 00 04 00 01 C4 C3 => bad CRC ! Must be C4 83
0A 03 00 04 00 01 C4 F0 => bad CRC ! Must be C4 B0
0B 03 00 04 00 01 C5 E1 => bad CRC ! Must be C5 61
0C 03 00 04 00 01 C4 D6 => correct CRC
0D 03 00 04 00 01 C5 C7 => bad CRC ! Must be C5 07
0E 03 00 04 00 01 C5 F4 => bad CRC ! Must be C5 34
and so on...
Has anyone ever seen this case ?
Please, if someone can help me, it will be w/ pleasure
Thanks for your message.
When I wrote randomly, I mean that CRC is well calculated for ID 0x01, 0x02 and 0x0C. And therefore, the add-ons answer correctly.
For the rest of ID, the CRC is not conform => no answer from add-ons.
Reason why I think that there is a pb w/ ArduinoModbus library and ModbusRTUClient.requestFrom function.
So, the CRC error is not random, but consistently incorrect with certain messages.
This calculator agrees with what you posted: Online CRC-8 CRC-16 CRC-32 Calculator
That suggests a problem with the library code, and you should post an issue on the Github site for the library.
Yes, I use this calculator in CRC-16/MODBUS (but not only) to check the CRC result.
Thanks for your advise. I will do that.
Nevertheless, it is very surprising that I didn’t find others topics w/ the same issue.
I imagine that I am not alone to use this library ! There is a lot of example using it.
To be frank I am perplex !
You learned about the problem because the peripheral actually checks the CRC code. It is possible that other peripherals do not perform that check, and no one has noticed.
Yes, you can see it w/ my initial post.
It is the data sent from
OPTA by throught ModbusRTUClient.requestFrom function recorded by the snifer.
And when the CRC is correct, the add ons / sensors answer well.
Indeed, after quick compare, the tables of CRC values are the sames.
At the end of project, not a lot. Only 5x nodes.
But one of sensors was in address 0x04. And after few mn of debug, I saw that the CRC was not conform than expected => no response from it.
Reason why I did a testing w/ more ID to check if it was an isolated cas w/ ID 0x04 or a true issue. And the result ....
I just found the issue !
It is a pb w/ the delay from ArduinoRS485 library and not ArduinoModbus library in conjunction w/ OPTA hardware ! Sorry for the confusion !
the responses of the sensors are truncatured => not conform. I think that it is too low,
Therefore, I adapted the delays to 500. I mean :
RS485.setDelays(500, 500);
And the responses of the sensors were goods but not for all the ID as wrote in my initial post !
This morning, I redid a lot of testing. And I modified the delays to 1000. I mean :
RS485.setDelays(1000, 1000);
And the responses for all the ID sensors are goods
Once again, sorry for the confusion.
But I think that we need to find a compromise between the hardware master and the sensors in order to all works well. It can be a little bit complicated for certain case !