Arduino mega multiple max485 modules

Hi guys.
I have a new project on Arduino mega.
And I have 5 max485 modules.
Using ModbusMaster library.
I want to connect all max485 modules to one serial, example Serial3.
How?
Code:

#include <Arduino.h>
#include <ModbusMaster.h>

ModbusMaster node1, node2, node3; 

void setup() {
  Serial3.begin(4800);
  Serial2.begin(4800);
  Serial1.begin(4800);

  node1.begin(1, Serial3);
  node2.begin(1, Serial2);
  node3.begin(1, Serial1); 
  //... 
} 
void loop() {
 //... 
} 

Thx in advanve!

Hi,
have you Googled;

arduino rs485 network

Tom.... :smiley: :+1: :coffee: :australia:

Bro I know what rs485 network.
I know that in the rs-485 network the principle of connecting 1 module is many devices. But I have a different problem, so the question is different.
But I can't find in. Google an answer to it, so I wrote here.
Thx.

the Mega has three spare hardware serial ports Serial1, Serial2 and Serial3 which would support three MAX485 boards - possibly two more using SoftwareSerial - no idea if this would work!
why do you require five RS485 ports - are you using five different RS485 protocols?
I have never required more than two independent RS485 ports on a microcontroller
Edit: if you require five hardware serial ports I recently used six serial hardware ports on a PIC24FJ1024GA610

1 Like

Hi,
Why all to one serial?
Can you please tell us the application?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

1 Like

I connect three to Serial1, Serial2 and Serial3.
And two on SoftwareSerial.
On SoftwareSerial max485 not working, I don't know why.
That I want connect all to one serial :blush:

Somewhere in google I see this code

ModbusMaster node1, node2;

void setup() {
  Serial3.begin(4800);

  node1.begin(1, Serial3);
  node2.begin(2, Serial3);
} 

But I don't know if it's worth trying

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.