Serial RS232 from Scale


hello. feel though close answer. not there yet. can help? i'm trying input shipping scale arduino. can manipulate input , output more interesting. i'm not worried manipulation. right now, i'm trying arduino recognize scale's output.

01
------
first, got scale sending data via serial cable com1 port of computer. can read via putty or accessport fine. see images attached config settings, wiring diagram, , results. yeah, scale works.


02
------
next tried using arduino without scale. connected windows computer via com1 arduino (using max3323 chip power levels right -- https://www.arduino.cc/en/tutorial/arduinosoftwarers232). arduino sends incoming message mac computer, connected via usb. works fine. again, see attachments below. i'm using exact same config settings in accessport step 01 above.

and see code here:

code: [select]


#include <softwareserial.h>

int result = 0;                   // lbs on earth (or inputted value)
int resultmoon = 0;               // lbs on moon
softwareserial scale(10,11);      // rx, tx
string rx_str = "";               // stores raw serial input string

void setup() {
  // open serial communications , wait port open:
  serial.begin(9600);     // opens serial port, sets data rate 9600 bps

  // set data rate softwareserial port
  scale.begin(9600);
  while (!serial) {
    ; // wait serial port connect. needed native usb port only
  }
  scale.println("setup complete");
  serial.println("setup complete");
}

void loop() {
  readscale();
}

void readscale() {

  // send data when receive data:
  //scale.listen();
  while (scale.available() > 0) {
    char inbyte = scale.read();
    serial.write(inbyte);
  }
}


03
-----
then did unplug serial cable windows computer's com1, , plug directly scale. want arduino read incoming data, , report mac. nothing.

04
-----
i tried modifying code see if data coming through, arduino not recognize data being available.

code: [select]


#include <softwareserial.h>

int result = 0;                   // lbs on earth (or inputted value)
int resultmoon = 0;               // lbs on moon
softwareserial scale(10,11);      // rx, tx
string rx_str = "";               // stores raw serial input string

void setup() {
  // open serial communications , wait port open:
  serial.begin(9600);     // opens serial port, sets data rate 9600 bps

  // set data rate softwareserial port
  scale.begin(9600);
  while (!serial) {
    ; // wait serial port connect. needed native usb port only
  }
  scale.println("setup complete");
  serial.println("setup complete");
}

void loop() {
  readscale();
}

void readscale() {

  // send data when receive data:
  //scale.listen();
  if (scale.available() > 0) {
    char inbyte = scale.read();
    serial.write(inbyte);
  } else {
    serial.println("no data available");
  }
}



can point me in right direction? thank in advance.

am correct in thinking using pc send test serial data arduino , that data correctly received?

but when connect scale arduino in place of pc not getting data?

first thought springs mind tx , rx lines may wrong way round.

...r
serial input basics


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Serial RS232 from Scale


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'