@123cheatn I'm trying very similar project but could not achieve it
On master Arduino, RFID UID ID will be read and send to 4 other Arduinos; they will react regarding to UID ID (activate a relay, led etc.). Also those 4 Arduinos have MFRC522 but won't be sending RF UID ID's, just reacting depending on which UID ID read by their reader.
I think I could not solve multiple SPI module code Here is my code;
#include <SPI.h>
#include <MFRC522.h>
#include <RF24.h>
#include <NRF24.h>
#include <nRF24L01.h>
NRF24 radio;
unsigned long time_now = 0;
int blinkled = 300;
int value;
int displace = 1000;
unsigned long CountDownStarted = 0;
int CountdownState = 0;
int Set60State = 0;
int Set90State = 0;
int EngineState = 0;
#define EnginePin 6
#define StartPin 7
#define Set90Pin 8
#define Set60Pin 9
#define TestLed 13
String cardUID ;
#define SS_RF 10
#define RST 5
#define SS_NRF 53
MFRC522 mfrc522(SS_RF, RST); // Create MFRC522 instance.
void setup()
{ pinMode(EnginePin, OUTPUT);
pinMode(StartPin, OUTPUT);
pinMode(Set90Pin, OUTPUT);
pinMode(Set60Pin, OUTPUT);
Serial.begin(115200); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
radio.setAddress(0xD2);
radio.begin(40, 53);
radio.setChannel(124);
radio.setRetries(0, 15);
radio.setActive(true);
pinMode(SS_RF, OUTPUT);
pinMode(SS_NRF, OUTPUT);
pinMode(TestLed, OUTPUT);
digitalWrite(EnginePin, LOW);
digitalWrite(StartPin, LOW);
digitalWrite(Set90Pin, LOW);
digitalWrite(Set60Pin, LOW);
digitalWrite(TestLed, LOW);
}
void loop()
{
radio.startListening();
if (CountdownState == 1) {
CountDown();
}
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content = "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "E0 0A DD A4" || content.substring(1) == "C0 57 FE A7" || content.substring(1) == "B0 AB 9F A5" || content.substring(1) == "50 51 1B A4" )
{
if (EngineState == 0) {
digitalWrite(EnginePin, HIGH);
Serial.print(F("Sending Engine Code... "));
bool sent = radio.send(0xD3, "E0 0A DD A4");
bool sent2 = radio.send(0xD4, "E0 0A DD A4");
bool sent3 = radio.send(0xD5, "E0 0A DD A4");
bool sent4 = radio.send(0xD6, "E0 0A DD A4");
Serial.println(sent ? "OK" : "failed");
Serial.println(sent2 ? "OK" : "failed");
Serial.println(sent3 ? "OK" : "failed");
Serial.println(sent4 ? "OK" : "failed");
EngineState = 1;
delay(50);
}
if (EngineState == 1) {
bool sent = radio.send(0xD3, "E0 0A DD A4");
bool sent2 = radio.send(0xD4, "E0 0A DD A4");
bool sent3 = radio.send(0xD5, "E0 0A DD A4");
bool sent4 = radio.send(0xD6, "E0 0A DD A4");
Serial.println(sent ? "OK" : "failed");
Serial.println(sent2 ? "OK" : "failed");
Serial.println(sent3 ? "OK" : "failed");
Serial.println(sent4 ? "OK" : "failed");
delay(100);
}
}
if ((EngineState != 0) && (content.substring(1) == "CD 9E 08 75" || content.substring(1) == "7D A6 4F 75" || content.substring(1) == "8D 2B 55 75" || content.substring(1) == "DD D1 6C 3E" ))
{
if (CountdownState == 0) {
Serial.println("Countdown Started");
digitalWrite(StartPin, HIGH);
delay(50);
digitalWrite(StartPin, LOW);
Serial.print(F("Sending Start Code... "));
bool sent = radio.send(0xD3, "CD 9E 08 75");
bool sent2 = radio.send(0xD4, "CD 9E 08 75");
bool sent3 = radio.send(0xD5, "CD 9E 08 75");
bool sent4 = radio.send(0xD6, "CD 9E 08 75");
Serial.println(sent ? "OK" : "failed");
Serial.println(sent2 ? "OK" : "failed");
Serial.println(sent3 ? "OK" : "failed");
Serial.println(sent4 ? "OK" : "failed");
CountdownState = 1;
}
if (CountdownState == 1) {
Serial.print(F("Sending Start Code... "));
bool sent = radio.send(0xD3, "CD 9E 08 75");
bool sent2 = radio.send(0xD4, "CD 9E 08 75");
bool sent3 = radio.send(0xD5, "CD 9E 08 75");
bool sent4 = radio.send(0xD6, "CD 9E 08 75");
Serial.println(sent ? "OK" : "failed");
Serial.println(sent2 ? "OK" : "failed");
Serial.println(sent3 ? "OK" : "failed");
Serial.println(sent4 ? "OK" : "failed");
delay(100);
}
}
if ((EngineState != 0) && (content.substring(1) == "7D 1C 65 5C" || content.substring(1) == "AD C2 5C 74"))
{
if (Set90State == 0) {
digitalWrite(Set90Pin, HIGH);
delay(50);
digitalWrite(Set90Pin, LOW);
Serial.print(F("Sending 90' Code... "));
bool sent = radio.send(0xD3, "7D 1C 65 5C");
bool sent2 = radio.send(0xD4, "7D 1C 65 5C");
bool sent3 = radio.send(0xD5, "7D 1C 65 5C");
bool sent4 = radio.send(0xD6, "7D 1C 65 5C");
Serial.println(sent ? "OK" : "failed");
Serial.println(sent2 ? "OK" : "failed");
Serial.println(sent3 ? "OK" : "failed");
Serial.println(sent4 ? "OK" : "failed");
Set90State = 1;
delay(50);
}
else
{
bool sent = radio.send(0xD3, "7D 1C 65 5C");
bool sent2 = radio.send(0xD4, "7D 1C 65 5C");
bool sent3 = radio.send(0xD5, "7D 1C 65 5C");
bool sent4 = radio.send(0xD6, "7D 1C 65 5C");
Serial.println(sent ? "OK" : "failed");
Serial.println(sent2 ? "OK" : "failed");
Serial.println(sent3 ? "OK" : "failed");
Serial.println(sent4 ? "OK" : "failed");
delay(100);
}
}
if ((EngineState != 0) && (content.substring(1) == "20 C4 18 A4" || content.substring(1) == "1D AE 2C 75"))
{
if (Set60State == 0) {
digitalWrite(Set60Pin, HIGH);
delay(50);
digitalWrite(Set60Pin, LOW);
bool sent = radio.send(0xD3, "20 C4 18 A4");
bool sent2 = radio.send(0xD4, "20 C4 18 A4");
bool sent3 = radio.send(0xD5, "20 C4 18 A4");
bool sent4 = radio.send(0xD6, "20 C4 18 A4");
Serial.println(sent ? "OK" : "failed");
Serial.println(sent2 ? "OK" : "failed");
Serial.println(sent3 ? "OK" : "failed");
Serial.println(sent4 ? "OK" : "failed");
Set60State = 1;
delay(50);
}
else
{
bool sent = radio.send(0xD3, "20 C4 18 A4");
bool sent2 = radio.send(0xD4, "20 C4 18 A4");
bool sent3 = radio.send(0xD5, "20 C4 18 A4");
bool sent4 = radio.send(0xD6, "20 C4 18 A4");
Serial.println(sent ? "OK" : "failed");
Serial.println(sent2 ? "OK" : "failed");
Serial.println(sent3 ? "OK" : "failed");
Serial.println(sent4 ? "OK" : "failed");
delay(100);
}
}
if (radio.available()) {
char buf[32];
uint8_t numBytes = radio.read(buf, sizeof(buf));
Serial.print(F("Received: "));
Serial.println(buf);
}
}
void CountDown() {
time_now = millis();
value = 128 + 127 * cos(2 * PI / blinkled * time_now);
analogWrite(TestLed, value);
//Serial.println(value);
}
Do you have any idea to solve this?