nancy
Posts: 12
Joined: Thu Jun 12, 2014 5:31 am

transfer UId from reader to database

Tue Jun 17, 2014 9:10 am

Hi

I am a newbie to raspberry pi. I have connected my raspberry pi with PN532 NFC/RFID reader to read the tag and it is working perfectly. I am getting the UID of the tag. Now I want this UID which is being read, to query the database for checking if it is the same UID in database or not?

Any help is appreciated.

Thanks in advance.


Nancy

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: transfer UId from reader to database

Tue Jun 17, 2014 9:27 am

which db
what language
how are you reading the UID - give an example
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

nancy
Posts: 12
Joined: Thu Jun 12, 2014 5:31 am

Re: transfer UId from reader to database

Tue Jun 17, 2014 9:31 am

Hi

I will be using my sql database using java and restful web service.

I am reading the tag with the help of libnfc. I connected my pi with the PN532 NFC reader by using library libnfc (UART).


Thanks
Nancy

mccet
Posts: 4
Joined: Tue May 12, 2015 5:02 pm

Re: transfer UId from reader to database

Tue May 12, 2015 5:04 pm

Hi nancy, I have the same problem, you have found a solution?

W. H. Heydt
Posts: 12785
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: transfer UId from reader to database

Tue May 12, 2015 8:51 pm

Find a language that has an interface to your chosen database system (or, alternatively, if you have picked a language, pick a database it can talk to).

I use C programs to read and write data in MySQL databases. Many other languages will work in a similar fashion. One constructs a SQL statement as a string using programming language constructs to use the variable data you want. So...using arbitrary names, you do something like...

strcpy(query_string, "select text_data from rfid_db where uid = \"");
strcat(query_string, uid_value);
strcat(query_string, "\" limit 1;");

After issuing the call to the database, checking that it was successful, and that it returned a value, you would then move the returned result with a statement like...

strcpy(uid_descrpition, db_row[1]);

I will leave it as an exercise for the reader for cases where you want more than one column returned and where you want to get back more than one row. I don't represent the above code as particularly good C. Only that it will work. Your mileage may vary.

mccet
Posts: 4
Joined: Tue May 12, 2015 5:02 pm

Re: transfer UId from reader to database

Thu May 14, 2015 11:21 am

thank you, I have communication problems . I can not read by the reader NFC PN523 (connected to raspberry) data from a tag through the library libnfc. Have you a solution?

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: transfer UId from reader to database

Thu May 14, 2015 12:10 pm

mccet wrote:thank you, I have communication problems . I can not read by the reader NFC PN523 (connected to raspberry) data from a tag through the library libnfc. Have you a solution?
What type of tags are you using?
What data are your trying to read?
How have your tried to read the data?
What kind of error messages do you get?

mccet
Posts: 4
Joined: Tue May 12, 2015 5:02 pm

Re: transfer UId from reader to database

Thu May 14, 2015 12:47 pm

Thank you all,
I do not have much experience in this field.

I'm using NFC UART pn532 connected to raspberry.
I want to write using an application andorid any textual tag and I want to see the text written on raspberry with library commands libnfc.

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: transfer UId from reader to database

Thu May 14, 2015 3:32 pm

Most existing android applications (like NXP TagWriter ) writes information to NFC tags in a specific format call NDEF. And how NDEF information is written to a card depends on the Tag type. NFC defines 4 different tagtypes with different capacity and different ways of reading and writing NDEF messages. You should read and learn about NFC Tag Types and NDEF messages.

libnfc doesnt know about NDEF directly but someone have written libndef.

On the other hand, if you know which Tag type you are going to use then its possible to figure out which commands are needed to read the NDEF information from the tags.

mccet
Posts: 4
Joined: Tue May 12, 2015 5:02 pm

Re: transfer UId from reader to database

Thu May 14, 2015 9:55 pm

Thank you, i think to use libnfc and rfidiot libreries to read tags... I thought initially use only ultralight tags to simplify the project , after I will try to improve it .
Now I will try to study the nfc protocol and these libraries ...

thanks to all for the advice !

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: transfer UId from reader to database

Fri May 15, 2015 2:23 pm

mccet wrote: I thought initially use only ultralight tags to simplify the project , after I will try to improve it .
!
Ultralight should in theory be the easiest tags to work with, they have limited functionality but also limited storage space.

Return to “General discussion”