Odd problem with RS485 messasging between 2 uno's

I have setup a very simple Test circuit to check the abilitiy of RS485 to allow me to send data from a Master to Slave device annd vice versa using Nick Gammons "RS485_protocol.h" library and 2 wire connections (+common ground). I am using ASCII transmission, not Modus RTU.

All I am trying to do is to have the Master send a command to the Slave to toggle the onboard pin 13 LED on or off, and then have the Slave tell the Master to do the same, but in opposite directions, so basically the LED's flash alternately.

I need this functionality for a Model Railway control project I am working on

However, while I can get the first part to work, so the Slave does what it is told, the subsequent sendMsg from the Slave never seems to be received by the Master.

I am using arbitrarily chosen "ID's" of 1 for the master and 5 for the Slave, which are in the first byte in the 2 byte messages so that I can test addressing. The software checks for the relevant first byte to decide if it is the PLC being addressed.

I send "51" from the Master, and the slave duly checks if it is the required PLC, "5" means it is, and then it simply checks the current status of the LED and switches it appropriately. THIS WORKS JUST FINE!

The Slave device then sends a message back to the master (ID 1) after a delay of "delay(1)" containing "11" which identifies the master (in byte[0] of the code) as the relevant PLC, and the second "1" tells it to toggle the master's LED On or Off as relevant in the same way as the slave.

Sadly, the message defined in code as being "11" sent back from Slave to Master is never received according to my debug code. I only ever seems to contain "00", it's default setup.

I am only using 19200 baud for the connection, both Unos are grounded together and I have even tried setting various delay periods on Master and Slave to see if there is timing clash, but nothing I have tried so far will get the Slave to send the correct data to the Master, or the Master to receive it as sent ?

The A->A, B-> B wiring seems fine, as the slave responds as expected

Can anyone help me in identifying what is going wrong ?

Can anyone help me in identifying what is going wrong ?

No, as we cannot see the code.

