RFID Result Output

Dear All,
I am new to this forum as well new for Arduino & sensors. I am not sure if I am able to explain you the entire scenario but I am trying my best.

Requirement: We have connected 3 RFID chip via SPI communication to Ardunio UNO board. Arduino board is connected with BlueTooth device via which results are getting published. We need to push the result via bluetooth so that our external connected device (Android) will get the result. We will place any kind of item which is having RFID reader. If any item pickedup or placed over the board then it should send a singnal with the message over the bluetooth.
Scenarion 1: If no item placed over the RFID
Result 1: Nothing should get published as result.
Scenarion 2: If all 3 items placed over the RFID
Result 2: Nothing should get published as result.
Scenarion 3: If 3 item placed over the RFID but item 1 has been pickedup
Result 3: Message will say “Item 1 pickedup”
Scenarion 4: If 3 item placed over the RFID but item 1 & item 2 has been pickedup same time
Result 4: Last pickedup item should get as result
Scenarion 5: There was no item placed, but now item 3 is placed
Result 5: Message will say “Item 3 placed”

==============
I am using below code but it is not working as what I am expecting it gives all result excluding of the things.

#include <SPI.h>
#include <MFRC522.h>
#include <SoftwareSerial.h>

#define RST_PIN 9

#define SS_PIN 10
#define SS_PIN2 8
#define SS_PIN3 7

MFRC522 mfrc1(SS_PIN, RST_PIN);   // Create mfrc1 instance.
MFRC522 mfrc2(SS_PIN2, RST_PIN);
MFRC522 mfrc3(SS_PIN3, RST_PIN);
SoftwareSerial BTserial(2, 3); // RX | TX

bool timerGestartet = false;
unsigned long timeAfter2Seconds = 0;
unsigned long currentTime = 0;

void setup()
{
 Serial.begin(9600);   // Initiate a serial communication
 BTserial.begin(9600);
 SPI.begin();          // Initiate  SPI bus
 mfrc1.PCD_Init();
 mfrc3.PCD_Init();
 mfrc2.PCD_Init();
}
void loop()
{
 reader1();
 delay(100);
 reader1();
 delay(100);
 reader2();
 delay(100);
 reader2();
 delay(100);
 reader3();
 delay(100);
 reader3();

 Serial.println();
 BTserial.println();
 delay(1000);

}

void reader1()
{
 if ( ! mfrc1.PICC_IsNewCardPresent())
 {
   return;
 }
 if ( ! mfrc1.PICC_ReadCardSerial())
 {
   return;
 }
 String content1 = "";
 byte letter;
 for (byte i = 0; i < mfrc1.uid.size; i++)
 {
   Serial.print(mfrc1.uid.uidByte[i] < 0x10 ? " 0" : " ");
   Serial.print(mfrc1.uid.uidByte[i], HEX);
   BTserial.print(mfrc1.uid.uidByte[i], HEX);
   content1.concat(String(mfrc1.uid.uidByte[i] < 0x10 ? " 0" : " "));
   content1.concat(String(mfrc1.uid.uidByte[i], HEX));
 }
 Serial.println();
 content1.toUpperCase();
 if (content1.substring(1) == "C0 E3 7C A6")
 {
   Serial.println(" * Bottle - 1 ");
   BTserial.println(" * Bottle - 1 ");
 }
 else if (content1.substring(1) == "F2 17 8F 27")
 {
   Serial.println("  * Bottle - 2 ");
   BTserial.println("  * Bottle - 2 ");
 }
 else if (content1.substring(1) == "43 BE 7D 27")
 {
   Serial.println(" * Bottle - 3 ");
   BTserial.println(" * Bottle - 3 ");
 }
}

