RS232 to TTL converter for weighing scale not working [SOLVED]

PROBLEM SOLVED IN POST #112 and #113

I am making an automatic oil dispenser, so to make it work I need communication from weighing scale to arduino to read signal so that further I can make that project.

But right now I am trying to get serial data from RS232 to TTL converter, but it wont give me right data or can say I am getting garbage/random characters and values

But, when I connect RS232 to USB connection and receive data in serial monitor it is showing right data (Screenshot in attachment)

My arduino code is:

#include <AltSoftSerial.h> 
AltSoftSerial mySerial;  
#define TwobitDelay 200

void setup()  
{
  Serial.begin(9600);  
  mySerial.begin(9600);
}
void loop() 
{
 while (mySerial.available()){
   Serial.println(mySerial.read(), OCT);
   delayMicroseconds(TwobitDelay);
}
}

It is showing random values (Screenshot in attachment)

I have connected GND from RS232 to TTL converter to GND of arduino uno and TXD from coverter to pin 8 of arduino

Weighing scale delivers 8 bits data at 9600 baud rate with "NO" parity and "1" stop bit

Weighing scale photos:Imgur: The magic of the Internet)

RS232 to TTL converter:

Please help me out, where I am wrong!!

Often this can be: wrong baud rate, tx/rx reversed, the signals are RS232 when you think they are TTL.

You are displaying in octal?

larryd:
Often this can be: wrong baud rate, tx/rx reversed, the signals are RS232 when you think they are TTL.

Baud rate is confirmed 9600, I have swapped RX/TX many a times! and can you please tell me how can I confirm that signals are TTL and not RS232?

Measure the converter pin voltages, they must be 0V or 5V on the Arduino side.

They must be: minus 3-12V or plus 3-12V on the RS232 SIDE.

