pn532 bus is busy

ProgrammingZkall
Posts: 1
Joined: Thu Jul 25, 2024 6:14 am

pn532 bus is busy

Postby ProgrammingZkall » Thu Jul 25, 2024 6:22 am

Hello,

im trying to build a nfc scanner with the pn532 module and found this library
https://github.com/lucafaccin/esp-pn532 ... er/PN532.h

so i write this code: #include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_log.h"
#include "driver/gpio.h"
#include "driver/i2c.h"
#include "PN532.h"

#define TAG "main"
#define I2C_SDA_PIN 1
#define I2C_SCL_PIN 0
#define RESET_PIN 7
#define IRQ_PIN 2
#define I2C_PORT I2C_NUM_0

void nfc_task(void *pvParameters) {
uint8_t uid[7];
uint8_t uidLength;

if (!init_PN532_I2C(I2C_SDA_PIN, I2C_SCL_PIN, RESET_PIN, IRQ_PIN, I2C_PORT)) {
ESP_LOGE(TAG, "Failed to initialize PN532.");
vTaskDelete(NULL);
}

while (1) {
if (readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 1000)) {
printf("UID: ");
for (int i = 0; i < uidLength; i++) {
printf("%02X ", uid);
}
printf("\n");
} else {
ESP_LOGW(TAG, "No NFC tag detected.");
}

vTaskDelay(1000 / portTICK_PERIOD_MS); // Delay between reads
}
}

void app_main() {
xTaskCreate(nfc_task, "nfc_task", 4096, NULL, 5, NULL);
}

But i get this Log output.

I (953) PN532: Successfully Initialized!
I (963) PN532: writecommand Sending :
I (963) PN532: 48 00 00 ff 04 fc d4 4a 01 00 e1 00
E (963) PN532: writecommand I2C write failed: Operation timeout because the bus is busy.
E (1973) PN532: Timeout
D (1973) PN532: No card(s) read
W (1973) main: No NFC tag detected.
I (2983) PN532: writecommand Sending :
I (2983) PN532: 48 00 00 ff 04 fc d4 4a 01 00 e1 00
D (2993) PN532: Reading:
I (2993) PN532: 01 00 00 ff 00 ff 00 4a 01
D (2993) PN532: Waiting for IRQ (indicates card presence)
D (3993) PN532: IRQ Timeout
W (3993) main: No NFC tag detected.

Can sombody please help my to find a solution thanks alot.

Who is online

Users browsing this forum: Bing [Bot] and 51 guests