void reader2()
{
 if ( ! mfrc2.PICC_IsNewCardPresent())
 {
   return;
 }
 if ( ! mfrc2.PICC_ReadCardSerial())
 {
   return;
 }
 String content2 = "";
 for (byte i = 0; i < mfrc2.uid.size; i++)
 {
   Serial.print(mfrc2.uid.uidByte[i] < 0x10 ? " 0" : " ");
   Serial.print(mfrc2.uid.uidByte[i], HEX);
   BTserial.print(mfrc2.uid.uidByte[i], HEX);
   content2.concat(String(mfrc2.uid.uidByte[i] < 0x10 ? " 0" : " "));
   content2.concat(String(mfrc2.uid.uidByte[i], HEX));
 }
 Serial.println();
 content2.toUpperCase();
 if (content2.substring(1) == "C0 E3 7C A6")
 {
   Serial.println(" * Bottle - 1 ");
   BTserial.println(" * Bottle - 1 ");
 }
 else if (content2.substring(1) == "F2 17 8F 27")
 {
   Serial.println("  * Bottle - 2 ");
   BTserial.println("  * Bottle - 2 ");
 }
 else if (content2.substring(1) == "43 BE 7D 27")
 {
   Serial.println(" * Bottle - 3 ");
   BTserial.println(" * Bottle - 3 ");
 }
}

void reader3()
{
 if ( ! mfrc3.PICC_IsNewCardPresent())
 {
   return;
 }
 if ( ! mfrc3.PICC_ReadCardSerial())
 {
   return;
 }
 String content3 = "";
 for (byte i = 0; i < mfrc3.uid.size; i++)
 {
   Serial.print(mfrc3.uid.uidByte[i] < 0x10 ? " 0" : " ");
   Serial.print(mfrc3.uid.uidByte[i], HEX);
   BTserial.print(mfrc3.uid.uidByte[i], HEX);
   content3.concat(String(mfrc3.uid.uidByte[i] < 0x10 ? " 0" : " "));
   content3.concat(String(mfrc3.uid.uidByte[i], HEX));
 }
 Serial.println();
 content3.toUpperCase();
 if (content3.substring(1) == "C0 E3 7C A6")
 {
   Serial.println(" * Bottle - 1 ");
   BTserial.println(" * Bottle - 1 ");
 }
 else if (content3.substring(1) == "F2 17 8F 27")
 {
   Serial.println("  * Bottle - 2 ");
   BTserial.println("  * Bottle - 2 ");
 }
 else if (content3.substring(1) == "43 BE 7D 27")
 {
   Serial.println(" * Bottle - 3 ");
   BTserial.println(" * Bottle - 3 ");
 }
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks... Tom.... :slight_smile:

I have formatted my code and as well as I have added a picture of my board.
Regards,
Rajeev

Hi,
The Ops picture;

Tom… :slight_smile:

board_arduino.png

I am using below code but it is not working as what I am expecting it gives all result excluding of the things.

Google translate failed you miserably. This statement makes no sense and is completely devoid of facts.

The code does something that you have failed to adequately describe.
You expect the code to do something that you have failed to adequately describe.
You are doing something, when the code is running, that you have failed to adequately describe.

#define SS_PIN 10
#define SS_PIN2 8
#define SS_PIN3 7

Do you count this way? "Uh-huh, two, three..." Or do you count "one, two, three..."?

 reader1();

Good function names have a noun (what does the work) and a verb (what work gets done). This function name has neither. No one can make any kind of intelligent guess as to what this function does.

reader2() and reader3() are equally stupid names.

The delay()s in your code guarantee that your code will miss important events.

Scrap that crap, and start over.

Hi PaulS,
I can understand that may be names are stupid but the code always works as per expectation. As I have been mentioned that I am new for Arduino and I have never worked before. I am working on a enterprise level application where Arduino is a part of that application.
I have never ever worked before but somehow I managed with the help of google and documentation. If you can help me to resolve this issue will be helpful to me.

Regards,
Rajeev

I am thinking if we can handle it by using array. But incase of pickup it will be difficult.