how to get weight form Weight Scale and ek 300i

Hello, I am use arduino mega 2560 for get weight form Weight Scale by rs232 to ttl
I try all buad rate but Can't read data
i use
rx = 14 > tx rs232 to ttl > and ek 310i
tx = 15 > rx rs232 to ttl > and ek 310i
rs232 vcc > 5V

this is manual weight scale

#include <SoftwareSerial.h>
SoftwareSerial weightSerial(14, 15);


void setup() {
weightSerial.begin(9600);
Serial.begin(9600);

while (!Serial){
  ;
}
 Serial.print("Wait");
}

void loop() {
 
  if (weightSerial.available()) {
   Serial.println(weightSerial.read()); 
   delay(2000);
  }
  if (Serial.available()) {
   Serial.println(weightSerial.read()); 
    delay(2000);
  }

}

MAX3232 RS232 to TTL / Female Serial TTL / serial module / Brush board MAX3232 chip
RS232 to TTL / Female Serial TTL / serial module / Brush board MAX3232 chip line to send Dupont
The products are widely used in radio modification, cell phones Brush, XBOX360 Brush, GPS, vehicle inspection, DVD Brush, hard disk repair, set-top box upgrades.
Can be used to program the microcontroller type:
STC microcontroller
STM32 MCU
NXP microcontroller
Renesas MCU
NEC MCU
Communications chip: Domestic MAX3232
Operating voltage: 3.3V-5.5V
Interface: TX RX VCC GND

Sorry i am bad english. Please forgive my stupidity.







Post a link to the datasheet or user manual for the scales.

Don't post pictures of code - they are unreadable and they can't be copied to a text editor. Just copy and paste the code as text and use the code button </> so it looks like this. See How to use the Forum

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

Sorry brother.

this is manual weight scale

#include <SoftwareSerial.h>
SoftwareSerial weightSerial(14, 15);


void setup() {
weightSerial.begin(9600);
Serial.begin(9600);

while (!Serial){
  ;
}
 Serial.print("Wait");
}

void loop() {
 
  if (weightSerial.available()) {
   Serial.println(weightSerial.read()); 
   delay(2000);
  }
  if (Serial.available()) {
   Serial.println(weightSerial.read()); 
    delay(2000);
  }

}

It was a real PITA to get a PDF of that manual. Anyway ...

It says at the start of Section 9 "Transmission form Asynchronous, bi-directional, half-duplex" and I am not sure what is the implication of "half-duplex".

If the second example in my Serial Input Basics does not work at 9600 baud then you will need to research what needs to change to deal with half-duplex.

I am assuming 9600 baud is the default as I can't see how you change the baud rate on the scale.

...R

Thank you brother.
I was Try the second example.
but no data send to my arduino,I look at rx led on arduino board. LED does not blink .
Is it possible If it is about IC of rs232?
I use Max3232 in now,And will it be possible if I use IC Max232cpe?

#include <SoftwareSerial.h>
SoftwareSerial weightSerial(14, 15);
const byte numChars = 32;
char receivedChars[numChars]; 
boolean newData = false;
char a;
void setup() {
weightSerial.begin(2400);
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}



void loop() {
recvWithEndMarker();
showNewData();
w();
}



void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;
    
    while (weightSerial.available() > 0 && newData == false) {
        rc = weightSerial.read();

        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
    }
}


void w() {
if (Serial.available()){
   a = Serial.read();
weightSerial.print(a);
Serial.println(a);
}
}

I ask webmaster of weight Scale. Him told me "buad rate is 2400" and pin of rs232c in scale is db9 use pin 2 3 5 And do not need to send data to get weight. Scale will send weight data regularly.
rx = 2
tx = 3
5v = 5

Have you tried my second example at 2400 baud? What happened?

...R

I was try second example at 2400 baud.
and so sorry rx led on arduino board. LED does not blink .

Why do you run SoftwareSerial on HardwareSerial pins?

l2eserved:
rx led on arduino board. LED does not blink .

The RX led only blinks for receives on Serial.

Oh sorry ,Please forgive my stupidity.
Thanks you for teaching me.
I will try in tomorow.
Current time is 09:53pm in thailand.
thanks you again and again

l2eserved:
I was try second example at 2400 baud.

Please don't post pictures of code as it can't be read and it can't be copied to a text editor.

Just copy and paste code and error messages as text and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

...R

i try code

const byte numChars = 32;
char receivedChars[numChars]; 
boolean newData = false;
char a;
void setup() {
Serial1.begin(2400);
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}



void loop() {
recvWithEndMarker();
showNewData();
w();
}



void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;
    
    while (Serial1.available() > 0 && newData == false) {
        rc = Serial1.read();

        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
    }
}


}

out put is -1

l2eserved:
i try code

out put is -1

What is this line supposed to do?

w();

I don't think that code will compile?

And when you say "out put is -1" do you mean that it shows "This just in ... -1"

If not, please post all of the output from the program, including the part.

...R

w(); is i try serial print serial of rs232 with out serial available >0
When I post I delete this code but I forgot delete w();
out put have a not This just in ... I thik output is -1 form w();

void w(){
int a;

a = Serial1.read();

Serial.print(a);

delay(1000);

}

and I was try another code form other website but I don't remember where website of this code.
output is 8bit FFFFFFFF

l2eserved:
w(); is i try serial print serial of rs232 with out serial available >0

The code you posted in Reply #11 did not have the code for your w() function.

If you want my help post the complete program in your next Reply.

...R

code

const byte numChars = 32;
char receivedChars[numChars]; 
boolean newData = false;
char a;
void setup() {
Serial1.begin(2400);
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}



void loop() {
recvWithEndMarker();
showNewData();
w();
}



void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;
    
    while (Serial1.available() > 0 && newData == false) {
        rc = Serial1.read();

        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
    }
}



void w(){
int a;

a = Serial1.read();

Serial.print(a);

delay(1000);

}

}

l2eserved:
code

You are a person of very few words - some extra comment would help.

I can't understand why you have created your w() function when you are supposed to be trying my code. Remove the w() function and try again.

And (as a separate issue) w is a very unhelpful name for a function. Using meaningful names for functions and variables makes code easier to understand and less likely to contain silly mistakes.

...R

I was tried follow you advice.
out put is " " only

const byte numChars = 32;
char receivedChars[numChars]; 
boolean newData = false;

void setup() {
Serial1.begin(2400);
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}



void loop() {
recvWithEndMarker();
showNewData();

}



void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;
    
    while (Serial1.available() > 0 && newData == false) {
        rc = Serial1.read();

        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
    }
}




}

l2eserved:
I was tried follow you advice.
out put is " " only

OK. Now we have a basis for making some progress.

I guess the first thing is for you to provide a diagram (a photo of a pencil drawing) showing exactly how the scale is connected to the Arduino.

Also add the 3 lines marked //NEW into your program and let me know if anything appears

 while (Serial1.available() > 0 && newData == false) {
        rc = Serial1.read();
        Serial.print("Char received  ");   //NEW
        Serial.write( (byte) rc);     //NEW
        Serial.println();   //NEW

        if (rc != endMarker) {

...R

Ok, thank you so much.
I will try it in tomorrow.
I will let you know.