2 wire connections (+common ground

Common grounds is not necessary with RS485.

Ok, fair comment I guess - here ya go !!

Sender code :

// Send
#include <RS485_protocol.h>
#include <SoftwareSerial.h>

#define RS485RECEIVEPIN    4
#define RS485TRANSMITPIN   5
#define RS485ENABLE_PIN    6
#define RS485OUTPUTPIN     7
#define SERIALID  '1'
#define SLAVEID1  5

byte Message[] = {
   SLAVEID1,1,
};

int address = 0;
int command = 0;
bool rs485Data = false;
char gbuff[256]="";
SoftwareSerial rs485 (RS485RECEIVEPIN, RS485TRANSMITPIN);  // receive pin, transmit pin


void fWrite (const byte what){
  rs485.write (what);  }
int fAvailable (){
  return rs485.available ();  }
int fRead (){
  return rs485.read ();  }
  
void setup()
{
  Serial.begin(9600);
  Serial.println("System Startup - Sender");

  rs485.begin(19200);
  pinMode (RS485ENABLE_PIN, OUTPUT);  // driver output enable
  Serial.println("Setup completed...");
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
}

void loop()
{
   start:
   delay (150); 
   Message[0] = SLAVEID1; 
   Message[1] = 1; 
   Serial.print("Sending: ");
   Serial.print(Message[0]);
   Serial.println(Message[1]);
   digitalWrite (RS485ENABLE_PIN, HIGH);  // enable sending
   sendMsg (fWrite, (const byte*)Message, sizeof Message);
   delayMicroseconds (660);
   digitalWrite (RS485ENABLE_PIN, LOW);  // disable sending

   // receive any available message
   byte buf []={
    2,0,
   }; 
   
   while (fAvailable()){
      rs485Data = true;
      recvMsg (fAvailable, fRead, buf, sizeof buf);
      Serial.print(buf[0]);
      Serial.println(buf[1]);
      sprintf(gbuff, "Message [%d%d] received...", buf[0],  buf[1]);
      Serial.println(gbuff);
      address = buf[0];
      command = buf[1];
   }
   if (rs485Data){
      if (address >= 0 && command < 2){
         sprintf(gbuff, "Message received = %d%d", address, command);
         Serial.println(gbuff);
         if (address != 1){  // ID = 5
            Serial.println("Message is NOT for us...");
            Serial.println(gbuff);
            goto start;  // unknown command
         }
         if (command > 1){   // command = 0/1
            sprintf(gbuff, "Command [%d%d] is NOT recognised...", address, command);
            Serial.println(gbuff);
            goto start;  // unknown command
         }
         if (digitalRead(13) == HIGH){
            digitalWrite (13, LOW);  // set LED to command value of 0 or 1 (On or Off)
            Serial.println("Setting LED OFF");
          }
          else{
            digitalWrite (13, HIGH);  // set LED to command value of 0 or 1 (On or Off)
            Serial.println("Setting LED ON");
          }
      }
      rs485Data = false;
   }
}

Receiver/Slave :

char  gbuff[128] = "";
#define _USE_RS485_
   #ifdef _USE_RS485_
      // required for RS485 communications
      // I AM USING NICK GAMMONS LIBRARY FOR THIS, AS IT WORKS GREAT
      #define RS485RECEIVEPIN    4
      #define RS485TRANSMITPIN   5
      #define RS485ENABLE_PIN    6
      #define RS485OUTPUTPIN     7
   #endif   
#define SERIALID  '5'  // this is this Arduinos ID for 2 way serial communications, and/or RS485
#define MASTERID  1
#include <SoftwareSerial.h>
#include "RS485_protocol.h"

SoftwareSerial rs485 (RS485RECEIVEPIN, RS485TRANSMITPIN);  // receive pin, transmit pin

byte buf[] = {
               0,
               0,
             }; 

int address = 0;
int command = 0;

void fWrite (const byte what){
  rs485.write (what);  }
int fAvailable (){
  return rs485.available ();  }
int fRead (){
  return rs485.read ();  }
  
void setup(){
  Serial.begin(9600);
  rs485.begin (19200);
  pinMode (RS485ENABLE_PIN, OUTPUT);  // driver output enable
  Serial.println("Setup completed...");
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
}

void loop(){
start:
   delay(100);
   recvMsg (fAvailable, fRead, buf, sizeof ((unsigned byte*)buf));
   sprintf(gbuff, "buf[0] = [%c], buf[1] = [%c]..", buf[0], buf[1]);
   Serial.println(gbuff);
   address = buf[0];
   command = buf[1];
   if (address >= 0 && command < 2){
     sprintf(gbuff, "Message received = %d%d", address, command);
     Serial.println(gbuff);
      if (address != 5){  // ID = 5
         Serial.println("Message is NOT for us...");
         Serial.println(gbuff);
         goto start;  // unknown command
      }
      if (command > 1){   // command = 0/1
         sprintf(gbuff, "Command [%d%d] is NOT recognised...", address, command);
         Serial.println(gbuff);
         goto start;  // unknown command
      }
      if (digitalRead(13) == HIGH){
         digitalWrite (13, LOW);  // set LED to command value of 0 or 1 (On or Off)
         Serial.println("Setting LED OFF");
       
         byte Message[] = {
             MASTERID,1,
         };
         digitalWrite (RS485ENABLE_PIN, HIGH);  // enable sending
         sendMsg (fWrite, (const byte*)Message, sizeof Message);
         delayMicroseconds (660);
         digitalWrite (RS485ENABLE_PIN, LOW);  // disable sending
         sprintf(gbuff,"Sending: [%d%d]", Message[0],  Message[1]);
         Serial.println(gbuff);
       }
       else{
         digitalWrite (13, HIGH);  // set LED to command value of 0 or 1 (On or Off)
         Serial.println("Setting LED ON");
         
         byte Message[]={
            1,
            0,
         };
         delay (1);  // give the master a moment to prepare to receive
         digitalWrite (RS485ENABLE_PIN, HIGH);  // enable sending
         sendMsg (fWrite, (const byte*)Message, sizeof Message);
         delayMicroseconds (660);
         digitalWrite (RS485ENABLE_PIN, LOW);  // disable sending
         sprintf(gbuff,"Sending: [%d%d]", Message[0],  Message[1]);
         Serial.println(gbuff);
         goto start;  // unknown command
       }
    }else{  // end if something received
          Serial.println("No message available...");
    }
}  // end of loop

Hopefully that shows you how simple the code is really, it is all all based on Nick Gammons examples in his excellent documentation on this forum :slight_smile:

The Slave responds just fine, and does as instructed, toggling the Pin 13 LED, but no matter what I seem to do, or try, the master never receives the sendMsg from the Slave ?

I am only using 19200 baud for the connection

This is not a low value for SoftwareSerial, it's about the hightest that may work.

If you only want to change the LED, why don't you use the hardware serial interface?

Throw away these lines:

         delayMicroseconds (660);

With these in place the master is blocking the RS485 line with the driver activated while the slave tries to send it's answer. You don't have to wait after SoftwareSerial.write() call because in SoftwareSerial there is nothing, absolutely nothing asynchronous.

And check for the return code of recvMsg() as it probably indicates a timeout because the received characters are out of sync.

This is just test code to ascertain the RS485 comms functionality ! The intended application will be somewhat more complex than toggling an LED.

I have rmoved the delayMicroseconds() and added a test for the recvMsg which has resulted in NOTHING at all apparently being received ?

This is just test code to ascertain the RS485 comms functionality ! The intended application will be somewhat more complex than toggling an LED.

In this case I strongly recommend not to use the SoftwareSerial library. If you need the USB connection for debugging use an Arduino model that provides an additional hardware serial interface (e.g. Leonardo, Mega2560).

I have rmoved the delayMicroseconds() and added a test for the recvMsg which has resulted in NOTHING at all apparently being received ?

Please post the resulting code.

What does "NOTHING at all" mean? You loose now the reception on the slave? Post the serial output!

Hi

"What does "NOTHING at all" mean? You loose now the reception on the slave? Post the serial output!"

OK, In fact I have now simplifed this down the the absolute code basics using another example - Code follows :-

Master -

/* YourDuino SoftwareSerialExample1
   - Connect to another Arduino running "YD_SoftwareSerialExampleRS485_1Remote"
   - Connect this unit Pins 10, 11, Gnd
   - Pin 3 used for RS485 direction control
   - To other unit Pins 11,10, Gnd  (Cross over)
   - Open Serial Monitor, type in top window. 
   - Should see same characters echoed back from remote Arduino

   Questions: terry@yourduino.com 
*/

/*-----( Import needed libraries )-----*/
#include <SoftwareSerial.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define SSerialRX        10  //Serial Receive pin
#define SSerialTX        11  //Serial Transmit pin

#define SSerialTxControl 3   //RS485 Direction control

#define RS485Transmit    HIGH
#define RS485Receive     LOW

#define Pin13LED         13

/*-----( Declare objects )-----*/
SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX

/*-----( Declare Variables )-----*/
int byteReceived;
int byteSend;
int data[] = {5,1,};

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Start the built-in serial port, probably to Serial Monitor
  Serial.begin(9600);
  Serial.println("YourDuino.com SoftwareSerial remote loop example");
  Serial.println("Use Serial Monitor, type in upper window, ENTER");
  
  pinMode(Pin13LED, OUTPUT);   
  pinMode(SSerialTxControl, OUTPUT);    
  
  
  // Start the software serial port, to another device
  RS485Serial.begin(4800);   // set the data rate 
  digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver to receive mode (LOW) 

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
/*  
  if (RS485Serial.available())  //Look for data from other Arduino
  {
    byteReceived = RS485Serial.read();    // Read received byte
    Serial.println(byteReceived);        // Show on Serial Monitor
    Serial.println("Data received back from slave.");
    if (digitalRead(Pin13LED) == LOW)  // Show activity    
        digitalWrite(Pin13LED, HIGH);  // Show activity    
     else
        digitalWrite(Pin13LED, LOW);  // Show activity    
   }  
*/
    Serial.println("Sending Data...");
    digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit   
    RS485Serial.write(5);          // Send byte to Remote Arduino
    digitalWrite(SSerialTxControl, RS485Receive);  // Disable RS485 Transmit       
    delay(1000);
/*
if (Serial.available())  // see if user has entered something
  {
    //while(Serial.available()){
       byteReceived = Serial.read();
       Serial.print(byteReceived);
    //}
    Serial.println("\nData received from from ME.");
    
    digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit   
    RS485Serial.write(byteReceived);          // Send byte to Remote Arduino
    digitalWrite(SSerialTxControl, RS485Receive);  // Disable RS485 Transmit       
    
    if (digitalRead(Pin13LED) == LOW)  // Show activity    
        digitalWrite(Pin13LED, HIGH);  // Show activity    
     else
        digitalWrite(Pin13LED, LOW);  // Show activity    
  }
*/  
}//--(end main loop )---

