CRLF RS232 in Arduino

Morning everyone,

Well, actually i’m a newbie in Arduino, I just know a bit of programming in Arduino,
But somehow i get a complicated project using Arduino from my school, (Which i think it should be easy in the first time, because it just using one input and one output)
But somehow, what i deal is different from what i think, so i really need your help guys.

What i need to do is connecting Arduino to a solar controller device using RS232. Then i should transfer the data i was obtained from Solar Controler to Server using ethernet. I use database mySqL in my server. And actually, i’ve done the part of database and ethernet things. However, i still stuck in the RS232 things. Because i don’t know a thing about serial communication and have no experience in this.

I have Arduino uno with shield ethernet from lextronic and a cable RS232 DB 9 male to male.
The protocol of communication in Solar Controler run like this:
" To retrieve the data the PC must send F
Response of the SCD (Solar Controler): In this sequence the data will be returned as ASCII signs.
For testing purposes you can use the HyperTerminal Program.
R: current voltage; current power; current temperature; minimum voltage; maximum voltage; minimum power; maximum power; CRLF
To delete the minim
um/maximum data the PC must send L"

What i’ve done is try to connect the device with my laptop and communicate using hyperterminal program by sending F (When i type F and enter) it would answer with the data.
So what i think is, i just need to send or serial.write(“F”) in arduino then receive the data by using serial.read(), But it’s not work,
this is the last code i made

#include <SoftwareSerial.h>

SoftwareSerial mySerial(3,5); // RX, TX


void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(1200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.println("Connected");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(1200);
}

void loop() // run over and over
{
  if (mySerial.available())
    mySerial.write("");
    Serial.println(mySerial.read());
    delay (10000);
}

I send the result with hypertherminal program too.
I really need your help guys, and i’ll appreciate and thanksful for every helps from you

Warmest Regard

What i need to do is connecting Arduino to a solar controller device using RS232.

How is the Arduino connected to the solar controller device ?
As far as I can see you have made no attempt to send F anywhere.

“” To retrieve the data the PC must send F"

You are probably already aware the means you send a 0x0D, followed by a 0x0A.

Paul

Thanks everyone,

well, like i said, i’m a really newbie in serial communication,

“You are probably already aware the means you send a 0x0D, followed by a 0x0A.”

actually i don’t aware of it and i don’t know how to do, Can you help me how to do that?
so what i do in my code is

mySerial.write(“F”)

That’s what i think because when i try to retrieve data from solar controler i used rs232 to usb on my computer and use hyperterminal program, i just type “F” and i get the data.

this is the last code i made

#include <SoftwareSerial.h>

SoftwareSerial mySerial(5,3); // RX, TX

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(1200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

Serial.println(“Connected”);

// set the data rate for the SoftwareSerial port
mySerial.begin(1200);
}

void loop() // run over and over
{
if (mySerial.available())
mySerial.write(“F”);
mySerial.listen();
for (int i = 0; i<16; i++){
char myByte = mySerial.read();
Serial.write(myByte);}
Serial.println();
delay (10000);
}

actually i don't aware of it and i don't know how to do, Can you help me how to do that?

Change

mySerial.write("F")

to

mySerial.println("F")

And the F will be followed by a CR/LF.


Rob

Morning

i've try change to mySerial.println("F") followed by CRLF
but this is what i got
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,
i think its the same F that i send to mySerial,

i figured out something, the RS232 port in my solar controler is female, my RS232 shield is also female, so i buy a RS232 cable, but i don't know that there is two type cable, DTE and DCE,when i check the cable with volt meter, i think the cable is DCE type because it has voltage in the pin 2 not in pin 3.

is there any suggestion on how is my code? if i should buy i new cable, is there any suggestion too?

There are a couple of questions in this one:
a) you said your controller is setup to communicsate through RS232. If that is the case RSR-232 operates at 12V levels.
b) the ethernet/Arduino board you mention does not have a DB-9 connector for Serial. On the pictures there is a a RS-232-TTL to USB module. So where do you connect de DB-9 connector?
c) Is there no data sheet of the Solar controller?

ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,

It looks like the rubbish you get when there is a mismatch of baud rates between the Tx and Rx ends of serial comms.

a) you said your controller is setup to communicsate through RS232. If that is the case RSR-232 operates at 12V levels.
b) the ethernet/Arduino board you mention does not have a DB-9 connector for Serial. On the pictures there is a a RS-232-TTL to USB module. So where do you connect de DB-9 connector?

I'm really sorry, i don't have a clue for those two questions. I just connect my arduino with RS232 shield that i bought from lextronic here is the detail, and i use a male to male RS232 cable (that i think its DCE type),

www.lextronic.fr/P29284-platine-shield-rs232-pour-arduino.html

this is the only document i've for my controller,

Thanks for your helps,

Morning Everyone,

Thanks for your attention,

somehow i found out that i've a problem with my cable, which is Straight forward, when i see the shield schematic, i found out that it send data from pin 2 and receive in pin 3. in the other site, my shield also send in pin 2 and receive in pin 3, so i think i've a stuck in that, so i'm planning in adding a null modem converter so it would change the pin.

i'd inform you later if it run well,
thanks a lot

warmest regard
bima

Thanks alot guys for your help,
it run very well,

but i've a bit problem in separating the data, if you mind to help me, i post my problem here,