Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interfacing GSM and RFID with Arduino

Status
Not open for further replies.
Hi
This is my code..
I am not able to read the RFID tag. I am not very sure of the address, length,checksum and reset reader as I already said.

#include <Wire.h>
#include <EEPROM.h>
#define MAX_NO_CARDS 3

byte tag[4];

void setup()
{
Wire.begin();
Serial.begin(9600);
Wire.beginTransmission(0x6c); // address of RFID reader
Wire.send(0x01); // length
Wire.send(0x80); // checksum
Wire.send(0x81); // reset reader
Wire.endTransmission();
}
void loop() {
if (Serial.available() > 0) {
Serial.read();
seekNewTag();
printTags();
}
else seekNewTag();
delay(200);
}
//Write Tag

void writeTag(int startingAddress, byte byte0, byte byte1, byte byte2, byte byte3){
EEPROM.write( startingAddress*5, byte(1));
EEPROM.write(startingAddress*5+1, byte0);
EEPROM.write(startingAddress*5+2, byte1);
EEPROM.write(startingAddress*5+3, byte2);
EEPROM.write(startingAddress*5+4, byte3);
}
//Find Empty Tag

int findEmptyTag(){
for (int startingAddress = 0; startingAddress< MAX_NO_CARDS; startingAddress++){
byte value = EEPROM.read(startingAddress*5);
if (value == byte(0)) {
return(startingAddress);
}
}
return(200);
}
//PrintTag

void printTags(){
for (int thisTag = 0; thisTag< MAX_NO_CARDS; thisTag++){
printOneTag(thisTag);
}
}
void printOneTag(int address) {
Serial.print(address);
Serial.print(":");
for (int offset = 1; offset < 5; offset++) {
int thisByte = int(EEPROM.read(address*5+offset));
if (thisByte < 0x10) {
Serial.print("0");
}
Serial.print(thisByte,HEX);
}
Serial.println();
}
//Look Up Tag

int lookupTag(byte byte0, byte byte1, byte byte2, byte byte3){
for (int thisCard = 0; thisCard< MAX_NO_CARDS; thisCard++){
byte value = EEPROM.read(thisCard*5);
if (value != byte(0)){
if(byte0 == EEPROM.read(thisCard*5+1) && byte1 == EEPROM.read(thisCard*5+2)
&& byte2 == EEPROM.read(thisCard*5+3) && byte3 == EEPROM.read(thisCard*5+4)) {
return(thisCard);
}
}
}
return(200);
}
//Seek New Tag

void seekNewTag() {
Serial.println("Waiting for card");
if (Serial. available()) {
return;
}
int tagToCheck = lookupTag(tag[0], tag[1], tag[2], tag[3]);
if (tagToCheck != 200){
Serial.println("That tag is already stored");
printOneTag(tagToCheck);
}
else {
int emptyTagLocation = findEmptyTag();
if (emptyTagLocation != 200){
writeTag(emptyTagLocation, tag[0], tag[1], tag[2], tag[3]);
Serial.println("That tag is new");
printOneTag(emptyTagLocation);
}
}
}

I am gettin an output as follows:

Waiting for tag
That tag is already stored
0:00000000
 

connect to hyperterminal and swipe the card on the reader and see what data comes on terminal and send snap shot of that screen......

do you have to write data to rfid card???? or just read it????????? do you have rfid card writer to write data in the card....
 
i jus have to read the tag and send the ID to the GSM module using the Arduino.
 

then 1st connect the rfid reader to terminal.. swipe the card and see what output you get.... count the number of characters you get in the window... see if you get a special character in the 1st position... if yes the ignore the 1st character when you read, and store the characters in an array in your program... and send the array through GSM.


the address you are searching is for writing the data into the tag, which is not at all required....
 
hey my GSM module is working with the hyper terminal, and it works.. When I connected it to the arduino pro mini and gave the following connections- supply,gnd, rx-rx,tx-tx, it is not working.
my simple code -
char a[30]="AT+CMGR=1";
char b[40];
int i;
int j;
void setup()
{
Serial.begin(115200);
}

void loop(){
Serial.write("AT");
delay(1000);
Serial.println(Serial.read(),);
}
is giving result-
AT
-1
this means gsm is not connected.. what should i do
 

oh i tried it the other way round too..
tx-rx
rx-tx
gnd-gnd
but stil no use
 

you dont send 0x0a and 0x0d after AT??

---------- Post added at 16:37 ---------- Previous post was at 16:35 ----------

what is the set up when you get -1?
 

yes i tried another code-
char a[5]="AT";
void setup()
{
Serial.begin(9600);

for(int i=0; i < 2; i++)
{
delay(100);
Serial.write(a);
delay(100);
}

Serial.write(0x0a);
delay(100);
Serial.write("GSM-Module");
delay(100);
Serial.println(0X0d);
Serial.print(Serial.read());
}
void loop(){}
but it is not reading anything
 

connect the board to PC using UART and open the hyperterminal and see if you get the output from the controller.. and dont give delay after serial.write and post your entire code and circuit....
 

hi. I tried connecting the gsm module to the hyperterminal again, this time I am not gettin any response when I type AT or anything else.
I have checked the comport well its COM10.
 

its difficult to give a solution sitting here.... you are not posting the circuit nor telling properly what you are doing and what you are getting and reply after many days... its difficult to remember every member problem if you come once in blue moon to the forum...

what is the problem with the modem now... is com 10 correct....
 

I was trying out the solution you had asked me to. I can do it only during my office hours. I figured out that now the hyperterminal itself is not responding then going to the circuit would be secondary, that is why I did not post the circuit.
Com10 is correct but the hyperterminal is not responding.
 

thanks a lot. I would try it out and get back to you
 

Hi. sorry for the late reply. Was into other project.
As you know I am interfacing my SM5100b gsm module with arduino pro mini.
As you suggested I tried connecting the module with the other system and it
is responding.
I also tried connecting the arduino and hyperterminal together, but the serial monitor doesn give any other response other than -1 for my code.

char a[10];
int i;
char val=0;
void setup()
{
Serial.begin(9600);

delay(1000);
}

void loop(){

Serial.println("\nAT");
Serial.println("0x0d");
delay(1000);
Serial.print(Serial.read());
delay(1000);
}
rx-tx,tx-rx,vcc-supply,Gnd-gnd
 

Where did you get Vcc pin in serial cable..... it does not have any pin out serial cable..
 

Replace "AT" with "AT\r". If you just send "AT" , how 'll GSM module know that your sending a command but not characters? "AT" is a set of characters too .
So "\r" indicates that its a command.
So write all AT commands such that it ends with \r in your Arduino program.
 

For those of you who have a RFID which uses the Wiegand26 protocol, do not attempt to connect the unit to an RS-232, they are not compatible.

You may damage your Serial Port, the RFID Reader or Both.

The following PDF has plans for a RFID door lock using a Wiegand26 reader using the PIC MCU:

RFID Door Lock

Project Schematic

It also has a very good explanation of Wiegand26 encoding. You can use it as a template for building Weigand26 to RS-232 protocol converter/translator.

Attached is a complete protocol converter/translator for Wiegand26 to RS-232 using the AVR MCU:
 

Attachments

  • A3616.zip
    2.1 MB · Views: 45
  • sample-source-code-c-and-hex-pr25.zip
    7.6 KB · Views: 44

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top