Slave :-

/* YourDuino SoftwareSerialExample1Remote
   - Used with YD_SoftwareSerialExampleRS485_1 on another Arduino
   - Remote: Receive data, loop it back...
   - Connect this unit Pins 10, 11, Gnd
   - To other unit Pins 11,10, Gnd  (Cross over)
   - Pin 3 used for RS485 direction control   
   - Pin 13 LED blinks when data is received  
   
   Questions: terry@yourduino.com 
*/

/*-----( Import needed libraries )-----*/
#include <SoftwareSerial.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define SSerialRX        10  //Serial Receive pin
#define SSerialTX        11  //Serial Transmit pin

#define SSerialTxControl 3   //RS485 Direction control
#define RS485Transmit    HIGH
#define RS485Receive     LOW

#define Pin13LED         13

/*-----( Declare objects )-----*/
SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX

/*-----( Declare Variables )-----*/
int byteReceived;
int byteSend;

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Start the built-in serial port, probably to Serial Monitor
  Serial.begin(9600);
  Serial.println("SerialRemote");  // Can be ignored
  
  pinMode(Pin13LED, OUTPUT);   
  pinMode(SSerialTxControl, OUTPUT);  
  
  // Start the software serial port, to another device
  RS485Serial.begin(4800);   // set the data rate 
  digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver to receive
  
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  //Copy input data to output  
  if (RS485Serial.available()) 
  {
    byteSend = RS485Serial.read();   // Read the byte 
    Serial.println("data received");  // Can be ignored
    
  if (digitalRead(Pin13LED) == LOW)  // Show activity    
     digitalWrite(Pin13LED, HIGH);  // Show activity    
  else
     digitalWrite(Pin13LED, LOW);  // Show activity    
   
    digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit    
    RS485Serial.write(byteSend); // Send the byte back
    delay(10);   
    digitalWrite(SSerialTxControl, RS485Receive);  // Disable RS485 Transmit      
    Serial.println("data returned");  // Can be ignored
//    delay(100);
  }// End If RS485SerialAvailable
  
}//--(end main loop )---

Still using Uno's right now. the Rx (NOT Tx as I would have expected ?) on the master is flashing as expected every 1 second. But that is all that is happening on either Uno.

I have modified the sender to send a single character every second to the slave via the RS485 connection.

Sadly the RS485 boards I am using do not have any indicators to show data movement either way. The Slave Uno shows no Rx or any other activity whatsoever.

All seems very weird ?

And where is the serial output of these sketches?

The LED won't blink as digitalRead() doesn't return what you expect it to return. It's not the state of the LED but the bit in the Port Input Register (PINB) while the digitalWrite writes to the Port Output Register (PORTB). As the pin is configured as an output the result of the digitalRead() call will stay the same and will not change if you do a digitalWrite() to the same pin.

Sorry about the long delay, I have been hijacked by other things.

In desperation I have totally rebuilt the test rig for this project, using Veroboard and soldering all joints possible to avoid issues of poor connectivity.

I have also tried various different schemes in the software, but right now if I am plugged into the Master Uno, the Serial output shows just "Sending data of 51". There is no apparent response from the Slave Uno.

I have lowered the comms speed to 9600, and attach hereto a screenshot of a Fritzing wiring diagram plus the outputs from both serial monitor sessions and finally the pretty short code for both sketches are included.

In this setup I am assuming that relevant line resistors are supplied by the boards themselves. The documentation is unclear about this. but my previous system did have additional resistpors soldered into it. so there does not appear to be any difference..

The twisted pair go A-A and B-B as specified, although I have tried reversing one end to no avail.

Master "sender" code

// Send
#include <RS485_protocol.h>
#include <SoftwareSerial.h>

#define RS485RECEIVEPIN    10
#define RS485TRANSMITPIN   11 
#define RS485ENABLE_PIN    3
#define RS485OUTPUTPIN     7
#define MASTERID  '1'
#define SLAVEID1  5

byte Message[] = {SLAVEID1,1};

int address = 0;
int command = 0;
bool rs485Data = false;
char gbuff[128]="";
SoftwareSerial rs485 (RS485RECEIVEPIN, RS485TRANSMITPIN);  // receive pin, transmit pin


void fWrite (const byte what){
  rs485.write (what);  }
int fAvailable (){
  return rs485.available ();  }
int fRead (){
  return rs485.read ();  }
  
void setup()
{
  Serial.begin(9600);
  Serial.println("System Startup - Sender");

  rs485.begin(9600);
  pinMode (RS485ENABLE_PIN, OUTPUT);  // driver output enable
  Serial.println("Setup completed...");
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
}

void loop()
{
//   start:
   delay (150); 
   Message[0] = SLAVEID1; 
   Message[1] = 1; 
   Serial.print("Sending: ");
   Serial.print(Message[0]);
   Serial.println(Message[1]);
   digitalWrite (RS485ENABLE_PIN, HIGH);  // enable sending
   sendMsg (fWrite, (const byte*)Message, sizeof Message);
   delayMicroseconds (660);
   digitalWrite (RS485ENABLE_PIN, LOW);  // disable sending

   // receive any available message
   byte buf []={2,0}; 
   
//   while (fAvailable()){
   if(recvMsg (fAvailable, fRead, buf, sizeof buf)){
//      rs485Data = true;
      Serial.print(buf[0]);
      Serial.println(buf[1]);
      sprintf(gbuff, "Message [%d%d] received...", buf[0],  buf[1]);
      Serial.println(gbuff);
      address = buf[0];
      command = buf[1];
      buf[0] = '\0';

//      if (rs485Data){
         if (address >= 0 && command < 2){
            sprintf(gbuff, "Message received = %d%d", address, command);
            Serial.println(gbuff);
            if (address != MASTERID){  // SHOULD BE MASTERID
               Serial.println("Message is NOT for us...");
               Serial.println(gbuff);
               return;  // unknown command
            }
            if (command > 1){   // command = 0/1
               sprintf(gbuff, "Command [%d%d] is NOT recognised...", address, command);
               Serial.println(gbuff);
               return;  // unknown command
            }
            if (digitalRead(13) == HIGH){
               digitalWrite (13, LOW);  // set LED to command value of 0 or 1 (On or Off)
               Serial.println("Setting LED OFF");
             }
             else{
               digitalWrite (13, HIGH);  // set LED to command value of 0 or 1 (On or Off)
               Serial.println("Setting LED ON");
             }
//         }
//         rs485Data = false;
      }
   }
}

Slave "Receiver" code

#include "RS485_protocol.h"
#include <SoftwareSerial.h>

// required for RS485 communications
// I AM USING NICK GAMMONS LIBRARY FOR THIS, AS IT WORKS GREAT
#define RS485RECEIVEPIN    10
#define RS485TRANSMITPIN   11
#define RS485ENABLE_PIN    3
#define RS485OUTPUTPIN     7
#define SERIALID  '5'  // this is this Arduinos ID for 2 way serial communications, and/or RS485
#define MASTERID  1
#define SLAVEID_1  5

char  gbuff[128] = "";

SoftwareSerial rs485 (RS485RECEIVEPIN, RS485TRANSMITPIN);  // receive pin, transmit pin

byte buf[] = {0,0}; 

int address = 0;
int command = 0;

void fWrite (const byte what){
  rs485.write (what);  }
int fAvailable (){
  return rs485.available ();  }
int fRead (){
  return rs485.read ();  }
  
void setup(){
  Serial.begin(9600);
  rs485.begin (9600);
  pinMode (RS485ENABLE_PIN, OUTPUT);  // driver output enable
  Serial.println("Setup completed...");
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
}

void loop(){
//   delay(100);
   Serial.println("Waiting for RS485 data");
   if(recvMsg (fAvailable, fRead, buf, sizeof buf)){
      sprintf(gbuff, "buf[0] = [%c], buf[1] = [%c]..", buf[0], buf[1]);
      Serial.println(gbuff);
      address = buf[0];
      command = buf[1];
      sprintf(gbuff, "Message received = %d%d", address, command);
      Serial.println(gbuff);

      if (address >= 0 && command < 2){
        sprintf(gbuff, "Message received = %d%d", address, command);
        Serial.println(gbuff);
         if (address != 5){  // ID = 5
            Serial.println("but message is NOT for us...");
            Serial.println(gbuff);
            buf[0] =  '\0';
            return;  // unknown command
         }
         if (command > 1){   // command = 0/1
            sprintf(gbuff, "Command [%d%d] is NOT recognised...", address, command);
            Serial.println(gbuff);
            buf[0] =  '\0';
            return;  // unknown command
         }
         if (digitalRead(13) == HIGH){
            digitalWrite (13, LOW);  // set LED to command value of 0 or 1 (On or Off)
            Serial.println("Setting LED OFF");
          
            byte Message[] = {MASTERID,1};
            digitalWrite (RS485ENABLE_PIN, HIGH);  // enable sending
            sendMsg (fWrite, (const byte*)Message, sizeof Message);
            delayMicroseconds (660);
            digitalWrite (RS485ENABLE_PIN, LOW);  // disable sending
            sprintf(gbuff,"Sending: [%d%d]", Message[0],  Message[1]);
            Serial.println(gbuff);
            buf[0] =  '\0';
          }
          else{
            digitalWrite (13, HIGH);  // set LED to command value of 0 or 1 (On or Off)
            Serial.println("Setting LED ON");
            
            byte Message[] = {MASTERID,1};
            delay (1);  // give the master a moment to prepare to receive 
            digitalWrite (RS485ENABLE_PIN, HIGH);  // enable sending
            sendMsg (fWrite, (const byte*)Message, sizeof Message);
            delayMicroseconds (660);
            digitalWrite (RS485ENABLE_PIN, LOW);  // disable sending
            sprintf(gbuff,"Sending: [%d%d]", Message[0],  Message[1]);
            Serial.println(gbuff);
            buf[0] =  '\0';
            return;  // unknown command
          }
       }else{  // end if something received
             Serial.println("No message available...");
       }
   }
}  // end of loop

