Read and Interpretate RS485 signal with MAX 485 and Arduino

Hello everybody:

Well, this is my problem, there's a signal coming from a central server which is RTU RS485 protocol (I'm 100% sure about that), I'd like to traduce that signal into ASCII characters after pass through a MAX 485 and the Arduino and present them in the serial monitor of the computer.
I'm also sure that the central server is sending only numbers. So basically I'd like to communicate the server with an slave arduino.
I don't have any preliminary code (for people who ask) and I'm very new in this topic of communicating micro-controllers

Has someone worked in this kind of project? Do you suggest an specific library? Someone has a example code for my problem.

I'm using an arduino MEGA and a MAX RS485

Thanks for responding

I wonder if the examples in Serial Input Basics would be useful. Simple reliable ways to receive data.

I think you will smile when you look up "traduce" in your dictionary. Maybe you mean "translate" - but I would be surprised if the data is not already in ASCII characters.

...R

Thanks Robin2, I'll check your information. Sorry for the wrong word jaja, I'm not a native English speaker.

Thanks ! I'll let know if have questions.

Do a Google for nick gammon 485 and will find some arduino/rs485 related info

Hello,

Here is the code that I'm using and I attached an image too for illustrating the connections

Could someone help me ?

#include <SoftwareSerial.h>

#define SSerialRX 10
#define SSerialTX 11

#define SSerialTxControl 12

SoftwareSerial RS485Serial(SSerialRX, SSerialTX);

int data_received;


void setup()
{
  Serial.begin(9600);
  RS485Serial.begin(9600);

  pinMode(SSerialTxControl, OUTPUT);

  digitalWrite(SSerialTxControl, LOW);
  
}

void loop()
{
 if(RS485Serial.available()>0)
 {
  data_received = RS485Serial.read();

  if  (Serial.available()>0)
  {
    Serial.println(data_received);
  }       
 }
}

Your Original Post said you were using a Mega which would be much better because it has extra HardwareSerial ports. But your photo shows an Uno.

If that was my project I would start by "listening" with the second example in Serial Input Basics

What is the purpose of the SSerialTxControl ? Post a link to the datasheet for the device you are using.

...R

Actually it was my fault, sorry for that :confused: ; I wanna work with an Arduino MEGA but I was just testing with UNO to feel familiar with the code.

I had some questions for you please, hope you don't get bored because I'm very new in this topic.

The controllers that I want to replace (with arduinos) show in a label that they receive RS485 signals as inputs, and those signals come from the server of the BMS (Building Management System) and coming through a CAT 6 UTP 4 cable; in the controllers, only 2 (green and white) of the six wires of the big CAT 6 cable enter inside the controller (see photo), so that makes me think that they are the signal A and B of the RS485 protocol (differential voltage).

So I'd like to use an arduino MEGA and supposedly a MAX 485 in order to determine what characters are coming to the controller when I send commands from the BMS.

I'm not sure how to connect the MAX 485 with MEGA or if I should use two different serial ports or bauds.

As I described before, in this case the MEGA would be a slave and the master would be the computer and the server as well, but I'm a little confused how can I read and then write the character that is coming to the Arduino Mega and finally show that character in the serial monitor of my PC; in other words, it will be like sending characters from one pc to other but with different software and I'm pretty sure that the information in this case are only numbers, but not totally.

What is the necessity of reading those values? Because they will be used as inputs for the Arduino MEGA to control DC motors, but that part it's piece of cake (I think).

What library would you recommend? Or what would be the right way to connect the Arduino with MAX 485?

Thanks so much for your attention

What is the device on the right of the breadboard in the picture in Reply #4. I'm guessing that converts RS485 to TTL. Please post a link to its datasheet.

I suspect that the link I already gave you will be sufficient - but I need to read the datasheet. RS485 is just an electrical specification to provide reliable transmission.

It would also be very useful to see the specification for the data provided by the BMS.

...R

Hi,
You need one of these;


And a terminal program to run on your PC, to evaluate what the 485 signal consists of.

Tom.... :slight_smile:
PS, they are much much cheaper if you go looking with google and ebay.

http://www.ebay.com.au/sch/i.html?_nkw=rs485+usb+ftdi&_fromfsb=0&_trksid=m270.l1313&ul_noapp=true

Thank you TomGeorge for the idea, I'll consider it.

Robin2, sorry for the late answer, I had to travel over the weekend.

Well, you are correct (I think) it's a converter to TTL.
As for your other requirement (BMS) I don't have that information. But I can try to find it for you, if you really require that.

I've attached the required datasheet.

Let me know if you have some ideas for this project.

Thanks for your interest

dlokura10:
As for your other requirement (BMS) I don't have that information. But I can try to find it for you, if you really require that.

I don't know about me but YOU definitely require it.

Your datasheet link does not work for me. And just to be clear I want the datasheet for the module you are using, not for the MAX485 chip.

...R

Hey TomGeorge:

Could you please suggest a software that you were talking about ? Thanks