whaleygeek / pi_m24sr

A Raspberry Pi based interface to the M24SR Dynamic NFC tag
MIT License
9 stars 7 forks source link

Detect NFC Tag #3

Open thibww67 opened 4 years ago

thibww67 commented 4 years ago

Hi, I managed to run m24sr.py on my RPi, but my goal is to detect something (ex : my phone, a card which have the NFC technology), but I don't understand how to use these function to get it. I tried test_read.py too..

Thank you for your explanations.

whaleygeek commented 4 years ago

Hi there, thanks for your question!

The m24sr is actually the tag-end of the conversation. You can see it in use in this video:

https://www.youtube.com/watch?v=UkEVSy_CU7s

You won't get the M24SR to read a tag, because it IS the tag.

You might want the 'other end' of the link in order to sense a payment card or NFC phone. For example, the SL030 board from skpang, I wrote a blog about it here: http://blog.whaleygeek.co.uk/raspberry-pi-rfid-tag-reader/

There is also the 'clever card kit' from MonkMakes... https://github.com/simonmonk/clever_card_kit

I used the SL030 to read the ID number from a normal credit card, and assigned a different sound to each card. It was a fun demo at an open day.

Hope this helps.

thibww67 commented 4 years ago

Thank you a lot for your answer, I didn't really get what it is, I understand how to have a better use of it !! Thanks to the Android application ST25 NFC tap, I write my URI in the memory and I correctly read it using m24sr.py, but by reading the Application Note AN4420, I didn't found how to write myself an URL in the memory, using I2C bus. Maybe using "write" function which is in the code but where can I place it ?

I really sorry for all these questions, but I really want to understand how to configure it :)

whaleygeek commented 4 years ago

Hi There.

Ah, I see the issue. For the project that Charlotte and I were building, we only needed tag-read from the Pi/Arduino end. I never coded the write service, as we didn't need it.

You will have to follow AN4420 and add a write() function yourself. If you fork this code and add the new code, do ask again if you would like me to review your forked and new code, just nudge me here on this issue and I can look at your new code for you.

Hope this helps.

whaleygeek commented 4 years ago

Correction, there is a write() service here: https://github.com/whaleygeek/pi_m24sr/blob/master/python_proto/m24sr.py#L67

This will write an NDEF record - however I never had a need to test this, as I always wrote the data from the Android end.

whaleygeek commented 4 years ago

There is another app note AN4433 that has sample message sequences in it. This was the app note I used to construct the read sequence from. Appendix C has the detailed I2C read sequence.

https://www.st.com/resource/en/application_note/dm00105043-storing-data-into-the-ndef-memory-of-m24sr-stmicroelectronics.pdf

Sadly, this app note doesn't have a detailed write sequence at the I2C end. But it will be similar to the read sequence - claim the token, select the file, write the file, deselect the file. You might be able to use a combination of reading the detailed I2C read sequence in AN4433 and looking at the data sheet AN4420 to construct a test_write.py file.

Your best next step would be to fork this code, create a test_write.py file, and start working out the sequence by looking at both application notes. If you do that, let me know of your fork URL here and I can perhaps guide you through the code and app note a bit.

thibww67 commented 4 years ago

Thank you, yes this is what I've seen, I will try to do this write test and keep you inform of my work.

whaleygeek commented 4 years ago

There is some info on the ST forums here also: https://community.st.com/s/question/0D50X00009XkghzSAB/help-with-writing-ndef-message-via-i2c-for-m24sr

I am asking one of my contacts at Arrow Electronics to see if we can get hold of any other app notes from ST that may have a sample I2C write sequence.

thibww67 commented 4 years ago

Yes I was reading it, but simply the fact of erasing the memory is something that I don't get. This will be very useful thank you, even to reset the memory, I don't see any other way to do it !

thibww67 commented 4 years ago

I got it ! Here is a code to write "abc.com" in the memory. The i2c message was not easy to write. I put it here to help people who want :

m24sr_write.zip

It's possible to make lots of improvements but this is the bare necessities, maybe @whaleygeek it's possible to add this file in python_proto !

The thing that would be useful is the answer of i2c protocol to confirm the command.

Thank you

whaleygeek commented 4 years ago

@thibww67 Well done for getting this working. I never heard back from Arrow/ST regarding my query for more data, sadly.

Next time I do some work on this project, I will try out your code and look at integrating it into the core driver. Thanks for the info!