Xerxes3rd / Wifiibo

Application and supporting library to manage amiibos using an ESP8266
67 stars 12 forks source link

Status: writeTag error: NFC hardware not available #23

Open RickoT opened 3 years ago

RickoT commented 3 years ago

Greetings,

I set this up with these items:

I was able to flash and boot up, connected to my wifi, but in the upper right corner it says NFC Error and when I try to flash I get the error in the subject.

I verified all my connections (multiple times) but it just does not seem to work. Am I missing something?

Thanks! ~Rick

RickoT commented 3 years ago

So I finally got the board to recognize, but when I try to read nothing happens. I connected my board like so image

Xerxes3rd commented 3 years ago

SDA should be connected to D2.

RickoT commented 3 years ago

When I tried that it said NFC error, I will revert the connection and try again

RickoT commented 3 years ago

ok, I must have made a mistake before, now I have SDA on D2, but it does not read or write.

I had to change to this code in order for it to recognize:

//Adafruit_PN532Ex pn532(D4); //MFRC522Ex mfrc522(D2, D3); Adafruit_PN532Ex pn532(2); // For Generic ESP8266 MFRC522Ex mfrc522(4, 0); // For Generic ESP8266

When I boot it says this in the serial monitor

11:22:26.758 -> connected with MyWifi, channel 12345 ( <-- Changed ) 11:22:26.758 -> dhcp client start... 11:22:27.131 -> ip:10.31.10.9,mask:255.255.255.0,gw:10.31.10.1 11:22:28.304 -> NFC chip: MFRC522 FW ver: (Unknown) 11:22:36.740 -> pm open,type:2 0

When I try to read/write it does this: and nothing happens when I put the tag on the reader/writer

11:29:01.491 -> Create amiibo: ID=0x01000000034f0902 11:29:01.491 -> Creating NFC tag...Place tag on the reader.

11:30:42.450 -> ws[/ws][3] text-message[18]: {"func":"readnfc"} 11:30:42.450 -> Triggering NFC read

Xerxes3rd commented 3 years ago

For the ESP8266 and Wemos D1 Mini, the ESP pin 4 is the same as D2 and pin 0 is the same as D3, so those are identical. I suspect you might have the Arduino IDE set to use a Generic ESP8266 module instead of the Wemos D1 Mini.

It looks like the library still can't communicate properly with the MFRC522, since it's not able to read the version number from the chip. You can try downloading a different MFRC522 library and flashing one of the examples to see if the module is functional.

RickoT commented 3 years ago

I THINK i chose the right Wemos board?

image

Xerxes3rd commented 3 years ago

Try choosing "LOLIN(WEMOS) D1 R2 & mini". It's confusing, but (I believe) that's the proper choice for most D1 Minis.

I double-checked the other open issues, and there are a couple reports that the MFRC522 library in Wifiibo isn't compatible with version 2.0 of the MFRC522- only version 1.0. If you do have a version 2.0 module, you can either try and fix the library & send a pull request, or get a PN532. I'll update the README to include a warning/disclaimer about the MFRC522.

RickoT commented 3 years ago

There is no version explicitly on the board, so I am assuming its 1.0, I changed the board to what you suggested but it still doesn't work (no version and does not read/write)

I'm messing with the settings to see if I can make a difference.

This is really my first jump into this stuff so I'm going to try and learn a bit more before I start messing with code too much 😁

I truly appreciate your assistance tho!

Xerxes3rd commented 3 years ago

Sorry, the version number is a revision of the MFRC522 chip itself- not the board. I would guess a lot of the boards being sold now have the version 2.0 chip. Even with version 1.0 of the MFRC522, the PN532 works better for me- it reads & writes slightly slower, but it consistently works. If possible, I would recommend getting the PN532 instead. Good luck!

RickoT commented 3 years ago

Ok, so I went and got the "real" parts and it seems to work. Sometimes when reading a blank the device dies, but one thing I noticed is that it only seems to work correctly when connected to a PC. If I plug in power, it won't read, it just hangs after clicking the read button, but it does appear to write.

It's odd

Xerxes3rd commented 3 years ago

That's really interesting, because it definitely reads the tag after writing to verify that the write was successful. It also has to read the tag's ID before it can encrypt the amiibo data. When it hangs with the 'read' button, can you cancel it, or is the device stuck? The only thing I would think would cause a hang like that would be (possibly) a noisy power supply. Does the 'hang' occur with different USB power supplies?

I suppose it would be appropriate to add a timeout to the read/write calls- something like 30 seconds, perhaps, in case the 'Cancel' button isn't working for some reason.

RickoT commented 3 years ago

I tried it with a few different chargers, even one from a canakit I had laying around :(

The only time it seems to be stable is when I have it plugged into my pc

RickoT commented 3 years ago

Oh I also forgot to mention that I had to swap this too...

//Adafruit_PN532Ex pn532(D4); //MFRC522Ex mfrc522(D2, D3); Adafruit_PN532Ex pn532(2); // For Generic ESP8266 MFRC522Ex mfrc522(4, 0); // For Generic ESP8266

RickoT commented 3 years ago

I also noticed that reading blank tags seems to be a problem. Sometimes it will read but display the last real tag that was scanned... sometimes it will kill it and I need to unplug and plug it back in