Hello, I want to receive the continuous data from serial output from Intercomp sw650 weighting scale with Arduino mega 2560. In the manual said that Total only continuous output will transmit a line with the total weight about four times per second:
" 5002"
" 5003"
" 5004"
I tried to apply the code below and set the baud rate both in arduino IDE and also in the weighting scale screen but it does not work.
#define SCALE_SERIAL_TX 18
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
if (Serial1.available()) {
//String receivedData = Serial1.readStringUntil('\n');
// Convert the received string to an integer and float
int receivedInt = receivedData.toInt();
float receivedFloat = receivedData.toFloat();
Serial.println(receivedInt);
Serial.println(receivedFloat);
// delay(100);
}
}
The converter does not convert the physical connection, rather it converts the voltage levels from one standard to the other so, yes, you need the converter
The user manual for the scales does not mention what voltage levels are used. Officially, RS232 uses some high voltages, both positive and negative, which would damage an Arduino input.
But it's possible that that the user manual omitted to mention is that it could be "TTL level" RS232 which would be 5V and ideal for an Arduino input.
So my advice would be to connect an oscilloscope and see what voltage level is actually output. Then you will know if you need an RS232 to TTL adapter.
But do not connect your Mega again until you have established whether an RS232 to TTL level converter is needed. You might already have damaged the Mega.
Also, please do not post images of serial monitor. Copy the text from serial monitor and paste that into your post between code tags.
Thank you. I have tried with arduino UNO by using 5V yesterday, it showed the correct result. so, i think the operate voltage is 5V. and today, I changed to Mega and use the old code (already change define port) but doesn't work. then I write the new one as above.
void loop() {
if (Serial1.available()) {
//String receivedData = Serial1.readStringUntil('\n');
// Convert the received string to an integer and float
int receivedInt = receivedData.toInt();
float receivedFloat = receivedData.toFloat();
Serial.println(receivedInt);
Serial.println(receivedFloat);
// delay(100);
}
}