Esp32s3 sense with PN532 from elecrow

theres limit with fritzing

1 Like

Yes, there is…
so change the code and run that demo with the correct pin numbers you switched to and , see what works.
shorten the delay’s a little also.
LMK
:v:

1 Like

what about using 5v and 3.3 v is that a problem… I am assuming no problem as long as common grounded?

did you have a fire on that breadboard… or black spray paint?

yeah ahahahahahahahah :rofl:


heres the revised schematic and also the revised code :

/**************************************************************************/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>


// If using the breakout or shield with I2C, define just the pins connected
// to the IRQ and reset lines.  Use the values below (2, 3) for the shield!
#define PN532_IRQ   (D3)
#define PN532_RESET (D6)  // Not connected by default on the NFC Shield

const int DELAY_BETWEEN_CARDS = 500;
long timeLastCardRead = 0;
boolean readerDisabled = false;
int irqCurr;
int irqPrev;

// This example uses the IRQ line, which is available when in I2C mode.
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);

void startListeningToNFC();
void handleCardDetected();

void setup(void) {
  Serial.begin(115200);
  while (!Serial) delay(10); // for Leonardo/Micro/Zero

  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);

  startListeningToNFC();
}

void loop(void) {
  if (readerDisabled) {
    if (millis() - timeLastCardRead > DELAY_BETWEEN_CARDS) {
      readerDisabled = false;
      startListeningToNFC();
    }
  } else {
    irqCurr = digitalRead(PN532_IRQ);

    // When the IRQ is pulled low - the reader has got something for us.
    if (irqCurr == LOW && irqPrev == HIGH) {
       Serial.println("Got NFC IRQ");
       handleCardDetected();
    }

    irqPrev = irqCurr;
  }
}

void startListeningToNFC() {
  // Reset our IRQ indicators
  irqPrev = irqCurr = HIGH;

  Serial.println("Starting passive read for an ISO14443A Card ...");
  if (!nfc.startPassiveTargetIDDetection(PN532_MIFARE_ISO14443A)) {
    Serial.println("No card found. Waiting...");
  } else {
    Serial.println("Card already present.");
    handleCardDetected();
  }
}

void handleCardDetected() {
    uint8_t success = false;
    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)

    // read the NFC tag's info
    success = nfc.readDetectedPassiveTargetID(uid, &uidLength);
    Serial.println(success ? "Read successful" : "Read failed (not a card?)");

    if (success) {
      // Display some basic information about the card
      Serial.println("Found an ISO14443A card");
      Serial.print("  UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
      Serial.print("  UID Value: ");
      nfc.PrintHex(uid, uidLength);

      if (uidLength == 4)
      {
        // We probably have a Mifare Classic card ...
        uint32_t cardid = uid[0];
        cardid <<= 8;
        cardid |= uid[1];
        cardid <<= 8;
        cardid |= uid[2];
        cardid <<= 8;
        cardid |= uid[3];
        Serial.print("Seems to be a Mifare Classic card #");
        Serial.println(cardid);
      }
      Serial.println("");

      timeLastCardRead = millis();
    }

    // The reader will be enabled again after DELAY_BETWEEN_CARDS ms will pass.
    readerDisabled = true;
}

what i notice its only when i play with IRQ like : disconnect it, put it on my finger, reconnect it that i detect a card or see things in the serial monitor

IRQ is interupt Request… so when it is floating the processor may be interupting

I notice you don’t have a declares for the output pins or input pins?
You’ll need those
:v:

Adafruit_PN532::Adafruit_PN532(uint8_t irq, uint8_t reset, TwoWire *theWire)
    : _irq(irq), _reset(reset) {
  pinMode(_irq, INPUT);
  pinMode(_reset, OUTPUT);
  i2c_dev = new Adafruit_I2CDevice(PN532_I2C_ADDRESS, theWire);
}

no need to, its declared in the constructor

yo, btw i changed the delay(10) to delay(1) it now works fine :smile:

FUCK i love electronics :revolving_hearts:

Hilarious,
WE all do…
Mark it as the solution so others can find it…
GL :slight_smile: PJ

Delay Lives Matter :face_with_hand_over_mouth: :+1:

now its a matter of integration with the rest of the code. i dont know if ill have difficulties with i2c

the delay was somehow messing with the IIC signal timing

1 Like

how to mark it as a solution ?

should be a button on your side on the comment… near the heart and stuff

now that im trying to integrate the code in my current project, the fun starts
what could cause this kind of warning ?

[ 3664][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1

it gives me this warning just after uploading the main.cpp. After that, if i restart the mcu with usb for example i have no warning

Hi there, Sounds like a high baud rate issue or shaky cable ,a clock or pull up resistor issue?
If reset fixes it, add some delay after the wire begin to give it time to run.
HTH
GL :slight_smile: PJ
:v:

I really think if you get one of these…

you can do away with half your problems and get a few bonus as well

dont forget the case too… very handy

but the battery polarity is reverse from standard so you need to make up your own cable or switch the pins… i get a

https://www.amazon.com/dp/B08T9FB56F

https://www.amazon.com/dp/B01M5AHF0Z

https://www.amazon.com/dp/B0797NRXZY

https://www.amazon.com/dp/B096D8SCP6

ahahahahah you are an affiliated seller or what. i dont need that thank you. i dont see the value in investing in something i will not re-use after prototyping stage. Sorry.

thats how you pay back for all the free help you got

Hi there,
Sounds like it did NOT respond to the read request is what I’m seeing?
HTH
GL :slight_smile: PJ
:v: