Hi,
I also trying to interpose between 2 devices one is slave (a smart meter) and one is master (invertor). They are from different manufactures therefore they can't communicate to each other.
I want to do this by using a Arduino board (I have a Nano) and use 2 TTL RS485 modules (MAX485). One to connect to one device and one to connect to the second one. In the loop, I want to read from one serial port (the one connected to slave) and write to the other (the one connected to the master).
Problem I am facing, is that the modbus class (and I tried few) works ok with the standard hardware serial port.. but not with any soft serial ports that i created. Thus I need to connect the MAX 485 module to RX and TX pins.. I one case it could work.. but not if I want to use 2 modules.. I can't connect them both to RX TX pins...
Is this setup (one board with 2 RS485 modules) a viable setup? Or just theoretically?
Any suggestions?
@noiasca as you can see, ModbusMaster is exactly what I use. If I replace mySerial by Serial.. (and ofcourse I switch the pins to RX, TX) it reads properly.
On the photovoltaic setup, the invertor is master (client) and is querying the slave(server) which is the smart meter. If I intervene between, on one side my Arduino needs to act as master to interrogate the smart meter, and on the other side , needs to act as a slave so it can reply when the invertor is querying.
This setup works fine on a PC.. but I want to go next level and replace my pc by an Arduino
I did that already... This library has also a downside... the pins for RX and TX are fixed based on the board.. thus I can not have 2 instances of an AltSerial port...
Why are you stuck on a Nano? Make your life easier and switch to a more appropriate platform. There are plenty of boards in the Arduino Ecosystem that support multiple Hardware UART ports.
I'd recommend a Teensy or one of the Adafruit Feathers.
Thanks @horace@gfvalvo ! I am not stuck to Nano.. just wanted to be sure that I am not doing something wrong before starting to spend more money on different boards.. Nano was a choice because of the size.. which allows us to put it in a fuse box afterwards... but I see your suggestions are comparable in size . so probably this will be the next step.. (unless someone will point a solution in the current setup ).