Can I work with Pro-Mini+RS485+send to another Pro-Mini?

Hello ,
wanted to know (before I start)

Can I write a code for Pro-Mini that read data from RS485 , do some manipulation then send data to another Pro-Mini ?

  • I have a working code on Mega that read data from RS485 device and then send it to another RS485 device , I want to see if I can make the project smaller and cheaper (by using 2 Prp-Mini and not 1 Mega)

Thanks ,

Question: What serial ports on the Mega are you using?

on the mega I'm using TX\RX1 m TX\RX2

As I expected. What is on each serial port? RS-485 on one. What is on the other?

Koren12345:
Can I write a code for Pro-Mini that read data from RS485 , do some manipulation then send data to another Pro-Mini ?

Short answer: yes.
Long answer: it depends on your skills, and the exact hardware you use, and what it has to do, and how much data you're dealing with, and probably a few other differences between the ATmega2560 and ATmega328. But in general, yes, can.

There is also a serial port count difference.

Pro-Mini doesn't have two serial ports. You will have to find a library that works with AltSoftSerial (better than SoftwareSerial).

Or

see if a pro-micro will work for you.

**@wvmarle **
The data is not so long , maybe 100 chars once every 5 min
the reading from the RS485 to the Pro-Mini is working ,
also the sending from the Pro-Mini to the RS485 is working

the only thing is how can I connect them and make them talk?

@adwsystems - Pro-Micro also have 1 serial port , no?so its the same no?

Thanks ,

Some wires in between should do the job.

You can transmit, you can read, so what's the problem? One hardware Serial, one SoftwareSerial or AltSoftSerial (they both have their quirks), done.

I just want to be sure it can be done - that is all.

OK
I will connect everything and give it a try

I will ask if I will have any problems

Thanks ,

Koren12345:
@adwsystems - Pro-Micro also have 1 serial port , no?so its the same no?

Not the same. It has one UART port and one USB port. Hence the question as to what was on each or your current serial ports. If currently you have RS-485 on one serial port and programming on the other, then the Pro-Micro is the same.

so I have try to make it work
I can read the data and it's seem I can send it but on the 2nd Arduino I only get 0

this is what I have on the first Arduino (reading from a RS485 device BR=115200) with is working

#include <SoftwareSerial.h>

SoftwareSerial SendToARD ( 8, 9); ///Tx,Rx

void setup() {
  Serial.begin(115200);
  SendToARD.begin(115200);
  Serial.println("Read Data From 1st Device");
 


}

void loop()
{
 
byte Test [200] ={NULL};

// create sample test message 200 chars 
for (int i=0;i<sizeof(Test);i++)
{
Test[i] = i;
}

SendMSG[SendMSGint] = {0xFF}; // my own End Of Message char 
SendToArduino(Test , sizeof(Test) );


delay (300000); 
        
 
}



void SendToArduino (byte MsgArray[] , int MsgArraySize)
{
  SendToARD.write(MsgArray , MsgArraySize);

  Serial.println ("Sending Data to Arduino - Done!");


}

this is what I have on the 2nd Arduino (read from 1st Arduino)

#include <SoftwareSerial.h>

SoftwareSerial SendToARD ( 8, 9); ///Tx,Rx

void setup() {
  Serial.begin(4800);
  ReadFromARD.begin(115200);
  Serial.println("Send Data to 2nd RS485 Device!");
 


}

void loop() {

  int i = 0;
  while ( ReadFromARD.available() > 0 )
  {
    char temp= ReadFromARD.read();

     if (temp != 0xFF)
     {
          FromARD[i] = temp;
          i++;
          Serial.println(FromARD[i] , HEX);
     }

     else
       {
   
          SendToSign(FromARD , sizeof(FromARD) );
       }


  }

}

void SendToSign (byte MsgArray[] , int MsgArraySize)
{
// 
//

//


}

when I open the monitor I only see "0" 200 times

so what am I missing ?
I have connected
Pin9(ARD1) to Pin8(Ard2)
Pin8(ARD1) to Pin8(Ard1)

Koren12345:
so I have try to make it work

What are you trying to make work?

I don't use SoftwareSerial so I cannot compile your programs myself. But from looking at the sketch for Arduino #2, I doubt you can get that one to compile either.

What is the connections between Arduino #1 and #2? RS-485, RS-232, TTL Serial?

Koren12345:

          FromARD[i] = temp;

i++;
         Serial.println(FromARD[i] , HEX);

