user60406: I'm trying to achieve RS485 communication between Arduino Mega and Arduino UNO as specified in following link:
https://www.engineersgarage.com/arduino/rs485-communication-between-arduino-mega-and-arduino-pro-mini
But now my problem is The master i.e. Arduino Mega doesn't print anything on Serial Monitor.
Please help me out to solve this issue, trying from week still no success.

Sir Peter Paul Kiefer,
Im attaching my circuit setup

Master Code/Mega code
void setup() 
{  
  //Using Serial1 Port
  Serial1.begin(9600);
  Serial.begin(9600);

  //DE/RE Controling pin of RS-485
  pinMode(8, OUTPUT);
}

void loop() 
{
  char getdata='m';

  //DE/RE=HIGH Transmit Enabled M1
  digitalWrite(8,HIGH);

  //Write '9' and Fetch Data From Pro Mini
  Serial1.print('9');

  //DE/RE=LOW Receive Enabled M1
  digitalWrite(8,LOW);
  delay(1000);

  //If Serial Data is available
  if(Serial1.available())
  { 
    while( Serial1.available() && getdata!='d' )
    { 
      getdata=Serial1.read();
      Serial.print(getdata);
    }

    Serial.println("");
  }
}

Slave code
void setup() 
{
  //Serial1.begin(9600);//Uncomment for Arduino Lenardo
  Serial.begin(9600);
  //while(!Serial1);//Uncomment for Arduino Lenardo

  //Led Connected
  pinMode(13, OUTPUT);

  //DE/RE Controling pin of RS-485
  pinMode(8, OUTPUT);
}

void loop() 
{
  // put your main code here, to run repeatedly:
  char getdata='c';

  //Led OFF
  digitalWrite(13,LOW);
  //DE/RE=LOW Receive Enabled
  digitalWrite(8,LOW);

  if(Serial.available())
  {
    getdata=Serial.read();
  }

  if(getdata=='9')
  {
     //DE/RE=HIGH Transmit Enabled 
     digitalWrite(8,HIGH);

     Serial.print("AcruxTek");
     Serial.print("Isld");
  }

  delay(2000);
  //Led ON
  digitalWrite(13,HIGH);
  delay(2000);
}


I connected gnd of RS485 converter to arduino gnd and also i did common gnd between circuits but still no output. I used same code nothing changed.. except one thing the example uses arduino pro mini but i used arduino uno as slave

user60381: I think there might be two issues in the engineering garage code. delay() function parameter in both codes is not matched. And another thing might cause problem is"Arduino Serial monitor hardware serial is already connected with another usb-serial converter ic which you are using for code uploading, so you cannot use this serial port for rs-485. So using software serial of Arduino pro-mini is a safe option. Finally you have to connect the software Serial pins with rs-485 converter. I have modified the code a little bit and attached the code herewith.
Arduino Mega code
void setup() 
{ 
  Serial1.begin(9600);//Using Serial1 Port
  Serial.begin(9600);
  pinMode(8, OUTPUT);//DE/RE Controling pin of RS-485
}

void loop()
{
  digitalWrite(8,HIGH);//DE/RE=HIGH Transmit Enabled M1
  Serial1.print('9');//Write '9' and Fetch Data From Pro Mini




  int timeOut = 0;
  digitalWrite(8,LOW);//DE/RE=LOW Receive Enable
  while(!Serial1.available() && timeOut < 5000)
  {
    delay(1);
    timeOut++; // wait 5s to get response from slave
  }
  String response = Serial1.readString();
  Serial.println(response);
}

Arduino Pro-Mini Code
#include <SoftwareSerial.h>
#define RS485_RX 2
#define RS485_TX 3
SoftwareSerial mySerial(RS485_RX,RS485_TX);//Creating object

void setup() 
{ 
  //Serial1.begin(9600);//Uncomment for Arduino Lenardo
  Serial.begin(9600);
  mySerial.begin(9600);
  //while(!Serial1);//Uncomment for Arduino Lenardo

  pinMode(13, OUTPUT);//Led Connected
  pinMode(8, OUTPUT);//DE/RE Controling pin of RS-485
}

void loop() 
{
  digitalWrite(13,LOW);//Led OFF
  digitalWrite(8,LOW);//DE/RE=LOW Receive Enable

  while(!mySerial.available())
  {
    delay(1);
  }

  String res = mySerial.readString();
  if (res == "9")
  {
     digitalWrite(8,HIGH);//DE/RE=HIGH Transmit Enabled 
     mySerial.print("AcruxTek");
     mySerial.print("Isld");
  }
  digitalWrite(13,HIGH);//Led OFF
}


