Folks,
Using "shield" MAX485 TTL to RS-485 to communicate a Mega (Master) with a Micro (slave)
Test each sketch using the Serial Monitor and the Slave is sending the data as expected, and the Master is receiving the data as expected. But when I change to the RS485 shield, it appears that data is not being received or transmit or both.
I wired the Shields as per for half duplex communication. Triple check the connections and everything seems to be connected fine, but see no seral activity. I'm not using any resistors for the bus, none of the "tutorials", videos and connection diagrams showed or say anything about
adding resistors to the bus. What I'm doin wrong??
Below the Codes
Master:
const int Tx_Rx = 3;
void setup()
{
pinMode(Tx_Rx, OUTPUT);
digitalWrite(Tx_Rx,LOW);
Serial.begin(9600); // Local Serial cooms
//Serial1.begin(9600); // RS485 Comms
}
void loop()
{
Message_From_Slave10();
//Message_To_Slave();
}
void Message_From_Slave10()
{
digitalWrite(Tx_Rx,LOW); // LOW = Receiving Data from Serial
if(Serial.available()) // Check if there is Data in the serial buffer
{
if(Serial.read()=='<') // New Message from Slave.
{
int TargetAddress = Serial.parseInt(); //
if ( TargetAddress == 10)
{
Serial.println (" We have a message from Slave 10");
}
}
}
}
Slave:
const int Tx_Rx = 12;
void setup()
{
pinMode (Tx_Rx,OUTPUT);
//digitalWrite(Tx_Rx,LOW);
Serial.begin(9600); // Local Serial cooms
}
void loop()
{
digitalWrite(Tx_Rx,HIGH); // HIGH = Transmitting Data to Serial
Serial.print ("<");
Serial.print (10);
Serial.print (";");
Serial.print (0);
Serial.print (";");
Serial.print (0);
Serial.print (";");
Serial.print (0);
Serial.print (";");
Serial.print (1);
Serial.print (";");
Serial.print (0);
Serial.print (";");
Serial.print (1);
Serial.print (">");
Serial.println (" ");
//digitalWrite(Tx_Rx,LOW); // LOW = Receiving Data from Serial
delay (5);
}
