Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
#include "Arduino.h"
#include<SoftwareSerial.h>
SoftwareSerial mySerial (17,16);
unsigned char incomingByte;

void sendIdentifyCmd ()
{
  mySerial.write (0x40);    
  mySerial.write (0x04);
  mySerial.write (0x01);  
  mySerial.write (0x01);
  mySerial.write (0xCD);
  //mySerial.write (0x32);                
#ifdef DEBUG
  Serial.print (0x40);
  Serial.print (0x04);
  Serial.print (0x01);
  Serial.print (0x01);
  Serial.print (0xCD);
  //Serial.print (0x32);
  Serial.println ();
#endif
}

void setup ()
{
  Serial.begin (9600);
  mySerial.begin (9600);
  Serial.println ("begin initial Serial!\n");
}

void loop ()
{
  sendIdentifyCmd ();
  delay (2);
  while(mySerial.available ()<64)
  {
      incomingByte=mySerial.read();
      Serial.println(incomingByte,HEX);
      Serial.print (' ');
    Serial.println("no tag");
      delay(1000);
  }
  Serial.println ();
  delay (1000);
}






this is my code..pls help me
Posted
Comments
George Jonsson 2-Dec-15 1:15am    
So what is the problem?

1 solution

It is not clear what is your problem, and how exactly did you connected to the reader, but there are a few things you should check...

1. Did you crossed the tx/rx lines? You should!
2. SoftwareSerial has its limitation about what port can be used as rx. Check here: https://www.arduino.cc/en/Reference/SoftwareSerial[^], and consider to use an Arduino board with more than one hardware serial (Mega?).

// UPDATE
C++
#include "Arduino.h"

unsigned char incomingByte;
 
void sendIdentifyCmd ()
{
	Serial2.write (0x40);		
	Serial2.write (0x04);
	Serial2.write (0x01);	
	Serial2.write (0x01);
	Serial2.write (0xCD);
}
 
void setup ()
{
	Serial.begin (9600);
	while(Serial);
	Serial2.begin (9600);
	while(Serial2);
	
	Serial.println ("begin initial Serial!\n");
}
 
void loop ()
{
	sendIdentifyCmd ();
	
	delay (2);
	
	while(Serial2.available() < 64)
	{
		incomingByte = Serial2.read();
		
		Serial.println(incomingByte,HEX);
		delay(1000);
	}
	
	Serial.println ();
	delay (1000);
}
 
Share this answer
 
v2
Comments
Member 12180021 2-Dec-15 2:26am    
thanks for rly..
i connected VI-86 uhf rfid reader with ttl 232 converter with arduino. previously i mention my code when i upload the the code in uart nothing is display after scanning
the the tag

i also used cross connection between ttl232 and arduino mega
pls help
Kornfeld Eliyahu Peter 2-Dec-15 2:28am    
What board do you use?
What TTL-RS232 converter do you have?
Member 12180021 2-Dec-15 2:45am    
arduino mega 2560
and ttl 232 used for rs232 converter
Kornfeld Eliyahu Peter 2-Dec-15 2:52am    
I see...
You made a huge mistake here...Port 17(rx)/16(tx) are hardware serial port!!! It called Serial2!!!
Do not create a software serial on those port, but instead of mySerial use Serial2!!!

See the code in my answer...
Member 12180021 2-Dec-15 3:38am    
ok

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900