SimpleModbus Arduino Half-duplex problem

Hi all,

I am writing here because I would like to get some help with a project of mine. I am willing to use Modbus with my Arduino Leonardo micro. I ordered some RS-485 Maxim converters wired up my Arduino and actually the protocol works on RS-232 wired directly to each other. With the master program I can send messages to the slave and the slave sends the response as it has to be. :slight_smile:

The second test was to try the communication with the RS-485 converters. When I force one Arduino to send and the other one just to receive and vice versa it does work. So I tested the communication layer works. :slight_smile:

However when I want to use the Modbus library for half-duplex communication with these converters it does not work. It looks like for me the master and the slave wants to communicate at the same time. I think because the indicator LEDs on the converter board loose their intensity a bit when the master tries to connect to the slave in the beginning. Because it is set to try 10 times after that nothing happens. I checked the resistors and all thing included on this RS-485 converter that is needed for the communication.

Have you had the same problem maybe? Or any suggestions to make it work? I tried to add delays for switching the TX enable in the code but did not help. I also checked if the one of the Arduino's maybe have a reset due to some infinite loop or too much waiting... No. If you want to take a look on the code I can copy this here later but I think the code is fine unless there is a problem with the library itself. :o :confused:

Anyway thanks in advance.

Modbus link: GitHub - angeloc/simplemodbusng: Modbus RTU Slave/Master for the Arduino Platform

RS-485 converter link: 5V MAX485 TTL To RS485 Converter Module Board Sale - Banggood USA sold out-arrival notice

Regards,
Adam Mokanszki

Meanwhile I uploaded the files. You can find them here.

ModbusMaster.ino (6.16 KB)

ModbusSlave.ino (4.02 KB)

SimpleModbusMaster.cpp (13.7 KB)

SimpleModbusMaster.h (5.9 KB)

SimpleModbusSlave.cpp (11.3 KB)

SimpleModbusSlave.h (3.53 KB)