Hello everyone, I have a very trivial task to perform and it is proving to be more of a challenge than I expected. All I need to do is read serial data sent from a scale (sent upon weight stabilization) and then print the value to serial monitor over the Arduino USB to the monitor to verify input before continuing to develop the rest of the loop. I an using an Arduino Uno and an rs232 v2 shield from Linksprite. The jumpers on the shield are set to 6,7 but I have tried other configurations as well. The scale is working perfectly as I can see the data if i pug it in via usb serial adapter and watch it in the Arduino serial monitor. Can anyone PLEASE hook me up with a sketch that will simply read data when it is sent from the scale and print it to the monitor?
Can anyone PLEASE hook me up with a sketch that will simply read data when it is sent from the scale and print it to the monitor?
What baud rate is the device operating at? You might set the baud rate in the below code and see if the data is diaplayed in the serial monitor.
//zoomkat 6-29-14 Simple serial echo test
//type or paste text in serial monitor and send
String readString;
void setup() {
Serial.begin(9600);
Serial.println("Simple serial echo test"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the String readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
Serial.println(readString); //so you can see the captured String
readString="";
}
}
//zoomkat serial echo test 7-31-2011
char input; // incoming serial data
void setup() {
Serial.begin(9600); // set serial port at desired value
Serial.println("serial echo test 0021"); // echo test
Serial.println();
}
void loop() {
if (Serial.available() > 0) { // check for serial buffer input
input = Serial.read(); // read the incoming byte:
Serial.print(input); // print the input
//Serial.println(); // print new line for better reading
}
}
Its echoing what is typed in but I want it to echo from the shield which is connected via s232 to a scale. It seems that the shield isn't receiving from the scale so Its not printing anything to the hardware serial to the screen.
I don't know what you are using for rs232 to TTL conversion, but you might try the simple approach I've used in the attached pix that uses two resistors and an NPN transistor.
Are you sure you have the scale connected properly? There is some confusion in RS232 between DCE and DTE equipment. Sometimes you crosss pins 2 and 3 and sometimes you connect them direct.