I sure hope someone can help me out here, as I desperately need this functionality on my model railway project.

Thanks in advance
Ian

Hmmmmmm, seems it didnt attach the 2 serial montor files, so here they are. (hopefully)

Doesn't appear to like multiple attachments !!!!!!!

here is last one I hope.

  pinMode (RS485ENABLE_PIN, OUTPUT);  // driver output enable

You only set the pin as output but not explicitly to LOW as you do for the LED pin.

Regarding the wiring diagram: Please prefer the schematics view over the breadboard view if you use fritzing, the connections are much better visible.

In the wiring diagram the RO pin of the MAX485 is connected to pin 11 (TX) and the DI pin is connected to pin 10 (RX). This is wrong. Please check your Arduino pins if they are damaged as the wrong wiring might have produced short-circuits.

Additionally the bus should have a defined idle state (no driver active) by connecting resistors from A/B to Vcc/GND and the bus lines must be terminated on both ends. You should pulls RO HIGH to not left it floating if DE is HIGH.

Having to boards to flash some less is a bit over the top. Why don't you use one board

Thanks for detailed feedback Pylon. I have done everything you have mentioned. You were correct about the D10 and D11 being switched.

Sadly, still no communications.

Here is the best schematic I can manage, but I am pretty sure it is an accurate diagram of my setup here.

@chopperaddict, please keep posting your progress as I will likely soon be heading down this road.

Two-for-one question. Does it work if you connect the arduinos directly (ie., without the RS485 boards)? I ask to see if this is a possible test for chopperaddict and for myself, prior to obtaining converter boards. I would like to test without the added step and complexity of the RS-485 boards if I can, which may be a good step for chopperaddict as well, if this is possible.

Hi AdwSystems

I guess you mean just using RS232 comms ? I might be able to try that, although in my railway project I need communications over about 50 feet or so at worst., so RS232 is not really reliable for me. I also need multi drop functionality so that I can utilise multiple Arduinos around the layout that are able to communicate to the minimum level I require, which is mostly one way from the master "controller board" to various areas that wioll have their own Unos to handle local functionality at the behest of the master control board (a mega). I do not want to complicate my system by having multiple protocols in the code base.

I am no expert at Arduino hardware for sure, although I am reasonably well experienced in the programming arena, so it is the hardware issues that are my "bete noir" right now.

Reading the thread so far it looks as though you have only two modules setup. If that is not the case, that's my bad and you can ignore me.

With only two modules setup for development (ie., a foot or so of comm cable), have you tried bypassing the RS485 modules to see if the arduinos will talk with TTL signals. Most of the RS-485 module is for signal shifting and has nothing to do with the protocol or data. After the program is working with just the arduinos, then add the RS-485 converters.

That was to be my plan when I reached that stage, but it looks like you are there already.

P.S. RS-232 should be good for 50 feet give or take, but not for multi-drop. I have also pursued these avenues. That's how I'm started on the path you are already travelling.

OK, I will give it a try for you !! Watch this space as they say............

On the other side, are you also involved in model railway stuff ? If so, what scale etc are you working with ?

Here is the best schematic I can manage, but I am pretty sure it is an accurate diagram of my setup here.

If you're using the cheap RS485 adapter available on amazon and ebay with the blue screw terminals (it looks like in your schematics), the termination is not necessary as every module is terminated and the idle state resistors are soldered on both boards (you might have to desolder one side). Please post a link to the hardware you're using.

Please check the 3 GPIO pins on both UNOs if they're still working and didn't get damaged when you used the wrong order (might have shorted them).

chopperaddict:
On the other side, are you also involved in model railway stuff ? If so, what scale etc are you working with ?

I'm not involved with model railway. I'm not that artistic. I'm am looking to use the RS-485 ModbusRTU for a couple of distributed home automation projects.