user10285: It's not really clear from the picture, but it seems that, the two adapter have no common ground. i.e you have to connect the ground (GND) pin of one the adapter to the GND pin of the other one. But do not remove the connection between the GND pins and the arduino GND pins.
I also assume that the mega-adapter is powered with 3.3 V and the UNO-adapter is powered with 5 V (or 3.3V I can not see). This might cause a problem, because the MAX485 chip needs a 5V power supply. 
EDIT:
Sorry by a second view a saw, the mega delivers 5 V. So possibly you only have to connect the GNDs of the adapters to solve your problem.
EDIT 2:
I guess the little yellow wire in front of of both adapters connects the DE pins of them. The DE pin of each adapter is also connected to the respective Arduino PIN 8. So it doesn't matter which Arduino is requesting to switch the adapter into the send mode. Both adapters are sending. As far as I know, the adapter only work in Half Duplex you mus define the direction of the data flow. If one adapter is in send mode the other must be in receive mode.
It might also be possible that the DE and RE PIN of each adapter is connected.
But this seams strange to me also. With that I would say you setup up one adapter in both receive and send mode and the other in none of them. 
EDIT 3:
By looking into the MAX485 Spec. I saw that RE is LOW active but labeled as RE (which I understood as HIGH active), so sorry the last paragraph of my EDIT 2 is nonsense. So, perhaps it's a matter of timing or (more likely) there is still something wrong with the wiring. 
EDIT 4:
In the picture I see that you connect the hardware tx and rx pins to the adapter. But Software Serial needs its own pins. Pin0 and Pin1 are connected with the PC Serial Terminal over the built in USB to Serial adapter of the arduino UNO. That's the reason why you need the software serial solution on an arduino. You need a second serial interface and UNO has only one of them which is already used for the connection to the PC (Programming and serial monitor).
In the code I don't see the initialization of the software serial port. 
This is also necessary:
#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;

// set up a new serial object
SoftwareSerial mySerial (rxPin, txPin);


60406: <p>I'm trying to achieve RS485 communication between Arduino Mega and Arduino UNO as specified in following link:</p>

<p><a href="https://www.engineersgarage.com/arduino/rs485-communication-between-arduino-mega-and-arduino-pro-mini" rel="nofollow noreferrer">https://www.engineersgarage.com/arduino/rs485-communication-between-arduino-mega-and-arduino-pro-mini</a></p>

<p>But now my problem is The master i.e. Arduino Mega doesn't print anything on Serial Monitor.</p>

<p>Please help me out to solve this issue, trying from week still no success.</p>

<hr>

<p>Sir Peter Paul Kiefer,</p>

<p>Im attaching my circuit setup</p>

<p><a href="https://i.stack.imgur.com/yNCfc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yNCfc.jpg" alt="enter image description here"></a></p>

<p>Master Code/Mega code</p>

<pre><code>void setup() 
{  
  //Using Serial1 Port
  Serial1.begin(9600);
  Serial.begin(9600);

  //DE/RE Controling pin of RS-485
  pinMode(8, OUTPUT);
}

void loop() 
{
  char getdata='m';

  //DE/RE=HIGH Transmit Enabled M1
  digitalWrite(8,HIGH);

  //Write '9' and Fetch Data From Pro Mini
  Serial1.print('9');

  //DE/RE=LOW Receive Enabled M1
  digitalWrite(8,LOW);
  delay(1000);

  //If Serial Data is available
  if(Serial1.available())
  { 
    while( Serial1.available() &amp;&amp; getdata!='d' )
    { 
      getdata=Serial1.read();
      Serial.print(getdata);
    }

    Serial.println("");
  }
}
</code></pre>

<p>Slave code</p>

<pre><code>void setup() 
{
  //Serial1.begin(9600);//Uncomment for Arduino Lenardo
  Serial.begin(9600);
  //while(!Serial1);//Uncomment for Arduino Lenardo

  //Led Connected
  pinMode(13, OUTPUT);

  //DE/RE Controling pin of RS-485
  pinMode(8, OUTPUT);
}

void loop() 
{
  // put your main code here, to run repeatedly:
  char getdata='c';

  //Led OFF
  digitalWrite(13,LOW);
  //DE/RE=LOW Receive Enabled
  digitalWrite(8,LOW);

  if(Serial.available())
  {
    getdata=Serial.read();
  }

  if(getdata=='9')
  {
     //DE/RE=HIGH Transmit Enabled 
     digitalWrite(8,HIGH);

     Serial.print("AcruxTek");
     Serial.print("Isld");
  }

  delay(2000);
  //Led ON
  digitalWrite(13,HIGH);
  delay(2000);
}
</code></pre>

<hr>

