Receiving Serial data from RS232 to TTL converter

Hello, i'm new in Arduino programming.
I want to ask about my project, so i have a long range RFID Reader (Long Range Integrated RFID Reader / Writer - CT-I802) that have 2 output a TCP/IP and a RS232. It works very fine on RS232 direct connect to a pc and a software that come with the product. So i can read the tag data on the software that the seller provided.
The problem is i can't recieve the tag data from the RFID Reader to my Genuino Mega 2560. I'm using a RS232 to TTL.

from TTL output i connect :
VCC to 5V Genuino
RXD to Pin 10
TXD to Pin 11
GND to Ground

the code is :

// RFID_UART.ino

#include <SoftwareSerial.h>
#include <SeeedRFID.h>

#define RFID_RX_PIN 10
#define RFID_TX_PIN 11

// #define DEBUG
// #define TEST

SeeedRFID RFID(RFID_RX_PIN, RFID_TX_PIN);
RFIDdata tag;

void setup() {
	Serial.begin(9600);
	Serial.println("RFID Test..");
}

void loop() { 
 
	if(RFID.isAvailable()){
		tag = RFID.data();
    Serial.println("RFID TAG DETECTED");
		Serial.print("RFID card number: ");
		Serial.println(RFID.cardNumber());
#ifdef TEST
	Serial.print("RFID raw data: ");
	for(int i=0; i<tag.dataLen; i++){
	    Serial.print(tag.raw[i], HEX);
	    Serial.print('\t');
		}
#endif
	}
 
}

I'm using library from the GitHub - Seeed-Studio/RFID_Library: 125Khz RFID library for Arduino.
Thank you for your interest, and sorry if i'm on wrong section.

Hi, what do you see on serial monitor of you uncomment the line defining TEST?

Do you need to swap RX & TX lines? Maybe put low value resistors (e.g. 220R) in series with RX&TX to protect them for that test.

The code is taken from example of the library.
After i uncommenting the Test on serial monitor still doesn't showing anything.
I'm using 9600 baud rate as the software from the manufacturer give using a 9600 baud rate.

The RFID reader is buzzing when a tag is present, but no data recieved on arduino.

It will (probably) not solve the problem, but why do you use software serial on a board that has additional hardware serial ports. Rather use Serial1 or so; usage the same as normal serial port.

If you have a serial port available on the PC (either physical or a USB-to-RS232), you can use that to test communications between the Arduino and the PC.

e.g. the below should echo what is received on Serial1 to Serial (the standard Arduino USB).

if(Serial1.avaliable() > 0)
{
  Serial.write(Serial1.read());
}

You need two terminal programs running. If you know how to do it you can use two instances of serial monitor; else you can use e.g. serial monitor for one and RealTerm / Putty / minicom / ... for the other one.

Okay, so now i'm using TX1 and RX1 on Arduino Mega.
So now from the RS232 to TTL converter RX going to TX1 and the TX going to RX1 is it right?

If so my code is :

void setup()  {
 Serial.begin(9600);
 Serial1.begin(9600);
}

void loop() {
 if(Serial1.available()>0)
 {
  Serial.write(Serial1.read());
 }
 delay (1000);
}

I already put the tag on my reader and it buzz, but still nothing on the serial monitor from the arduino IDE.

Here is a simple schematic i'm doing at this moment.

Also attached if the schematic didn't show properly.

Image from Reply #5 so we don't have to download it. See this Image Guide

...R

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

quivers:
Okay, so now i'm using TX1 and RX1 on Arduino Mega.
So now from the RS232 to TTL converter RX going to TX1 and the TX going to RX1 is it right?
...
...
I already put the tag on my reader and it buzz, but still nothing on the serial monitor from the arduino IDE.

Don't use the reader; connect both serial ports of the mega as I described. Get a simple echo from one port to another port working first.

Once that works, you can start using the reader. What do the specs say about baudrate, parity, databits and stop bits?

Robin2:
Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

If the basic communication is not working, it's not going to help (in my opinion).

sterretje:
Don't use the reader; connect both serial ports of the mega as I described. Get a simple echo from one port to another port working first.

Once that works, you can start using the reader. What do the specs say about baudrate, parity, databits and stop bits?
If the basic communication is not working, it's not going to help (in my opinion).

Okay so i tried this way
From my laptop to arduino using a usb port then from the arduino to my pc using tx1 and rx1 going through RS232 to TTL converter.
I'm opening from the HTerm on my PC but it receiving a gibberish word, all the same words.
Is it possible that my converter broken?
Or the cable on wrong position?

sterretje:
If the basic communication is not working, it's not going to help (in my opinion).

I guess I start from the other end :slight_smile:

If I have a program that I know works reliably then I can concentrate on other issues.

...R

Robin2:
I guess I start from the other end :slight_smile:

If I have a program that I know works reliably then I can concentrate on other issues.

...R

It seems the problem is on the wire , i change my wire so i can recieve from the Arduino IDE Serial Monitor to HTerm. but i can't receive from the HTerm to Serial monitor.

quivers:
<...>
From my laptop to arduino using a usb port then from the arduino to my pc using tx1 and rx1 going through RS232 to TTL converter.
I'm opening from the HTerm on my PC but it receiving a gibberish word, all the same words.
Is it possible that my converter broken?
Or the cable on wrong position?

?

Maybe a link to your specific reader.

Ray

mrburnette:
?

Maybe a link to your specific reader.

Ray

I can't provide specific link to my reader because it's i only found it on my country, but here it is anyways. P.S. I can't find the datasheet and the seller only give me the demo software

( https://www.tokopedia.com/focusstore/long-range-integrated-uhf-rfid-reader-writer-ct-i802 )

And for update, already can send data from Arduino Serial Monitor to HTerm succesfully, but when i send from HTerm it become a gibberish word printing without ending.

quivers:
And for update, already can send data from Arduino Serial Monitor to HTerm succesfully, but when i send from HTerm it become a gibberish word printing without ending.

Please show the code that achieves the above.

Check and double check the wiring with the TTL-to-RS232 converter. Do you have a link for it?

sterretje:
Please show the code that achieves the above.

Check and double check the wiring with the TTL-to-RS232 converter. Do you have a link for it?

Update, already can do sending and receiving through any serial port.

But now i'm confused because i can read the RFID tag data using a USB to RS232 and connect it direct to PC and read it on HTerm but not on the Arduino.

Is there any syntax i should do before i can read the data from the RFID Reader?

For the schematic is like this :

For the code is :

void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial2.begin(9600);
  Serial.println("Arduino Ready");
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial2.available()) {
    int inByte = Serial2.read();
    
    Serial.println();
    Serial.print(Serial2.read());
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {  
    int inByte = Serial.read();
    Serial2.write(inByte);
  }
}

Your comment states 'read from port 1' but your reading port 2. Incorrectly wired?

sterretje:
Your comment states 'read from port 1' but your reading port 2. Incorrectly wired?

Ah i forgot to change the comment, It's work perfectly fine if i sending from the Serial to Serial2 and Serial2 to Serial. But when i plug the RS232 to TTL converter into the RFID Reader RS232 Output, the Serial Monitor did not receive anything.

The comment on the codes i forgot to change it because i was trying the other Serial port that arduino mega provided so here's the code i use ATM.

void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial2.begin(9600);
  Serial.println("Arduino Ready");
}

void loop() {
  // read from port 2, send to port 0:
  if (Serial2.available()) {
    int inByte = Serial2.read();
    
    Serial.println();
    Serial.print(Serial2.read());
  }

  // read from port 0, send to port 2:
  if (Serial.available()) {  
    int inByte = Serial.read();
    Serial2.write(inByte);
  }
}

An oscilloscope would be helpful to determine what's going on. Without that, it might be helpful to put an LED and 1k Ohm resistor between the TTL lines and ground so that you have a visual indication of line states during your testing.

MrMark:
An oscilloscope would be helpful to determine what's going on. Without that, it might be helpful to put an LED and 1k Ohm resistor between the TTL lines and ground so that you have a visual indication of line states during your testing.

Umm I don't know what you mean by put an LED and 1k Resistor between the TTL Lines, because it is a module and looks a lot like this one :

Another Update, i just recognize that from the RS232 to TTL Converter into the Arduino Mega wire seems funny

VCC > 5V
RXD > RX1
TXD > TX1
GND > GND

It won't work if i try :

VCC > 5V
RXD > TX1
TXD > RX1
GND > GND

on this code

void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial2.begin(9600);
  Serial.println("Arduino Ready");
}

void loop() {
  // read from port 2, send to port 0:
  if (Serial2.available()) {
    int inByte = Serial2.read();
    
    Serial.println();
    Serial.print(Serial2.read());
  }

  // read from port 0, send to port 2:
  if (Serial.available()) {  
    int inByte = Serial.read();
    Serial2.write(inByte);
  }
}

Not that i actually now can communicate with the RFID Reader, it just work for the Serial Monitor to HTerm on the PC