6 Replies Latest reply on Aug 19, 2016 1:02 PM by Intel Corporation

    PN532 Adafruit on Edison with i2c - Didn't find PN53x board

    Busnet.it

      Hi,

      I tried to connect edison to NFC reader (PN532 Adafruit). As I read in pdf documentation of INTEL the right way is to use I2C.

       

      Sketch: Arduino

       

      Connection here

      Unknown-2.jpgUnknown-3.jpgUnknown.jpg

       

      Here the code (the Adafriut example):

       

      #include <Wire.h>
      #include <Adafruit_NFCShield_I2C.h>
      
      #define IRQ   (2)
      #define RESET (3)  // Not connected by default on the NFC Shield
      
      Adafruit_NFCShield_I2C nfc(IRQ, RESET);
      
      void setup(void) {
        Serial.begin(115200);
        Serial.println("Hello!");
      
        nfc.begin();
      
        uint32_t versiondata = nfc.getFirmwareVersion();
        if (! versiondata) {
          Serial.print("Didn't find PN53x board");
          while (1); // halt
        }
        
        // Got ok data, print it out!
        Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
        Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
        Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
        
        // Set the max number of retry attempts to read from a card
        // This prevents us from waiting forever for a card, which is
        // the default behaviour of the PN532.
        nfc.setPassiveActivationRetries(0xFF);
        
        // configure board to read RFID tags
        nfc.SAMConfig();
          
        Serial.println("Waiting for an ISO14443A card");
      }
      
      
      void loop(void) {
        boolean success;
        uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
        uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
        
        // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
        // 'uid' will be populated with the UID, and uidLength will indicate
        // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
        success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
        
        if (success) {
          Serial.println("Found a card!");
          Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
          Serial.print("UID Value: ");
          for (uint8_t i=0; i < uidLength; i++) 
          {
            Serial.print(" 0x");Serial.print(uid[i], HEX); 
          }
          Serial.println("");
          // Wait 1 second before continuing
          delay(1000);
        }
        else
        {
          // PN532 probably timed out waiting for a card
          Serial.println("Timed out waiting for a card");
        }
      }
      

       

       

      On serial Monitor:

      Didn't find PN53x board

       

      Is there something wrong? Or jumper to active on Edison shield?

       

      Thanks.

       

      Paolo

        • 1. Re: PN532 Adafruit on Edison with i2c - Didn't find PN53x board
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello Busnet.it,

          Could you please try the following tests?

          1. With your current setup, access your Edison's Linux terminal and run the following script:

          #!/bin/sh
          echo 28 > /sys/class/gpio/export
          echo 27 > /sys/class/gpio/export
          echo 204 > /sys/class/gpio/export
          echo 205 > /sys/class/gpio/export
          echo 236 > /sys/class/gpio/export
          echo 237 > /sys/class/gpio/export
          echo 14 > /sys/class/gpio/export
          echo 165 > /sys/class/gpio/export
          echo 212 > /sys/class/gpio/export
          echo 213 > /sys/class/gpio/export
          echo 214 > /sys/class/gpio/export
          echo low > /sys/class/gpio/gpio214/direction
          echo high > /sys/class/gpio/gpio204/direction
          echo high > /sys/class/gpio/gpio205/direction
          echo in > /sys/class/gpio/gpio14/direction
          echo in > /sys/class/gpio/gpio165/direction
          echo low > /sys/class/gpio/gpio236/direction
          echo low > /sys/class/gpio/gpio237/direction
          echo in > /sys/class/gpio/gpio212/direction
          echo in > /sys/class/gpio/gpio213/direction
          echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux
          echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux
          echo high > /sys/class/gpio/gpio214/direction

          After you have ran it, run the command i2cdetect -y -r 6, does your board detect the I2C device?

          2. Using pretty much the same setup but with a external power supply for Edison. Run the script above and the i2cdetect command again. Is there any difference? 

          3. Using a different power supply only for your I2C device. Run the script above and the i2cdetect command again. Is there any difference?  Remember connect both boards grounds.

          Let me know if you are able to see any difference between the results of those tests.
          -Peter.

          • 2. Re: PN532 Adafruit on Edison with i2c - Didn't find PN53x board
            Busnet.it

            Hi Peter,

            I'm sorry but It does not work.

             

            The script

            Schermata 2016-08-18 alle 10.25.23.png

             

            i2cdetect

            Schermata 2016-08-18 alle 10.26.06.png

             

            Step 1. after script and command

            FAIL

             

            Step 2. with a external power supply for Edison

            FAIL

             

            Step 3. different power supply only for your I2C device

            FAIL

             

            I run the script after upload the code before the command nfc.begin();

             

            Paolo

            • 3. Re: PN532 Adafruit on Edison with i2c - Didn't find PN53x board
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hi Paolo,
               
              These tests let us determine that the issue is not related to a lack of power to your I2C device. We would like to ask you if you have access to another I2C device and if so, could you please test if your Edison can detect it with the i2cdetect command. Also, in case you have access to another board (like an Arduino UNO), could you please check if your I2C device issues persist with it?
               
              -Peter.

              • 4. Re: PN532 Adafruit on Edison with i2c - Didn't find PN53x board
                Busnet.it

                Hi Peter,

                Same i2c device with Arduino works correctly, but tomorrow I Will try to use another device.

                Thanks

                 

                Paolo

                • 5. Re: PN532 Adafruit on Edison with i2c - Didn't find PN53x board
                  Busnet.it

                  Hi Peter,

                  I done a lot of test; finally the problem is solved.

                   

                   

                  Thanks to your advice, I tried to give power to the i2c device after the boot of Edison (I thought about a power problem). So the device was recognized: first upload the code, when transfer complete I inserted 5V pin.

                  But card reader did not work well.

                   

                  So I tried to use 3,3V and It works perfectly. My be there is something wrong..

                   

                  Paolo

                   

                  Thank-you, see you on maker faire ROME.

                   

                  Connessione PN532.jpg

                   

                   

                  • 6. Re: PN532 Adafruit on Edison with i2c - Didn't find PN53x board
                    Intel Corporation
                    This message was posted on behalf of Intel Corporation

                    Hi Paolo,

                    I'm glad to hear that it is now working. If you ever have any other doubts, please don't hesitate to come back to the community, we'll try to help you in any way we can.

                    -Peter.