[SOLVED]Owon PSU and RS232 Module

Hello guys,

I have OWON P4305 power supply and it can be programmed via RS232 port. I need to send commands from RS232 module and i have this module; https://robotdyn.com/rs-232-module.html

Problem is when i send my command from arduino it did not work but if i send it from serial monitor with usb-rs232 adapter it works. And also i tried plug my module with that adapter to my pc so i can see that my commands correct. I tried using send bytes, chars, string. I wrote one by one my command with DEC and HEX format. I tried print, println and write. And also i tried crossing rx-tx pins. Still couldnt solve it. I guess my problem is sending correctly newline and carriage return bits. Please can you give me some suggestions?

Here is example one of my codes.

byte cData[100];
int nBytesAvail = 0;
int nBytes = 0;
#define rs232serial Serial1
#define hc05serial Serial
void setup() {
  // put your setup code here, to run once:
rs232serial.begin(9600);
hc05serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
if ((nBytesAvail = rs232serial.available())>0)
{
  nBytes = rs232serial.readBytes(cData, nBytesAvail);
  hc05serial.write(cData, nBytes);
  }
if ((nBytesAvail = hc05serial.available())>0)
{
  nBytes = hc05serial.readBytes(cData, nBytesAvail);
  rs232serial.write(cData, nBytes);
}
}

I am using Arduino Mega 2560 and i will use bluetooth module but i tried codes with usb plug cable so thats why serial's name hc05.

tbatuhan: i tried crossing rx-tx pins

Confusingly, the pin marked "TXD" on the module is the input and the pin marked "RXD" is the output. So your connections should be:

Arduino | MAX232 module

RX1 | RXD TX1 | TXD 5V | VCC GND | GND

pert:
Confusingly, the pin marked “TXD” on the module is the input and the pin marked “RXD” is the output. So your connections should be:

Arduino | MAX232 module

RX1 | RXD
TX1 | TXD
5V | VCC
GND | GND

But module shows reversely

Please explain what you mean by that.

I added photo. When i search on internet a guy had same problem when he uses that module for pc he solved problem with wiring as same as you said. And another guy who tried to communicate with an equipment had same problem and he solved with reversely what you said. I so confused ;D

The information I provided is based on the schematic provided at the Documents tab of https://robotdyn.com/rs-232-module.html and the MAX232 datasheet: http://www.ti.com/lit/ds/symlink/max232.pdf

If the schematic doesn't match the module, then the information I provided is wrong.

I request pinout of rs232 port from company. I will ensure if i connect correctly. Thanks for help.

I found that i need to cross rx-tx pins from out of rs232 module. When i tried to crossing rx-tx pin input of module didnt work. So,

Working setup,

Arduino rx->RS232 module rx Arduino tx->RS232 module tx

RS232 module (Female)2.pin -> RS232 plug(Male) 3.pin (Crossing RX-TX) RS232 module (Female)3.pin -> RS232 plug(Male) 2.pin RS232 module (Female)5.pin -> RS232 plug(Male) 5.pin (Commons)