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.
pn532 bus is busy
-
- Posts: 1
- Joined: Thu Jul 25, 2024 6:14 am
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: Baidu [Spider], Google [Bot] and 60 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.