Hi there,
I am trying to connect a device with Rs232 output to Arduino. I bought a rs232 Arduino shield but although I tried several time the software serial with different pin (2-7)to connect them I couldn't receive any thing from device I know the device is working well because with other connector (rs232 to usb) I can see the data in computer.
softwareSerial Myserial (rx, tx)
Any advice?
Regards,
Ali
softwareSerial Myserial (rx, tx)
If that's all your code I think I see the problem.
If not why did you post it?
With regards to the shield (rs232 Arduino shield).
Below is the code which I used.
#include <SoftwareSerial.h> //we have to include the SoftwareSerial library, or else we can't use it
#define rx 2 //define what pin rx is going to be
#define tx 3 //define what pin tx is going to be
SoftwareSerial myserial(rx, tx); //define how the soft serial port is going to work
String inputstring = ""; //a string to hold incoming data from the PC
String sensorstring = ""; //a string to hold the data from the Atlas Scientific product
boolean input_string_complete = false; //have we received all the data from the PC
boolean sensor_string_complete = false; //have we received all the data from the Atlas Scientific product
float pH; //used to hold a floating point number that is the pH
void setup() { //set up the hardware
Serial.begin(9600); //set baud rate for the hardware serial port_0 to 9600
myserial.begin(9600); //set baud rate for the software serial port to 9600
inputstring.reserve(10); //set aside some bytes for receiving data from the PC
sensorstring.reserve(30); //set aside some bytes for receiving data from Atlas Scientific product
}
void serialEvent() { //if the hardware serial port_0 receives a char
inputstring = Serial.readStringUntil(13); //read the string until we see a <CR>
input_string_complete = true; //set the flag used to tell if we have received a completed string from the PC
}
void loop() { //here we go...
if (input_string_complete) { //if a string from the PC has been received in its entirety
myserial.print(inputstring); //send that string to the Atlas Scientific product
myserial.print('\r'); //add a <CR> to the end of the string
inputstring = ""; //clear the string
input_string_complete = false; //reset the flag used to tell if we have received a completed string from the PC
}
if (myserial.available() > 0) { //if we see that the Atlas Scientific product has sent a character
char inchar = (char)myserial.read(); //get the char we just received
sensorstring += inchar; //add the char to the var called sensorstring
if (inchar == '\r') { //if the incoming character is a <CR>
sensor_string_complete = true; //set the flag
}
}
if (sensor_string_complete == true) { //if a string from the Atlas Scientific product has been received in its entirety
Serial.println(sensorstring); //send that string to the PC's serial monitor
if (isdigit(sensorstring[0])) { //if the first character in the string is a digit
pH = sensorstring.toFloat(); //convert the string to a floating point number so it can be evaluated by the Arduino
if (pH >= 7.0) { //if the pH is greater than or equal to 7.0
Serial.println("high"); //print "high" this is demonstrating that the Arduino is evaluating the pH as a number and not as a string
}
if (pH <= 6.999) { //if the pH is less than or equal to 6.999
Serial.println("low"); //print "low" this is demonstrating that the Arduino is evaluating the pH as a number and not as a string
}
}
sensorstring = ""; //clear the string
sensor_string_complete = false; //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
}
}
Hi,
Welcome to the forum.
Please read the first post in any forum entitled how to use this forum.
Which RS232 shield?
- Supplier.
- Model Number.
- Picture.
- Library (if any).
Sorry, but what you are telling us is like, you have a car, tell me how to drive it?
You could have a Model-T, 57 Chevy, Tesla, Prius, or a Stanley Steamer, each you drive differently.
Thanks.. Tom. 
Attached is the rs232 shield which I used
Below is the link to rs232 shield which I used.
Thanks
OK so what links have you made on the board?
And which connections on the board?
Your board is advertised on that site under
Home>PRODUCTS>Kits, Science & Learning>Science /Lab Equipment>Models/Puzzles
and it looks like it will be one 
Did it come with any documentation? If so, read it and set it up. If not, try to understand what all jumper fields are for. There must be a way t configure it for pin 0/1 or for other pins for software serial. A multimeter can be useful to figure it all out.
Hi
As you can see in the code I have configured the softwareSerial with pin 2,3 (rx, Tx) and the jumper set to pin 2,3 but I couldn't received any data from device output.
Thanks
Ali
Start simple. Communicate with a computer with RS232 port (or USB/RS232 adapter). Send some data from an Arduino sketch and use something like Putty or Realterm and see what comes in. Once you have tat working (see thought 1 below as well), write a sketch that reads from the serial port and e.g. echoes it.
Once that's working, you should be ready to connect it to the device (you might have to swap pin 2 nd 3 again).
Other thoughts
1)
You might also have pins 2 and 3 swapped.
2)
I assume you have tested you device against the computer?
3)
Any handshaking required by the device?
Thanks for your respond
As I said before, the device is working well with computer through rs232 to usb converter.
However I can't receive any data by rs232 Arduino shields.
Is there any way to connect the converter (rs232 to usb) to Arduino through usb?
Regards,
Ali
AlirezaRabieh:
Thanks for your respond
As I said before, the device is working well with computer through rs232 to usb converter.
However I can't receive any data by rs232 Arduino shields.
Is there any way to connect the converter (rs232 to usb) to Arduino through usb?
Regards,
Ali
Ali, are you sure you're device is using RS-232? The comments in your code mention Atlas Scientific devices. They don't use RS-232, but UART. So, in case you'r "device" is an EZO circuit, you will not need that RS-232 shield. You can hook up those stamps directly to the pins of your Arduino.
Patrick