@denis222, unfortunately I'm not very familiar with the PIC platform. The original Arduino library I ported is here. The issue I identified with variable types is:
This affected the reading of some cards. I can't speak to writing to the cards but members have not flagged this as a problem. You may want to try to get in touch with the original library author.
Well it was only a matter of time before everyone started trying this even a relative beginner such as myself. I purchased RFID-RC522A
Note the āAā ā Did I get the wrong card for this library?
I have soldered the pins (I had to learn to solder to do this) and hooked everything up to sparticale core as advised in the comments of dump.info in the library. The little red led on RFID-RC522 lit up. I took wgbartleyās code which compiled and flashed without issue. But after various attempts at debugging I canāt tell if my RC is connected or if my RFID fobs are the wrong kind or donāt work ā¦ how can I determine if the card is connected?
Great thread but the answer to getting RC522 to work is still unclear to me.
My goal is to Spark.publish the RFID tag to the spark cloud. It should be simple enough but at the moment I canāt even get the example dumpinfo.ino to read my cards. My plan was to get dumpinfo.ino working and then modify it to publish the tag to sparkās cloud API as well as light the onboard D7 LED.
I notice that MISO, MOSI, SCK & SDA(SS) donāt seem to be #define in the example dumpinfo.ino document (and libraries) - might this be where iām going wrong?
Any advice would be much appreciated @peekay123 & @ParticleCommunity
@Jak, the library uses hardware SPI and you only specify the SS and RST pins. So as @kennethlimcp pointed out and as described at the top of the DumpInfo.cpp file, you need to hook up the SPI line correctly:
Function Core Pin MRFC522 Pin
Reset ANY (D2) RST
SPI SS ANY (A2) SDA
SPI MOSI A5 MOSI
SPI MISO A4 MISO
SPI SCK A3 SCK
I have hooked it up as suggested and changed how I reading reading the serial output (now using Arduinoās Serial Monitor on OSX.). it read like a charm!!! Thank you ever so much.
Last cheeky question: do you know what the Spark.publish command would be to post the UID (tag) to the spark cloud?
@Jak, using Spark.publish() requires that you have the UID in a character string format. Second, and only for now (but donāt take my word for it), the string canāt be longer than 63 characters (or 255 if Iām full of doodoo). With this being satisfied, the publish would look like:
Spark.publish("myUID", uidstring, 60, PRIVATE);
- myUID is the published event name
- udistring is the string representation of the UID (63 chars max)
- 60 is the TTL
- PRIVATE means it is not seen by the public, only devices/services on your account
:smile:
Are you guys doing all this magic with a Spar Core or a Photon? I got my Photon a few days ago with the latest firmware (0.4.3) and all it does when I flash your library on it is flashing red in a weird pattern then resetting and flashing againā¦ Any Ideas what the problem might be or in which direction I have to dig further?
Doesnāt look like there is any new code it the [Github] (https://github.com/pkourany/MFRC522_RFID_Library) since Jan 24, 2015.
Iām also getting the SOS red blinkingā¦ Not sure what to do now
Thanks! I am using just the basic code found here and used RST pin D2, D3 and A1 and always ending with a red SOS.
Iām now at the point of trying Particle Dev and flashing is working but it seems NONE of the code is being executed, even a simple Particle.publish("Working", "yes"); is not firing.
Nope, that was on the web UI.
I tried compiling locally but it seems to not compile locally. I mean it works but it uploads and nothing happens. (No SOS lights though)
@anlek, I believe I found the problem. Even with local build, I got the same results as you - SOS. Looking at the code I realized that the SPI configuration was being split between the demo app and the MFRC522 constructor. Moving the entire SPI config out of the constructor and into the setSPIConfig() function of the class then calling it in setup() of the demo app removed the problem. The unpredictable nature of class constructor initialization is what I believe caused the problem. I have posted the fix to the repo and the web IDE.