Hello ,
I want to connect to a serial device , read data and add some data , send it to another serial device.
can I use 2 arduino pro mini for this?
the reading code is almost working on the pro-mini
the sendgin code is almost working on another pro-mini
the code is just to see I know how to read and how to send
I just want to know how can I "connect" them
If "device1" only sends and "device2" only receives and they both use the same baud rate and character format you can use the single hardware serial port for both.
david1234:
device1 is 115200 sending only
device2 is 4800 reading only
same format
still a problem ?
Yes. You can't set the TX and RX sides of the hardware serial port to separate baud rates.
You could use SoftwareSerial to send the data to "device2" at 4800 baud and use the hardware serial port to receive from "device1" at 115200.
david1234:
in the loop I will listen to "device1" when I get from him end char , I will send the data to device2?
the data is going to change once every 5 min ~
Do you mean that you get 1 message from "device1" every five minutes? Or at least there are large gaps between messages? If so, you could use this trick to switch baud rates between reading and writing:
// Message received from 'device1' and changes made in "char buffer[];"
Serial.end();
Serial.begin(4800); // 'device2' baud rate
Serial.write(buffer);
Serial.end(); // Includes a .flush() so it waits for the send buffer to empty
Serial.begin(115200); // 'device1' baud rate
// Go back to looking for the next message from 'device1'.
}
send the data to "device2" at 4800 baud and use the hardware serial port to receive from "device1" at 115200.
Device1 is sending message every 5 min , sometime even more - could be 1 hour even...
and only after I get the message I need to add some data - and send it to device 2
they never will work together , only Half-duplex on each side .
I will start working on it - and ask here when I will have more questions
I just wanted to know I can do it 1 arduino , so I will not waste time...