Go Down

Topic: Read and send HEX sting by serial (Read 7035 times) previous topic - next topic


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


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.


Can you connect the serial shield to the computer ?

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


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.


Jan 04, 2013, 05:48 pm Last Edit: Jan 04, 2013, 06:24 pm by rmartin Reason: 1
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!

Code: [Select]

#include <SoftwareSerial.h>

//New serial port for my shield
SoftwareSerial Mx3232Serial =  SoftwareSerial(7, 8);

//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);



void loop() {
//leggo dalla seriale(pin7)
//EchoChar = PortaSeriale.read();
//invio il dato letto


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        




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

Code: [Select]


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


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.

Code: [Select]


or this

Code: [Select]

Mx3232Serial.println("");       // send CR LF

or even this

Code: [Select]

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?



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?



Some devices label them backwards.

"From a different perspective" is the politically correct way of phrasing that.
The art of getting good answers lies in asking good questions.


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?


The weigher work correctly connected directly to my pc!

So is your pc serial port TTL or rs232?
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


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


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


Go Up