The OP method is a boolean test for true/false. I was mistaken in thinking nothing available returned -1, which would also be true. But the actual number 0 to ? is returned. So there is no difference for what he is doing.
Read the documentation better next time!
ok, so this is the MAX 3232 module:
this is how I'm plugging the module to arduino:
this is the convertor I am plugging to the computer and see the data in the terminal:
now for some reason I cannot see any data from the arduino,
I have tried another mx3232 module/arduino/arduino mega something is weird..
You should have 3 wires from your Arduino to the RS-232 module.
VCC goes to Arduino 5V
GND goes to Arduino 0v
TXD goes to the pin you've designated as the receive pin. I have a similar module and TXD is the pin where data from the other device comes out at TTL level.
Another thing to check is whether your scales are configured for hardware handshaking. This will be taken care of by your PC USB-RS232 dongle, but not by your Arduino module.
It doesn't look like handshaking is used. If those are ASCII character codes, then:
53 = 5
54 = 6
61 = =m
77 = M
I wouldn't expect to see 245.
EDIT: Also turn on the timestamp in the IDE serial monitor as we can see if there are bursts of characters/bytes.
And please don't screenshot the serial monitor. You can cut & paste the text into the forums - I think between code tags.
Hmmm, ok. The timestamps show that there is a continuous stream of bytes. That doesn't seem right. I'm guessing that when you connect to your PC, you maybe get 1 reading every few seconds?
i cannot say that I'm receiving every second, i can say that I'm receiving 5 time in seconds its very fast
I'm still thinking ASCII. Something is still wrong.
how do you think I can convert it?
the scale right now is 0.000 which should retrieve "wn000.000kg" and this is what I getting:
I have also tried to cast it to HEX but the results is not good.
"wn000.000kg" in HEX: "77 6e 30 30 30 2e 30 30 30 6b 67"
and it's not seem alike
...please don't screenshot the serial monitor. You can cut & paste the text into the forums - I think between code tags.
+1. @markd833 is right to be annoyed by this…
Not gonna work with screen shots. If that was data I could cut and paste, I'd bother with it.
And you still are making us draw our own schematics.
You are not trying to get the best help. I may continue to watch your slow motion progress. I hope others continue to be willing to meet you more than half way. I am not.
a7
TBH your hint made me go do just that… I had assumed available would be a count, 0 zero meaning no chars available. And false, too, of course.
Later away form the device, I thought maybe I had missed
void loop() { // run over and over
if(myScale.available > 0){
Serial.println(myScale.read());
}
}
which woukd be an mistake I don't make (!) and therefor have lotsa trouble spotting. I believe it would compile without error, and not too sure you'd get a warning.
I will test that when I am back at the big rig.
a7
I believe that "Even Check" might mean that you need to configure the port for Even Parity. IOW, are you sure you have your arduino serial port set up the same way as putty was when you could see it working?
@Eshk12 , here's something to try just to establish that your RS232-TTL board is working as expected.
Load up the IDE example sketch called blink - it's in File->Examples->01.Basics->Blink. It should simply bink the on-board LED on your UNO.
Connect your RS232-TTL board VCC and GND to your UNO 5V and GND pins. Then connect the RXD pin (it's labelled RXD on my RS232-TTL board) to your UNO Pin 1 (TX).
In your IDE serial monitor, set the baud rate to 9600. You should see the serial data from the scales appearing in the IDE serial monitor.
If you don't see any text, then move the jumper from the RXD pin to the TXD pin on your RS232-TTL board. (Different board makers have differing labelling conventions on what TXD and RXD mean.)
If you do see text, then you know that your RS232-TTL board is working and you know for sure which pin on the board has data coming out.
Once we know that is working, we can move on to trying to receive the data in software.
maybe the weight sensor isn't working?
Hi,
I am using Arduino Uno and I understand that I cannot use Serial on TX, RX(0,1) because the IDE using it.
So I took Arduino Mega and plugged it into pins 17,16 for Serial 2 pins and I don't receive any data even after swapping the pins.
(RS232-TTL board TX -> Mega RX 17,
RS232-TTL board RX -> Mega RX 16)
void setup() {
Serial.begin(9600);
Serial2.begin(9600);
Serial.println("Started");
}
void loop() {
if (Serial2.available() > 0) {
int inByte = Serial2.read();
Serial.print(inByte, DEC);
}
}
the output is only "Started"
Thanks for your help
@cedarlakeinstruments - Hi!
This is my setting from putty,
I didn't configure any parity only the same baud rate.
Normally you can't use pins 0 and 1 as they are used if your sketch uses the serial port. The blink sketch doesn't use the serial port at all, so you can use those pins. It simply makes your UNO into a USB-serial adapter.
Now, with the MEGA2560, if you are using Serial2, then receive is on pin 17. The TTL serial data coming from your RS232-TTL board either comes out of the TXD pin or the RXD pin (depending on the board makers interpretation of TXD and RXD). Your wiring options are TXD to pin 17, or RXD to pin 17.
Does it still work with putty if you set handshaking to NONE?
@markd833, I have try to put both RX/TX pins from RS232-TTL board to pin 17 and it's still not showing anything...
how can I set handshaking to NONE?