RFID MRC-522 (Home security)

Hello guys, I need help in my project, i am new to this.
Last month I was stolen in my house and I have the idea to make a home security system with
cloud based platform (cayenne). Therefore I want to create a security system in my house.
I want to make a project where there are Arduino Uno, RFID scanner (RC-522), Esp8266 module (as a shield), Yx5300 (as mp3), and servo motor.

Here are some of the schemes that I have tried to create :

  1. Arduino + esp8266 (as a shield)

  2. Arduino + RFID RC-522

  3. Arduino + YX5300

  4. Arduino + Servo motors

What I want to ask is whether it is possible to combine all of them in 1 Arduino? coz I already bought all that :sweat_smile:

And even now I can only control LED Arduino using Esp8266 as a shield, im stuck :sweat:
I don’t really understand how to program it. Can anyone help me in making this project, I will really appreciate it :wink:

i guess you have connected to cayenne with this setup.

you can use this library GitHub - miguelbalboa/rfid: Arduino RFID Library for MFRC522 and similer project RFID based attendance monitoring system

do you have any link to this?

this can be controlled using a slider from cayenne dashboard.

Im sorry, I forgot to explain beforehand how the project went,
So I want to make, if the rfid scanner scans the correct rfid tags, it will trigger a servo motor (assuming as the door lock), and if the rfid scanner scans for the wrong rfid tags, it will trigger an alarm in the mp3 module (in my case yx5300)
is it possible to make it like that?

I found this article , hopefully it’s an example of the right project

I’ve read this project , but it’s using a different rfid scanner and mp3 module. What should i do now ?

Yup, it is possible. did you check the two links i have provided above?

Okay,I’ve checked it. Ive added the rc522 library before,
Should I upload the code from your project to my Arduino too?

the code is for wemos mini, you need to make changes to work with arduino uno and esp shield.

what is the function of pin D4 on your wemos? I see your existing scheme, but there is no cable connected to pin D4

hey Ive just made a new program code, everything is fine until I upload it

RFIDCLOUD.ino.txt (1.7 KB)

when I open the monitor serial, it looks like this

there seems to be something wrong with my program, can you check my program please ? what should I fix ?

is that the last output? is there any more lines in the serial monitor after that?

yes, it looks like this

when I tried using another program and deleted all the code related to the rfid scanner, only to turn on the default LED on Arduino, it worked fine

lets try a different approach.
First, set the baud rate of your esp to 9600 using this code:

// Basic serial communication with ESP8266
// Uses serial monitor for communication with ESP8266
//
//  Pins
//  Arduino pin 2 (RX) to ESP8266 TX
//  Arduino pin 3 to voltage divider then to ESP8266 RX
//  Connect GND from the Arduiono to GND on the ESP8266
//  Pull ESP8266 CH_PD HIGH
//
// When a command is entered in to the serial monitor on the computer 
// the Arduino will relay it to the ESP8266
//
 //AT+CIOBAUD=9600
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); 

 
void setup() 
{
    Serial.begin(9600);     // communication with the host computer
    //while (!Serial)   { ; }
 
    // Start the software serial for communication with the ESP8266
    ESPserial.begin(115200);  
 
    Serial.println("");
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    Serial.println("Ready");
    Serial.println("");    
}
 
void loop() 
{
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( ESPserial.available() )   {  Serial.write( ESPserial.read() );  }
 
    // listen for user input and send it to the ESP8266
    if ( Serial.available() )       {  ESPserial.write( Serial.read() );  }
}

Once uploaded, open the serial monitor. Type AT you should receive a response OK if all the connection is okay. Now type AT+CIOBAUD=9600 to change the baud rate to 9600.

it works well. What’s next ?

Now that you have set the baud rate to 9600, use this code to connect to cayenne.

#define CAYENNE_DEBUG       // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTESP8266Shield.h>
#include <SoftwareSerial.h>

#define VIRTUAL_CHANNEL 1


// WiFi network info.
char ssid[] = "";
char wifiPassword[] = "";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";


// Set ESP8266 Serial object. In this example we use the Serial1 hardware serial which is available on boards like the Arduino Mega.
//#define EspSerial Serial

SoftwareSerial EspSerial(2,3);

ESP8266 wifi(&EspSerial);

void setup()
{
  Serial.begin(9600);   
  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(9600);
  delay(10);
  Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);
 
}


void loop()
{
  Cayenne.loop();
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
  // Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
  Cayenne.virtualWrite(0, millis());
  // Some examples of other functions you can use to send data.
  //Cayenne.celsiusWrite(1, 22.0);
  //Cayenne.luxWrite(2, 700);
  //Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
  CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  //Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

my bad, i forgot to set ciobaud. and now it’s an error. is it broken?

you are getting error.:thinking:

I tried change baudrate using this command AT+UART=9600,8,1,0,0 from this link and receive OK on serial monitor, but AT does not working anymore, did I make a mistake ?

Upload below code and see if you get a response for AT

// Basic serial communication with ESP8266
// Uses serial monitor for communication with ESP8266
//
//  Pins
//  Arduino pin 2 (RX) to ESP8266 TX
//  Arduino pin 3 to voltage divider then to ESP8266 RX
//  Connect GND from the Arduiono to GND on the ESP8266
//  Pull ESP8266 CH_PD HIGH
//
// When a command is entered in to the serial monitor on the computer 
// the Arduino will relay it to the ESP8266
//
 //AT+CIOBAUD=9600
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); 

 
void setup() 
{
    Serial.begin(9600);     // communication with the host computer
    //while (!Serial)   { ; }
 
    // Start the software serial for communication with the ESP8266
    ESPserial.begin(9600);  
 
    Serial.println("");
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    Serial.println("Ready");
    Serial.println("");    
}
 
void loop() 
{
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( ESPserial.available() )   {  Serial.write( ESPserial.read() );  }
 
    // listen for user input and send it to the ESP8266
    if ( Serial.available() )      
}

hey, I changed the 9600 baudrate and use this code to connect to cayenne. this is on the serial monitor.However my cayenne dashboard shows Arduino is offline

The serial monitor looks like this if I use my code ASLI.ino.txt without adding a rfid scanner, and my cayenne dashboard looks normal, I can control it from there


sorry to ask a lot, and thank you for all the help :grimacing:

in the first code the esp serial baud is set to 9600 and second code the serial is set to 115200. How can the different baud rate work for same esp?