Read and send HEX sting by serial

My dear Friends
I need to read and write a weight from a precision weigher that have a rs232 serial port

The problem is how to receive by Arduino the right weight from the weigher?

If i'll connect the weigher to my pc with serial and send the EXADECIMAL command 01 73 I obtain like response a string with thw weight for example 0023.05g

I buy a RS232 shield with max 3232 I connect to the weigher, but nothing...
Can you help me?
How can I send to my weigher the HEX 01 73 string and listen the reply?
thanks a lot
Fabio

Tell us how it is connected, and which Arduino you are using.
Also post a link to the shield.

The best way to do this, is to keep the RX and TX for the serial monitor on the PC and to upload the Arduino sketch. Use other pins with SoftwareSerial to control the weighting appartus.

Dear Krodal

thanks for your reply.
I use Arduino UNO, comnnected to a RS232 shield

you can see the connection in this photo

For the rs232 shield i connect the VCC to the +5v of the arduino and the ground to the Arduino Ground
For the trasmission I connect the 7 and 8 pin.

I try all examples found in internet by using serial and serial library, but never.

First question: in the code I need to open one or 2 serial port?
How i can to be sure that I can write and read on the serial?
When I connect the shield to the arduino my pc make a "pling" like i connect a new usb device, is this correct?

thanks for youe support Fabio

You use Arduino Uno : good.
The RS232 shield with MAX3232 chip : good.
Wiring : not sure.
Sketch : don't know.

The TX of the shield should probably be connected to the RX of the Arduino.

If a new device is connected to the computer, it makes the "pling" sound. So if you plugin the Arduino with USB connector, the computer noticed that a new device is connected.

Can you connect the serial shield to the computer ? It could be even the same computer. And if you send text over that serial port, you could try to read it with the Arduino.
If that is working, you can try the digital scale.

Krodal:
Can you connect the serial shield to the computer ?

how? by mini usb?
I don't understand how you suggest me
thanks
Fabio

You wrote that you can connect a PC with a serial port to the weigher.
You also connect the Arduino with USB to the PC.

So you could connect both the serial port from the PC to the RS232 shield to the Arduino and also connect the USB to the Arduino.
You have to use a second serial monitor program for the serial port.

This way you can test everything without using the weigher.

Yes! Thanks a lot Krodal
I try to connect my arduino and shield to a serial COM3 and with another serial converter COM4, I monitor the COM4 and I show that the arduino send correctly the string!!!

This code work!

#include <SoftwareSerial.h>
 
//New serial port for my shield
SoftwareSerial Mx3232Serial =  SoftwareSerial(7, 8);
 
//variabile
//char EchoChar = 'A';
char Str1[ ] = "s";

//String Str1 = " s";
//String Str1 = String(' s',HEX);


String Buffer; unsigned long T;

void setup()  {
//pin7(RX) Input
pinMode(7, INPUT);
//pin8(TX) Output
pinMode(8, OUTPUT);

Mx3232Serial.begin(9600);

Serial.begin(9600); 
}
 
void loop() {
//leggo dalla seriale(pin7)
//EchoChar = PortaSeriale.read();
//invio il dato letto
Mx3232Serial.print(Str1);

//Serial.println(Mx3232Serial.read());
 
Buffer = "";
T = millis();

  while (millis() - T < 10)  {         // read all the chars on the serial 
    while (Mx3232Serial.available() > 0) {
      Buffer += char(Mx3232Serial.read());
    }
  }
  
  if (Buffer.length() > 0) {           // transmit to Serial Monitor        
    Serial.print(Buffer);
  }

delay(1000); 

Serial.print(Str1);

}

Now the problem is, how to send the HEX 01 73 string to my weigher and receive the weight?
If with my serial monitor I send this HEX string it work, with arduino NO!

I try to send this

Mx3232Serial.write(0x01);
Mx3232Serial.write(0x73);

but dosen't work! Now my question is how to dend in HEX this string?
thanks
Fabio

Sorry that I didn't understand it with the first post.

I think it has to do with the Carriage Return (CR, '\r', 0x0D) and/or Line Feed (LF, '\n', 0x0A).
If you connect the weigher to the PC, you probably send the code with CR and/or LF.
You could read the specification of the weigher, but I would start to send them both.

Mx3232Serial.write(0x01);
Mx3232Serial.write(0x73);
Mx3232Serial.write("\r\n");

or this

Mx3232Serial.write(0x01);
Mx3232Serial.write(0x73);
Mx3232Serial.println("");       // send CR LF

or even this

Mx3232Serial.println("\x01\x73");   // send 0x01, 0x73 with CR LF

=( =( =(
Oh my good tried more and more time, but never.
I have no reply by the weigher.

what do you think is possible to make for a different carriage return?

Fabio

If you haven't tried already, consider testing with your TX and RX connections to the scale swapped. Some devices label them backwards.

Confirm you have a good ground connection to the scale?

-br

Some devices label them backwards.

"From a different perspective" is the politically correct way of phrasing that.

The weigher work correctly connected directly to my pc!
The weigher work correctly if I sebd the HEX command by a Port monitor.
And If I try to montor the ARDUINO by the Port monitor software i show the right command, If with my port monitor software I try to send a string my Arduino Monito show this string

I think that my arduino monitor read correclty or not?
thanks
Fabio

The weigher work correctly connected directly to my pc!

So is your pc serial port TTL or rs232?

Have you tried connecting your rs232 shield to the rs232 on your PC. Then do a simple sketch to echo your arduino serial connection over rs232 to check that it's connected up properly. This is to make sure its all connected up properly

zoomkat:

The weigher work correctly connected directly to my pc!

So is your pc serial port TTL or rs232?

RS 232, is a standard USB port with a converter USB to RS232

Fabio

tobyb121:
Have you tried connecting your rs232 shield to the rs232 on your PC. Then do a simple sketch to echo your arduino serial connection over rs232 to check that it's connected up properly. This is to make sure its all connected up properly

Yes! I hav made and it work well (look the latest snapshot), now the problem is when I attache the arduino to the weigher, I doesn't receive any reply!

thanks for your support!
Fabio

Ok, this is a bit of a long way round, but try now sending over RS232, from your pc this time, the commands you normally send, but connect the RS232 to your arduino and have it echo them back to the serial monitor, which should show you exactly what is being sent to the scales. You may want to try something like realterm for windows, as this will show you exactly what characters are being sent, including \r and \n, and you can also do things like put it into hex mode so that it shows you the hex values of each byte it receives rather than the ascii representation.

Made and apparently work

here you can see the result by sending the aaaa (string) and the 01 73 (hex) with a serial port monitor
the Arduino echo serial show aaaa and "space" + s exactly the encoding of the HEX value in string
...
and now??? why my weigher don't make me and echo on the Arduino monitor? =( =( =( =(
thanks for your support
Fabio

Can you help me how I can be sure that my Arduino read correctly on his serial port?
I connect the arduino to the weigher but i doesn't receive anithing!
thanks
Fabio

@rmartin, DO NOT CROSS-POST AGAIN.

Thread locked.

Replies go here...
http://arduino.cc/forum/index.php/topic,119097.0.html