Hello Community, this is my first post.
I have a little problem with a serial communication on my Arduino Mega. Here is my code which I used for testing:
int module1 = 22; //Module1
void setup() {
Serial.begin(9600); //Serial Object for PC Communication
Serial1.begin(115200); //Serial Object for inverter module
pinMode(module1, OUTPUT);
digitalWrite(module1, HIGH); //Set the Select Pin on the Header of the Module on HIGH to
enable the Serial communication
}
void loop() {
if (Serial1.available()){
while (Serial1.available()){
Serial1.println("%in+CR+NL"); //this is a command to read serial number
Serial.println(Serial1.read());
delay(200);
I have a serial Object (in this case it's an inverter from the company Flexiva) and I want to control it with the Mega. The company supplies a software, to configure the modules via RS232. I used a PL2303HX to communicate with it and it works fine. Now I want to use my arduino to send and recieve data from the module (115200 Baudrate) and read the answer via USB (9600 Baudrate).
I can send data to the module, but I recieve only numbers which doesn't make any sense. Does anybody have experience with two serial communications and how to send data from one to another ?
The idea is to use a raspberry pi to control the inverter at the end.
Thank you