Mike86
Published

Read NFC Tag and Send its ID Number to your Phone via SMS

This is an entry illustrating an experiment of using RDM8800 and SIM 900 to read NFC tags and send the ID number to phone via sms.

BeginnerFull instructions provided30 minutes1,506
Read NFC Tag and Send its ID Number to your Phone via SMS

Things used in this project

Hardware components

Itead RDM8800 NFC/RFID Module
×1
Itead SIM900/SIM900A GSM/GPRS Minimum System Module
×1
Itead FTDI FT232RL USB Breakout Board - Foca
×1
NFC tag
×1
Dupont lines
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

RDM8800

SIM 900

Foca

Code

Untitled file

C/C++
#include <PN532.h>
#include <SPI.h>


#define delaytime 2000
#define timeout1 5000
#define timeout2 7000

char number[20] = "13428979973";   //phone number
byte comm_buf[20];

const int LED = 3;

#define PN532_CS 10
PN532 nfc(PN532_CS);
//#define  NFC_DEMO_DEBUG 1
unsigned int frame_format;

unsigned char id_buffer[10];
uint32_t old_id;
unsigned long lasttime=0;
unsigned long prev_time=0;

unsigned char r_buffer[30];

void setup(void) {
  Serial.begin(9600);  
  nfc.begin();
  nfc.SAMConfig();

  pinMode(LED,OUTPUT);
  digitalWrite(LED,HIGH);
  delay(1000);
  digitalWrite(LED,LOW);
  delay(10000);
  
	lasttime = millis();
    
}


void loop(void) {


	
  uint32_t id;
  // look for MiFare type cards
  id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A);
  
  


		if (id != 0) 
		{
			if(old_id != id)
			{
				old_id = id;
				hex_to_dec(id);
				while(Serial.available())
					Serial.read();					
				Serial.println("AT+CMGF=1");
                prev_time = millis();
				int a=0;
				while((millis() - prev_time)<timeout1)
				{
					if(Serial.available())
					{
						
						r_buffer[a++]=Serial.read();
						
						if(strstr((char *)r_buffer, "OK"))
							break;
					
					}
					
					
				}
				Serial.print("AT+CMGS=\"");
				Serial.print(number);
				Serial.println("\"");
				prev_time = millis();
				a=0;
				while((millis() - prev_time)<timeout2)
				{
					if(Serial.available())
					{
						
						r_buffer[a++]=Serial.read();
						
						if(strstr((char *)r_buffer, ">"))
							break;
					
					}
					
					
				}
				Serial.print("card: ");
				for(unsigned char i=0;i<10;i++)
				{
					Serial.write(id_buffer[i]);
				}
				char buf_end[2];
				buf_end[0]=0x1a;
				buf_end[1]='\0';
				Serial.println(buf_end);
				prev_time = millis();
				a=0;
				while((millis() - prev_time)<timeout2)
				{
					if(Serial.available())
					{
						
						r_buffer[a++]=Serial.read();
						
						if(strstr((char *)r_buffer, "OK"))
							break;
					
					}
					
					
				}
                
			
			}

				lasttime = millis();


			

		}

Credits

Mike86

Mike86

15 projects • 12 followers

Comments