I am having trouble using the MFRC522 RFID reader with the attiny84. I am trying to make a keycard security for a truck anti-theft system. I can make an atmega8 microcontroller work very well very easily, however I do not want to "waste" one if I don't need to. I am a complete noob, so this may be super easy for you guys to figure out. So far I have MOSI to pin6, MISO to pin5, SCK to pin4, SDA to pin10, RESET to pin8, GND to GND, 3.3v to 3.3v. I have absolutely no resistors, capacitors or anything(and this may be the problem). I am using ATTinyCore and the code seems to upload to the attiny84 chip without problems. I know the RFID reader works and the ID number for the card is correct. Here is the code:
#include <SPI.h>
#include <RFID.h>
#define SS_PIN 10
#define RST_PIN 8
RFID rfid(SS_PIN, RST_PIN);
String rfidCard;
int i;
int relay = 3;
int led = 9;
void setup() {
SPI.begin();
rfid.init();
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);
}
void loop() {
if (rfid.isCard()) {
if (rfid.readCardSerial()) {
rfidCard = String(rfid.serNum[0]) + " " + String(rfid.serNum[1]) + " " + String(rfid.serNum[2]) + " " + String(rfid.serNum[3]);
if (rfidCard=="211 160 177 30"){
digitalWrite(relay, HIGH);
}else if(rfidCard=="243 207 206 46"){
digitalWrite(relay, HIGH);
}else if(rfidCard=="17 145 161 38"){
digitalWrite(relay, HIGH);
}else{
}
}
}
rfid.halt();
}
This exact code works perfectly fine with the atmega8 chip.
Here are the settings I have selected:
Any help is appreciated. Thanks