NFC Module V3
- Войдите на сайт для отправки комментариев
Всем привет. Сразу хочу извиниться за свою Русский язык, часто делаю ошибки.
В чем заключается проблема, я стараюсь использовать модуль NFC Module V3 для того чтобы считывать специфическую карточку и с помощью этого открывать Соленоидный замок. Использую I2C шину.
Но вот незадача. Все работает прекрасно, кроме момента что модуль перегревается ужасно. Буквально за одну минуту до него уже невозможно прикоснуться.
Я использую 5В для того чтобы запитать сам модуль. Если же я стараюсь использовать 3В то модуль показывает что питание есть (индикатор питания светится). Но в Serial Monitor мне говорит что не видит модуля. В чем может быть проблема? Вот код на всякий случай. Сам код я взял в mysensors, сделал лишь модификации под свой ключ и реле.:
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_RFM69
#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
// Add your valid rfid keys here. To find you your key just run sketch; hold your new RFID tag in fron ot the reader;
// and copy the key from serial output of this sketch.
const uint8_t maxKeyLength = 7;
uint8_t validKeys[][maxKeyLength] = {
{ 0x73,0xF,0x23,0x1B,0x00,0x00,0x00 },
{ 0x79,0xB8,0xEC,0x0,0x00,0x00,0x00}, // ADD YOUR KEYS HERE!
{ 0, 0, 0, 0, 0, 0, 0 }};
int keyCount = sizeof validKeys / maxKeyLength;
#define CHILD_ID 99 // Id of the sensor child
// Pin definition
const int relay_pin = 8;
PN532_I2C pn532i2c(Wire);
PN532 nfc(pn532i2c);
void setup() {
Serial.begin (115200);
pinMode(relay_pin , OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(relay_pin, HIGH);
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Couldn't find PN53x board");
digitalWrite(13, HIGH);
while (1); // halt
}
Serial.print("Found NFC 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(0x3);
// configure board to read RFID tags
nfc.SAMConfig();
}
void loop() {
bool success;
uint8_t key[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t currentKeyLength; // 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, &key[0], ¤tKeyLength);
if (success) {
Serial.print("Found tag id: ");
for (uint8_t i=0; i < currentKeyLength; i++)
{
if (i>0) Serial.print(",");
Serial.print("0x");Serial.print(key[i], HEX);
}
for (uint8_t i=currentKeyLength; i < maxKeyLength; i++)
{
Serial.print(",0x00");
}
Serial.println("");
bool valid = false;
// Compare this key to the valid once registered here in sketch
for (int i=0;i<keyCount && !valid;i++) {
for (int j=0;j<currentKeyLength && !valid;j++) {
if (key[j] != validKeys[i][j]) {
break;
}
if (j==currentKeyLength-1) {
valid = true;
}
}
}
if (valid) {
// Switch lock status
digitalWrite(relay_pin, LOW);
}
// Wait for card/tag to leave reader
while(nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], ¤tKeyLength));
}
}
У них указано вот такой принцип подключения