Go Down

Topic: how to get weight form Weight Scale and ek 300i (Read 195 times) previous topic - next topic

l2eserved

Aug 10, 2017, 10:47 am Last Edit: Aug 10, 2017, 11:16 am by l2eserved
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

https://www.manualslib.com/products/AAndd-Ek-300i-3015221.html

this is manual weight scale

Code: [Select]
#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.









Robin2

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 </>
Code: [Select]
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
Two or three hours spent thinking and reading documentation solves most programming problems.

l2eserved

Sorry brother.

https://www.manualslib.com/products/AAndd-Ek-300i-3015221.html

this is manual weight scale

Code: [Select]
#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);
  }

}

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

l2eserved

#4
Aug 11, 2017, 04:35 am Last Edit: Aug 11, 2017, 01:04 pm by l2eserved
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?

Code: [Select]
#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);
}
}


l2eserved

#5
Aug 11, 2017, 04:42 am Last Edit: Aug 11, 2017, 04:47 am by l2eserved
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

Robin2

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

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

l2eserved

#7
Aug 11, 2017, 11:29 am Last Edit: Aug 11, 2017, 01:01 pm by l2eserved
I was try second example at 2400 baud.
and so sorry  rx led on arduino board. LED does not blink .

Whandall

Why do you run SoftwareSerial on HardwareSerial pins?

rx led on arduino board. LED does not blink .
The RX led only blinks for receives on Serial.
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

l2eserved

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

Robin2

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 </>
Code: [Select]
so your code looks like this and is easy to copy to a text editor. See How to use the Forum

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up