<p>I connected gnd of RS485 converter to arduino gnd and also i did common gnd between circuits but still no output. I used same code nothing changed.. except one thing the example uses arduino pro mini but i used arduino uno as slave</p>
 60381: <p>I think there might be two issues in the engineering garage code. delay() function parameter in both codes is not matched. And another thing might cause problem is"Arduino Serial monitor hardware serial is already connected with another usb-serial converter ic which you are using for code uploading, so you cannot use this serial port for rs-485. So using software serial of Arduino pro-mini is a safe option. Finally you have to connect the software Serial pins with rs-485 converter. I have modified the code a little bit and attached the code herewith.</p>

<p><strong>Arduino Mega code</strong></p>

<pre><code>void setup() 
{ 
  Serial1.begin(9600);//Using Serial1 Port
  Serial.begin(9600);
  pinMode(8, OUTPUT);//DE/RE Controling pin of RS-485
}

void loop()
{
  digitalWrite(8,HIGH);//DE/RE=HIGH Transmit Enabled M1
  Serial1.print('9');//Write '9' and Fetch Data From Pro Mini




  int timeOut = 0;
  digitalWrite(8,LOW);//DE/RE=LOW Receive Enable
  while(!Serial1.available() &amp;&amp; timeOut &lt; 5000)
  {
    delay(1);
    timeOut++; // wait 5s to get response from slave
  }
  String response = Serial1.readString();
  Serial.println(response);
}
</code></pre>

<p><strong>Arduino Pro-Mini Code</strong></p>

<pre><code>#include &lt;SoftwareSerial.h&gt;
#define RS485_RX 2
#define RS485_TX 3
SoftwareSerial mySerial(RS485_RX,RS485_TX);//Creating object

void setup() 
{ 
  //Serial1.begin(9600);//Uncomment for Arduino Lenardo
  Serial.begin(9600);
  mySerial.begin(9600);
  //while(!Serial1);//Uncomment for Arduino Lenardo

  pinMode(13, OUTPUT);//Led Connected
  pinMode(8, OUTPUT);//DE/RE Controling pin of RS-485
}

void loop() 
{
  digitalWrite(13,LOW);//Led OFF
  digitalWrite(8,LOW);//DE/RE=LOW Receive Enable

  while(!mySerial.available())
  {
    delay(1);
  }

  String res = mySerial.readString();
  if (res == "9")
  {
     digitalWrite(8,HIGH);//DE/RE=HIGH Transmit Enabled 
     mySerial.print("AcruxTek");
     mySerial.print("Isld");
  }
  digitalWrite(13,HIGH);//Led OFF
}
</code></pre>
 10285: <p>It's not really clear from the picture, but it seems that, the two adapter have no common ground. i.e you have to connect the ground (GND) pin of one the adapter to the GND pin of the other one. But do <em>not</em> remove the connection between the GND pins and the arduino GND pins.</p>

<p>I also assume that the mega-adapter is powered with 3.3 V and the UNO-adapter is powered with 5 V (or 3.3V I can not see). This might cause a problem, because the MAX485 chip needs a 5V power supply. </p>

<p>EDIT:</p>

<p>Sorry by a second view a saw, the mega delivers 5 V. So possibly you only have to connect the GNDs of the adapters to solve your problem.</p>

<p>EDIT 2:</p>

<p>I guess the little yellow wire in front of of both adapters connects the DE pins of them. The DE pin of each adapter is also connected to the respective Arduino PIN 8. So it doesn't matter which Arduino is requesting to switch the adapter into the send mode. Both adapters are sending. As far as I know, the adapter only work in Half Duplex you mus define the direction of the data flow. If one adapter is in send mode the other must be in receive mode.</p>

<p>It might also be possible that the DE and RE PIN of each adapter is connected.
But this seams strange to me also. With that I would say you setup up one adapter in both receive and send mode and the other in none of them. </p>

<p>EDIT 3:</p>

<p>By looking into the MAX485 Spec. I saw that RE is LOW active but labeled as RE (which I understood as HIGH active), so sorry the last paragraph of my EDIT 2 is nonsense. So, perhaps it's a matter of timing or (more likely) there is still something wrong with the wiring. </p>

<p>EDIT 4:</p>

<p>In the picture I see that you connect the hardware tx and rx pins to the adapter. But Software Serial needs its own pins. Pin0 and Pin1 are connected with the PC Serial Terminal over the built in USB to Serial adapter of the arduino UNO. That's the reason why you need the software serial solution on an arduino. You need a second serial interface and UNO has only one of them which is already used for the connection to the PC (Programming and serial monitor).</p>

<p>In the code I don't see the initialization of the software serial port. 
This is also necessary:</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;

const byte rxPin = 2;
const byte txPin = 3;

// set up a new serial object
SoftwareSerial mySerial (rxPin, txPin);
</code></pre>