You receive a character, write it to the array, increase the index of that array, then print the character of the array the just increased index is pointing to. As nothing has been written to that element of the array yet, this value will be 0 (zero).

Swap the second and third line, or print temp.

What you see and what you get are two different things. You hit the problem with the first swing. You are sending hex values and expecting them to be displayed as ASCII. You show you knew that wouldn't work. Because 0xFF won't display doesn't mean it wasn't sent. Convert the HEX values to ASCII values you can see and try again. (or you could follow the example from wvmarle and use the HEX parameter for Serial.print() )

Also posting a code snippet doesn't allow anyone to look elsewhere in the program to help determine what is wrong (because this obviously isn't it).

Understand what you're actually transmitting... remember that to a computer it's all ones and zeroes.

Indeed snippets are often useless when it comes to finding problems. More often than not the problem is in the part you didn't post!

I have try now for 3 days to do it alone - didn't work
so I will give you all the information to help me

in the first Arduino I have a byte array and I'm trying to send it to the 2nd Arduino by using

SendToArd.write(0x9E ) //this is for me to know that message start 
SendToArd.write( msgAaray,sizeof(msgArray) ) // the message 
SendToArd.write( 0x9F ) this is for message end

in the 2nd Arduino I have this simple reading code :

#include <SoftwareSerial.h>

SoftwareSerial ReadFromARD ( 8, 9); ///tx,Rx

void setup()
 {
  Serial.begin(4800);
  ReadFromARD.begin(115200);
  byte rc;

   

}

void loop() 
{
while  ( ReadFromARD.available() > 0)
    {
      rc = ReadFromARD.read();  
      Serial.print(rc , HEX);
      Serial.print (" , ");
 

}

the output of the 2nd Arduino is this

F7 , F4 , E0 , 2D , FA , E5 , E2 , F1 , F4 , EC , 20 , 31 , 31 , 20 , E5 , F7 , 20 , 73 , 5C , 70 , 5C , 70 , 5C , 31 , 38 , 3A , 31 , 30 , 20 , 3A , E6 , E0 , E9 , F6 , E9 , 20 , EF , EE , E6 , 20 , 73 , 5C , 70 , 5C , 7C , 5C , 20 , 20 , 22 , ED , E9 , F7 , E9 , F4 , E0 , 22 , 20 , 28 , E4 , E7 , E5 , E8 , E1 , E5 , 30 , E4 , E1 , E5 , E8 , 20 , E4 , F2 , E9 , F1 , F0 , E9 , E3 , 9F ,

the full message been sent is (I have check it by connecting the 1st arduino to my computer and open putty to be sure what beeing sent)

9E F7 F4 E0 2D FA E5 E2 F1 F4 EC 20 31 31 20 E5 F7 20 73 5C 70 5C 70 5C 
31 37 3A 35 36 20 3A E4 E0 E9 F6 E9 20 EF EE E6 20 73 5C 70 5C 70 5C 20 
20 22 ED E9 F7 E9 F4 E0 22 20 20 E4 E7 E5 E8 E1 E5 20 E4 E1 E5 E8 20 E4 
F2 E9 F1 F0 20 36 36 38 36 2A 20 E9 F6 F8 E0 20 F2 E3 E9 EE 20 E6 EB F8 
EE 20 2E 2D 20 9F

why?
I can't seem to understand why he cut me the message

I have try all kind of messages , all of them got "cut"
so what could be the reason ?
between the Arduinos I have Tx\Rx\GND connected

  • I can guess this if I had a electric\gnd problem I wouldn't get any data at all ,no ?
    Thanks ,

Koren12345:
I have try now for 3 days to do it alone - didn't work
so I will give you all the information to help me

That would have been nice in the first place as well as this time. Where is the full sketch for the 1st arduino? Additionally, that cannot be your sketch for the second Arduino as it does not compile. Please post both sketches you are using, in the entirety.

Besides all of that, any search on your part would have showed that Software serial max speed is around 19200 or 38400. So running SoftwareSerial at 115200 will not work. Change the speed to 19200 and try again.

WOW ,
I didn't know this :slight_smile:

this seem like the first thing I would check

and thank you !
after change the rate between the devices to 1200 it's working without any problem !

Thanks!

1200 is really slow! Sure that's not supposed to be 19200?

when I try to put 19200 , it got stuck - and didn't print me the all data
which is strange ,
but in 1200 it's working without any problem so far