Are you sure you need the values in octal?

 while (mySerial.available()){
   Serial.println(mySerial.read(), OCT);
   delayMicroseconds(TwobitDelay);

larryd:
Measure the converter pin voltages, they must be 0V or 5V on the Arduino side.

They must be: minus 3-12V or plus 3-12V on the RS232 SIDE.

Are you sure you need the values in octal?

 while (mySerial.available()){

Serial.println(mySerial.read(), OCT);
delayMicroseconds(TwobitDelay);

I just checked pin voltages, on RS232 side it is around minus 9 volt, and on arduino/TTL side there is some voltage showing up but less than 1 volt!

I am not sure it needs octal or something else, I used HyperTerminal with 9600 baudrate and also with arduino terminal result is like [+000.000 Kg] and like this in screenshot **PS- this result is with RS232 to USB cable **

If my code is wrong, please do help me out to rectify/modify it, Thanks!

1 volt is not enough.

Serial.println(mySerial.read(), OCT);

OCT is saying display the umber in octal.

Try:
Serial.println(mySerial.read());

Try:
Looping back the RS232 side then manually apply 0v or 5v (trough a 220 Ω) on the TX pin on the TTL side.
Monitor the TTL RX pin for 0v and 5v.

The RX pin should go from 0v to 5v.

larryd:
1 volt is not enough.

Serial.println(mySerial.read(), OCT);

OCT is saying display the umber in octal.

Try:
Serial.println(mySerial.read());

Try:
Looping back the RS232 side then manually apply 0v or 5v (trough a 220 Ω) on the TX pin on the TTL side.
Monitor the TTL RX pin for 0v and 5v.

The RX pin should go from 0v to 5v.

Yes, I have tried without octal, same random numbers are obtained as output!!

What is looping back?
I applied 5v through a 220 ohm resistor on TX pin on TTL side but there is no 5v on TTL RX pin (around 500-600 mV), and current measured on RS232 side is on RXD pin around -9v, and when I connect RS232 to RS232 to TTL converter, some blinking starts taking place without any external voltage source (arduino etc), maybe my coverter is broken! Please do suggest what should I do now?

Loop back:
On the converter, make sure the Vcc and GND pins go to 5v and GND on the Arduino.
On the RS232 side, (DB09 connector) connect pin 2 to pin 3.
On the TTL side, TX pin through a 220 Ω (prevents accidentally damaging things) to 5v then to 0v.
On the TTL side, measure the voltage on RX (should go 5v then 0v).

Edit
You may have a bad pin on the Arduino.
Try different pins for mySerial.

Why do you not have RX connected here?

larryd:
Loop back:
On the converter, make sure the Vcc and GND pins go to 5v and GND on the Arduino.
On the RS232 side, (DB09 connector) connect pin 2 to pin 3.
On the TTL side, TX pin through a 220 Ω (prevents accidentally damaging things) to 5v then to 0v.
On the TTL side, measure the voltage on RX (should go 5v then 0v).

Edit
You may have a bad pin on the Arduino.
Try different pins for mySerial.

I followed exactly of your steps, but there is no 5v or 0v on RX pin, whereas it is around 3v
I have tried almost all pins on my Arduino uno but nothing works!!

larryd:
Why do you not have RX connected here?

Because my weighing scale only delivers data but donot take any data back

PLEASE do help me out, I think my converter is not okay as when I measured voltage on RS232 connection by Ground and RXD pin is around -9v but when I measure on converter it shows only around -3v!!

PS - when I am measuring weight through RS232 to USB cable then weight shows in format like "+000.000 Kg", example - when I measured 395 gram object it shows like "+000.395 Kg" and so on.

Your help will be highly appreciated, My other hardware and code is ready and now I am stuck in this situation! Please do suggest any type of communication or circuit which I can use, I have MAX3232 in case my converter doesnot work

“I followed exactly of your steps, but there is no 5v or 0v on RX pin, whereas it is around 3v”
3V can be reasonable but it should go from 3v to 0v..

Are you saying the TTL RX pin always stays at +3v when you follow the steps?
OR
Are you saying it does go from 3v to 0v when you follow the steps?

Are you connecting 5v or 3.3v to Vcc on the converter?

Do you have a NPN transistor?

larryd:
“I followed exactly of your steps, but there is no 5v or 0v on RX pin, whereas it is around 3v”

Are you saying the TTL RX pin always stays at +3v when you follow the steps?
OR
Are you saying it does go from 3v to 0v when you follow the steps?

Are you connecting 5v or 3.3v to Vcc on the converter?

Do you have a NPN transistor?

I have connected TX to 5v arduino output through 220 ohm resistor and TTL GND to arduino GND and VCC to arduino 5v and measuring voltage through RX pin from TTL converter gives 5v, and also connecting RX to TX pin of RS232 connection.

But if in meanwhile I connect RX pin to arduino input pin 8 which is as specified in my code, nothing works, no data is received back everything blank

Yes I have BC547 NPN transistor.

I hope there is some other way I can read data from RS232 to arduino? Please do help me out!

Do you have LED and a 220 Ω resistor?

larryd:
Do you have LED and a 220 Ω resistor?

YES

I will show you a schematic of how to test the converter in a few minutes.

Please wait.

larryd:
I will show you a schematic of how to test the converter in a few minutes.

Please wait.

Thank you so much larryd :slight_smile:
will wait....

Hook up these 2 test circuits.

Which one, if any, flashes the LED?

larryd:
Hook up these 2 test circuits.

Which one, if any, flashes the LED?

Tried both circuits, with RX pin LED is constantly ON, and with RX pin LED doesnot light up.

But, if I remove 5v from TTL converter and connect LED With RX pin, LED starts blinking with very little intensity.

What should I do now? Order a new RS232 to TTL converter?

Do you have a 1k and 10K resistor?

If so, try circuit #1 with your program.

If it does not work try circuit #2.

2019-01-14_23-32-31.jpg

larryd:
Do you have a 1k and 10K resistor?

Yes I have