Write/Read data in a mifare card or tag using MFRC522. #6159
Replies: 1 comment
-
Posted at 2019-05-17 by Robin Thr 2019.05.16 Is the inquiry for designing the circuit, coding the solution, or both? Do you have a re-writeable type card to start with?
Which model writer? Code snippet for reading cards Arduino sketch to model after Posted at 2019-05-17 by user100204 Both, but mainly coding the solution. Yes, I have a re-writeable card. I gonna check it out these links. Posted at 2019-05-17 by user100204 I've already tried this http://www.espruino.com/MFRC522. I received the card ID but I couldn't write. Posted at 2019-05-17 by @gfwilliams I'm afraid there's no code in that module to handle reading/writing of data on the cards yet - just getting the ID. I'm out of the office today but I'll see what I can do on Monday. If you can't wait until then or want do do it yourself you'll need to extend http://www.espruino.com/modules/MFRC522.js using the information in the MFRC522's datasheet. Posted at 2019-05-17 by user100204 Ok. I’ll wait for your help. Thanks a lot Posted at 2019-05-21 by @gfwilliams Well, that took a long time - I'd been hoping to use the Arduino code as a base but something just seemed a bit 'off' with it. Ended up using https://github.com/pimylifeup/MFRC522-python as the datasheet itself doesn't really seem to provide enough info by itself. Ok, this is a bit hacky at the moment - I need to turn it into a proper module that works the same way as the old one, but:
So using the standard reader and tags, it seems you can only really do stuff with pages 8 and over, which are 16 bytes each? Be careful - I think I 'bricked' a tag by writing lots to it and maybe overwriting the 'auth key' with something else. Definitely stick to pages 8/9/0 and 16 bytes each and you're fine though. Also, there will be exceptions thrown every so often - sometimes a read will fail and you'll get a Posted at 2019-05-23 by user100204 Hi Gordon, I tried this solution, but I got some problems. I gonna attach these problems here. Could you please try again to help me? I'm using the STM32F4 Cortex M4. Thank you!
Posted at 2019-05-23 by Robin Thr 2019.05.23 Is the writer the type as requested in #2 above? or another type? re: 'STM32F4 Cortex M4' Is the Espruino device the Pico? Posted at 2019-05-23 by user100204 Yes, this is the writer I'm using. What do you mean with Pico? Posted at 2019-05-24 by Robin Hi @user100204, I'll be more succinct then. Which Espruino board? Would you mind posting the results of entering With the amount of effort @gfwilliams has put into this so far, and so that we may provide a speedier response, not having him ask the for the same trivial detail, my inquiry was to better isolate whether we are dealing with a hardware issue or a software one. Posted at 2019-06-07 by user100204 Hi Robin, sorry for the late, these are the results of entering process.env VERSION: "2v01", Posted at 2019-06-08 by Robin Sat 2019.06.08 Good morning @user100204 and thank you for posting that result set. Confirming that a recent flash of Espruino is being used should remove the notion that Espruino is the culprit and isolate the solution to the module or the calling code. re: 'STM32F4 Cortex M4' This thread was originally started under heading: Home >> Official Espruino Boards >> General As the Discovery is a third-party board, the sub-title 'Questions about Espruino on non-official boards' is for 'Other Boards' that are not official Espruino supported boards. For future posts, the more appropriate place to request assistance on this third-party board would be under either 'General', 'Interfacing' or 'Other Boards' beneath: Home >> Other Boards >> Other Boards Now back to the coding issue. As two weeks have elapsed since the last post, Is there still the issue with the timeout errors as shown in #8 above? It seems that there are several types of errors in either a read or a write operation, would you agree? As the sections shown in #7 will throw exceptions, It is quite possible that the method used to call each type, is not correctly structured within try/catch blocks and the errors are just bubbling up, giving the effect the coding cause is actually somewhere else. Let's take each error one at a time, and would you please post some code sections so that we may see how the call to either the read or write and/or the try/catch blocks are structured. Hint: Using the '</>Code' button just to the left of the 'Preview' button above this edit window will allow the block and error responses to have additional highlighting, making reading a bit easier as shown in #7 Posted at 2019-06-10 by @gfwilliams At @robin has mentioned, this section of the forum is for official boards (not Discovery boards). There's what I hoped was a very clear message at the top of it when you go to post a new thread. I split the forum in two so I can properly support users who paid for official boards (eg by doing work like this on the NFC library) - however if I spent all my time doing work like this for people who have not and presumably have no intention of supporting my work on Espruino then I'd go out of business and none of these tools would exist for anyone. So @robin may be able to help you get this working - but I'm no longer going to be helping you out. Posted at 2019-06-10 by Robin Mon 2019.06.10
I can appreciate @gfwilliams, that it must have taken several days to crank out that write solution for @user100204 and that effort took away from the need to stay focused on Espruino itself. May I inquire as to your setup, e.g. Espruino board and RC522 board mfg? I have the original module MFRC522 read code example working, but on a KeyeStudio board controlled by a Pico. I've noticed there seem to be two variants to the Green'ish-Blue one shown on the module web page, being more of a Cobalt Blue in addition to the Green-Yellow KeyeStudio board I possess. The Arduino source references I've found, differ slightly and although your solution is quite similar, my KeyeStudio board is struggling around L168 and I'll need to compare the datasheet along with the KeyeStudio Arduino code to then fiddle with that section. It's quite possible the subtle hardware differences may cause an issue, and if that is the case, I'll need to pick up the same mfg board as the one you have. I also want to verify with user100204 as that may be an area to resolve. Through the use of the debugger and console.log statements, I'm willing to assist user100204 the best I'm able. Thank you for all your efforts in keeping the core Espruino functional for the community. Posted at 2019-06-11 by @gfwilliams It was a Pico and the exact reader you see here: http://www.espruino.com/MFRC522 The cards used to read/write were the cards that you get given with the reader - the type of card you use definitely matters as they can use different protocols. The code itself was mostly based on https://github.com/pimylifeup/MFRC522-python so you could try connecting to a Raspberry Pi and using the Python code to see if that works |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-05-16 by user100204
How can I write data in a mifare card, increment this data and after read this incremented data?
Beta Was this translation helpful? Give feedback.
All reactions