Attiny84 / RFID

Hi everybodies,

I’m actually doing a special project : Motorbycle signals full controlled by Arduino…
I’ve made my own code (using some codes already axisting…) and my system is nearly ready…

However, to save energy, I would like to separate the RFID reader by using an Attiny84 to drive it…
(So summarize, at stand-still, only the Attiny and RFID reader is powered, and when I’ve the Good TAG, then I energize my Arduino Pro-Mini to have all ready…)

My problem : Unable to have a functionning sketch for my Attiny… When I try to check the code I’ve SO many errors :frowning:

Here my code for my Attiny program :

#include <RFID.h>
#include <SPI.h>

#define buzzerPin 3

// Configuration RFID
RFID monModuleRFID(6,11);
    //Crée un tableau avec 5 blocs dans lequel on va stocker notre ID
int UID[5]={};  
    //Ceci est notre clé de comparaison pour valider l'accès.
int MASTERKEY[5]={145,157,135,112,251};

void setup() {
SPI.begin();
monModuleRFID.init();   // Initialiser Module RFID
tone(3, 2500, 100);
}

void loop() {

LectureRFID();

}
void LectureRFID(){
    if (monModuleRFID.isCard()) {  
        if (monModuleRFID.readCardSerial()) 
        {        
        for(int i=0;i<=4;i++)
        {
        UID[i]=monModuleRFID.serNum[i];
        } 
        if (
            UID[0] == MASTERKEY[0]
         && UID[1] == MASTERKEY[1]
         && UID[2] == MASTERKEY[2]
         && UID[3] == MASTERKEY[3]
         && UID[4] == MASTERKEY[4])
      //correspond au tag 1
        {
        digitalWrite (buzzerPin,HIGH);
        }
        else
        {
        digitalWrite (buzzerPin,LOW);
        }
        monModuleRFID.halt();
    }
    delay(50);
   }
}

Do you have some information or solution for me ?
For me, the problem comes from the RFID.h file… but I don’t know why !!!
(errors in the txt file enclosed)

Kind regards
Aurélien

errors.txt (16.3 KB)

You're using the stock SPI library on a chip without hardware SPI - unsurprisingly, all the registers associated with the SPI hardware don't exist. There is a USI, which can be used to do SPI, with a different library - but since the library for the RFID reader includes SPI as well, you have to modify that. This is a pain in the ass, so I don't recommend this approach.

There is a better way: Instead of whatever core you're using, use my core (board manager URL in my sig, or see https://github.com/SpenceKonde/ATTinyCore/blob/master/Installation.md ). It includes a special version of the SPI library that detects what sort of hardware the selected chip has, and selects the appropriate implementation of the interface provided by SPI.h - thus, you don't have to modify the libraries, and can often directly transfer code between normal Arduino boards and ATTiny's without full hardware SPI. Note that it doesn't support the user configurable clock speed like hardware SPI does - the function to set it is provided for compatibility, but it doesn't do anything.