Closed Invi0 closed 9 months ago
I just tested this library on an Arduino Leonardo and an Arduino Mega 2560, and didn't encounter any problems. I'm going to need some more information to be able to help you.
I'm using your sample code with buttons and buttons for testing. everything works great on arduino uno and arduino nano. On this basis, I built a device communicating with ten slave units. Everything failed when trying to incorporate mega. so I tried a purely basic sketch of the slave device and the master device themselves on the example code. unfortunately the sketch failed and I don't know why. according to the oscilloscope, neither device is transmitting. Tested even without max485 modules on direct rx/tx Tx/Rx. if I use only a simple sketch for sending data, it works on the given pins. I don't know what could be wrong. Could it be an IDE compiler error ? I am using the latest version of the library.
What pins are you using for RX and TX?
For Pins softwareserial, I used the default pins according to the sketch, then tried it on pins 3, 4, 5, then I switched to using the hw port on the megabyte. By default, I use the classic serial1 and for that I have already started it somehow, but only if I use only one slave, if I modify the code and add another slave like with nano, the other one doesn't work for me. at the same time, I now have a string of 15 slave devices on the nano. however, hw serial now at least communicates with one slave. but I don't know why the serial software doesn't work. , unfortunately it still doesn't work on leonard even when using the HW serial port.
SoftwareSerial is particular on what pins can be used on the Arduino Mega and the Arduino Leonardo. The details can be found in the Arduino Docs for the SoftwareSerial library.
The ModbusRTUMasterExample sketch is only setup to talk to one slave device. I'm guessing you made some modifications. Can you post your sketch here?
Hello. I have a problem with your library. The code only works for me on arduino uno and arduinlo nano boards. (Same MCU). On Leonardo and arduino Mega boards, the library is broken.