Read RS485 data from Load Cell, using, SWIFT RAIL and MAX485

Ok, so I have a setup with:

  • Arduino Mega 2560

  • Max485

  • SWIFT RAIL

  • TYPE: DE

  • Address: 11

  • BAUD: 9600

  • PAR: none

  • Load Cell

Connections

  • Swift Rail: Data + and Data - are connected to A and B pins in the MAX485

  • MAX 485:

  • DI is not connected

  • DE to GND

  • DI to GND

  • RO to RX(0)

  • Arduino Mega to PC USB

For the connections I have followed this wiring.

I want to read the RS485 Signal in my Serial Monitor in the Arduino software.
In order to do that, I’ve been trying to write my code according to the SoftwareSerial documentation with no result, as you can see in the “SerialMonitor” screenshot.

Problems I think I have:

  • Don’t know how to put the address of the Swift Rail into the code.
  • In the code, I ask if mySerial is listening and it’s not, and the same with available.
  • For the moment I only tried to get the first character of the package, which I should modify later on, when everything else is working?
#include <SoftwareSerial.h>

const byte rxPin = 0;
const byte txPin = 1;

// set up a new serial port
SoftwareSerial mySerial(rxPin, txPin);
 
void setup()  {
  
  // define pin modes for tx, rx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  Serial.begin(9600);
  
}

void loop(){
  
  mySerial.listen();
  if (mySerial.isListening()) {
    Serial.println("Port One is listening!"); 
  }else{
    Serial.println("Port One is not listening!"); 
  }
  
  if (Serial.available()){
    Serial.println("Available");
  }else{
    Serial.println("Not Available");  
  }
  
  char iByte = Serial.read();
  Serial.println(iByte);

  delay(3000);
}

SerialMonitor.PNG

Please post a link to this "SWIFT RAIL" thingy.

For a start, don't use softwareSerial on pins 0 and 1.
try pins 10 and 11 (or any other that does not have a hardware uart)

More information on the devices you're using will help as well.

Does the Swift Rail interface thing (no link provided) just send data out all the time? Typically modbus is master slave, and the data must be requested by the master. Therefore you will need to connect DI.

If all you want to do is see RS-485 modbus data why not get a RS-485 to USB converter and assign the serial monitor to the corresponding port?

adwsystems:
Does the Swift Rail interface thing (no link provided) just send data out all the time? Typically modbus is master slave, and the data must be requested by the master. Therefore you will need to connect DI.

If all you want to do is see RS-485 modbus data why not get a RS-485 to USB converter and assign the serial monitor to the corresponding port?

Yeah I forgot about the link to the Swift Rail, here you go:

https://www.utilcell.es/wp-content/uploads/2016/07/En-De_DS_SWIFT_Utilcell.pdf

Ok that makes sense about the DI if I want to also request de Data. Actually the way I put it in the setup of the Weighing Indicator is that it transmits data by DEmand.

It is my first project with Arduino and I'm quite lost, I apologize.

I don't know if I understood you on your last sentence. The way it should work is by gathering the data and storing it on the cloud.
Do you mean connecting the usb of the converter to the PC?

josepmor:
Do you mean connecting the usb of the converter to the PC?

Yes.

josepmor:
I don't know if I understood you on your last sentence. The way it should work is by gathering the data and storing it on the cloud.

You didn't say that originally.

You say you're using Mega2560 yet your diagram shows UNO. Which is it?

DKWatson:
You say you're using Mega2560 yet your diagram shows UNO. Which is it?

It is the Mega 2560, I'm sorry for the confusion.

adwsystems:
You didn't say that originally.

My bad, I though it wouldn't make a difference. I just want to be able to read the data that's coming from the Weighting Indicator and store it.
That would be the first step in the whole project.

Then stay away from SoftwareSerial. The 2560 has 4 hardware USARTs, use one of them.

RS485 is a physical protocol and implemented as half-duplex on single-pair networks. For bi-directional communication to need to control the transmit enable pin which you currently have nailed to ground. The Modbus ASCII protocol is quite basic, but it is unlikely the unit is sitting there spewing out data and compromising the network. You should need to issue a request to which the unit responds.

You need to get more information about the communications protocol. I've been to the website and it was no help.