What´s my mistake?
I have to add the line like this? See picture below
No, not really. I don't see in your pictures what bytes were sent from the PC to the Arduino. Please add a line to the sketch that gives that out.I would also try to snoop the packets on the network with a tool like WireShark, that helps to see what's really being sent or not.
cause in the MgsModbus.cpp I found the lines:
#define DEBUG 1
Other Persons got the same problem, see https://forum.arduino.cc/index.php?topic=275752.0@pylon: You answered at this topic on Oct 31, 2014, 04:57 pm.I did the suggestion with "Remove line 18 and replace "ServerIp" in line 82 by "remSlaveIP"." but it doesn´t work.
Mb.remSlaveIP = (192,168,178,54);
Mb.remSlaveIP = IPAddress(192,168,178,54);
Serial.println("0 - print the first 12 words of the MbData space");
Serial.println(F("0 - print the first 12 words of the MbData space"));
Serial interface startedEthernet interface startedMy IP address: 192.168.178.12.address: 0Data: 1address: 1Data: 2address: 2Data: 3address: 3Data: 4address: 4Data: 5address: 5Data: 6address: 6Data: 0address: 7Data: 0address: 8Data: 0address: 9Data: 0address: 10Data: 0address: 11Data: 00 - print the first 12 words of the MbData space1 - FC 1 - read the first 5 coils from the slave and store them in the lower byte of MbData2 - FC 2 - read the first 5 discrete inputs from the slave and store them in the higer of the MbData3 - FC 3 - read the first 5 registers from the slave and store them in MbData[3..74 - FC 4 - read the first 5 input registers from the slave and store them in MbData[8..12]5 - FC 5 - write coil 0 of the slave with the bit valeu of MbData[0.0]6 - FC 6 - write register 0 of the slave with MbData7 - FC 15 - write 5 coils of the slave starting with coil 0 with GetBit(16..208 - Fc 16 - write 5 registers of the slave starting on register 0 with MbData[0..4]192.168.178.54'Here, I typed a "3" to call FC 3.connected with modbus slaveMaster request: 00.01.00.00.00.06.01.03.03.E8.00.0603.00.00.00.00.01.00recieve klaar'Here, I typed a "0" to print the words of MbData space.address: 0Data: 1address: 1Data: 2address: 2Data: 3address: 3Data: 4address: 4Data: 5address: 5Data: 6address: 6Data: 0address: 7Data: 0address: 8Data: 0address: 9Data: 0address: 10Data: 0address: 11Data: 0
I did a record with wireshark. But I don´t see a modbus telegramm (port: 502) sent by Arduino (IP: 192.168.178.012)
The bigger problem is that the library is so bad
I cannot find any documentation for your heating system regarding the modbus interface.
What ID does it use? Where do you have the register addresses from?
I guess the problem is that you connect your network using a switch and not a hub. With a switch you don't see any traffic not originating from or targeting your PC. With a smart switch you can define your PC's port as a mirroring port to see all traffic but most cheap switches don't have this option.
The answer you got from the heating system looks like it doesn't really support the ModBus protocol.
That´s true I think the modbus serial is finished, but modbus TCP isn´t.
What is with the Ethernet header, IP header, TCP header and Ethernet trailer?
No, it works. Because with the PC I get the data. See attachment, Wireshark_Aufnahme.pcapng.
Serial.println("This is just a string");
Serial.println(F("This is just a string"));
Could someone make the communication correctly?
It also wastes a lot of memory by setting the send and receive buffers very big (260 bytes) and your sketch wastes the rest by using huge strings in RAM (together more than 1.8kB is used before the sketch starts, the UNO has only 2kB)