Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to troubleshoot timeout error? #5

Open
jamoore5 opened this issue Sep 13, 2020 · 9 comments
Open

How to troubleshoot timeout error? #5

jamoore5 opened this issue Sep 13, 2020 · 9 comments

Comments

@jamoore5
Copy link

jamoore5 commented Sep 13, 2020

Not sure if this project is still active, stuck how to troubleshoot timeout error.

Setup is working with python code and setup

I did figure out to update nrstpd to 25 based on above setup.

Error I am seeing when running

require 'mfrc522'
require 'securerandom'

r = MFRC522.new(25)

begin
  r.picc_request(MFRC522::PICC_REQA)
  uid, sak = r.picc_select
  puts "uid: #{uid}"
rescue CommunicationError => e
  abort "Error communicating PICC: #{e.message}"
end

Error communicating PICC: status_picc_timeout

@atitan
Copy link
Owner

atitan commented Sep 13, 2020

After instance initialization, the reset pin you selected (BCM25) should be in HIGH OUT, and the voltage should be detectable using a multimeter.

I suggest that you read MFRC522 version first, to ensure the SPI communication is fine.

r = MFRC522.new(25)
puts r.send(:read_spi, 0x37)

To see what the library send and receive to/from MFRC522, set the ENV variable DEBUG=1, it'll print the content in STDOUT.

@jamoore5
Copy link
Author

jamoore5 commented Sep 14, 2020

Thanks for the response

require 'mfrc522'
r = MFRC522.new(25)
puts r.send(:read_spi, 0x37) # 146

What is read_spi? The above command work with the rst pin unplugged.
edit: looked at the code I see it says 0x37 => shows the software version

@atitan
Copy link
Owner

atitan commented Sep 15, 2020

The read_spi, which is the communication wrapper in the library, is currently a private method, send is needed to access it.

Looks like your configuration is working with rst unplugged.
Let me know if your had other problems.

@jamoore5
Copy link
Author

Looks like your configuration is working with rst unplugged.

Sorry if I was unclear, I was just commenting that the check for version works with both the rst pin plugged in or unplugged.

@atitan
Copy link
Owner

atitan commented Sep 15, 2020

That's strange.
According to datasheet, NRSTPD is the pin control whether MFRC522 is powered on or off.

@jamoore5
Copy link
Author

This is the configuration I am using

The grey cable does not seem to affect the puts r.send(:read_spi, 0x37) statement
The purple and red are controlling the power.

@jamoore5
Copy link
Author

I have confirmed 3v in the rst pin when it is on.

python code works so it must be a configuration issue.

@atitan
Copy link
Owner

atitan commented Sep 16, 2020

If your r.send(:read_spi, 0x37) works, then set environment variable DEBUG=1 and run the following:

r = MFRC522.new(25)
puts r.send(:communicate_with_picc, MFRC522::PCD_Transceive, MFRC522::PICC_WUPA, 0x07)

This will send wake up command to RFID card to power it up.
You'll receive confirmation from the card in normal cases.

Plus, be sure to remove/place RFID card between each test, this will reset the card activation state.

@atitan
Copy link
Owner

atitan commented May 23, 2021

@jamoore5
I've increased the overall stability by rewritten the SPI communication part of the library.
If you would like to try, enable SPI linux driver and use mfrc522 3.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants