Need Help on EM-18 reader module and arduino ||Want to read RFID continuously/ periodically



  • i am working with arduino and EM-18 Reader module. i have a code for reading different cards. But,it reads the card once and return the card data. i want to read the same card continuously or periodically using that module to detect the presence of the card on the reader module to do a specific task. simply, i want to get a high signal on a pin as long as there is a right a right card in the reader range .and the signal should be low if the card is away from the range of the reader.
    i have a code to read a card. for the operation that i mentioned above, what changes should i make in that code . or please provide a proper code. please Help !!!!!

    char input[12];                        
    int Number;
    
    void setup() {                       
      Serial.begin(9600);                                       
    }
    
    void loop() {                         
      if(Serial.available())             
      {
        int count = 0;
        while(Serial.available() && count < 12)
        {
          input[count] = Serial.read();
          count++;
          delay(5);
        }
        if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
           input[4] == '9' && input[5] == '4' && input[6] == 'D' && input[7] == '4' &&
           input[8] == '8' && input[9] == '1' && input[10] == 'A' && input[11] == 'C' )  //if the card id read is 6D0094D481AC
        {
          Number=1;                    
          Serial.println("GROUP 1"); 
        }
        else if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
           input[4] == '9' && input[5] == '4' && input[6] == 'D' && input[7] == '6' &&
           input[8] == 'F' && input[9] == 'F' && input[10] == 'D' && input[11] == '0' )    //if the read card id is 6D0094D6FFD0
        {
          Number=2;                   
          Serial.println("GROUP 2");
        }
         else if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
           input[4] == '9' && input[5] == '4' && input[6] == '9' && input[7] == 'C' &&
           input[8] == 'B' && input[9] == 'B' && input[10] == 'D' && input[11] == 'E' )
        {
          Number=3;
          Serial.println("GROUP 3");
        }
         else if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
           input[4] == '9' && input[5] == '4' && input[6] == 'B' && input[7] == '5' &&
           input[8] == 'E' && input[9] == 'B' && input[10] == 'A' && input[11] == '7' )
        {
          Number=4;
          Serial.println("GROUP 4");
        }
         else if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
           input[4] == '9' && input[5] == '4' && input[6] == 'C' && input[7] == '0' &&
           input[8] == '2' && input[9] == '3' && input[10] == '1' && input[11] == 'A' )
        {
          Number=5;
          Serial.println("GROUP 5");
       }
      }
    }
    

    😕 please Help



  • my thought is you can check the card availability by reading the card in a time interval, and you can run the function/task in between the time interval by assuming the card is there.



  • @shahidpk I have an idea, but don't know whether it works or not. Try to switch off and switch back on the module while keeping your card infront of the reader. If the detection time is very less then you can try to power off and power on the module rapidly and read the card data continously.

    But before trying this out, try how much time the module takes to initialize and read the card. if this time is too high then my method is waste to implement. As far as I read online, it is the protocol problem of the module. They are programmed to just output only once and other readings are internally masked. So, you need a module that is programmable and should be able to change it's firmware.



  • @salmanfaris ok, lemme try



  • @kowshik1729 yup. I had seen it somewhere



  • @kowshik1729 i am working on it. When vcc is reconnecting the module re-reads the card. It take about 1 seconds maximum to read it.



  • @shahidpk There we go. Now rapidly power off and power on the module to continously read the card data.

    Now I would like to tell a mistake which everyone does commonly whenever I tell to rapidly switch off and on the board. The first thought that gets in your mind is to connect the VCC of the Em-18 board directly to the Arduino's any of the digital pin and toggle that pin at a delay. Right? 😁

    It is a bad thing to do so. Because we do not know how much current does EM-18 reader module sucks from power supply while powering on. So, if it sucks more than 40mA from the Arduino's digital pin then there is a huge chance that the board can get damaged and eventually your USB port too. So, what is the work around in this case?

    The best practice I would suggest is to "Take a MOSFET, and connect the Gate terminal to the digital pin of arduino. On the drain pin connnect the power supply and on the source pin connect the EM-18 module's VCC pin. This is how you will be able to short the Drain and source gates by giving Gate voltage from the arduino."

    In this way you can protect the EM-18, Arduino as well. So, please do try this method, as far as I thought this would do the job.



  • @salmanfaris i have tried in all my ways... when power on in the absence of card. Shows no card. And led connected to indicate it is low(set by program on arduino pin 3). When card is placed it reads card and led light up. BUT it stay on always till power off. And once the card is placed. Then there is any change if card is removed. I noticed that by placing an led on tx pin of module, there is always a high signal from module. And when card is placing a small blink is seen. I think data stream. 😌😓



  • @kowshik1729 a simple npn transistor such as BC547 is enough for this.No need of MOSFET. EM-18 module draws 50mA current. I already tried it. But, No luck. I think, any changes are needed in my code.



  • @shahidpk I see. Can you please share the code?


Log in to reply
 

Recent Posts

  • read more
  • Hi @Akhil I found the following answer in one of the forums. here is the link to the thread.

    The way that I've seen most people do it (have a look on the Raspberry Pi forums), and have done myself with success is using /etc/rc.local.

    All you need to do here is put ./myscript in the rc.local text file. If it's in python, put python myscript.py.

    This literally is "a simple solution, (like dropping my script in some "startup" directory or something similar)"- maybe search on the forums when you're having questions as well, this solution came up on the first 4 results of a google search!

    read more
  • i need to run a QT application on BOOT. and i want to disable all controls like minimize application, close application.
    Anyone have experience in this? please help me.
    THANKS!

    read more
  • @mubassir-mk Glad that it helped.

    read more
  • M

    @kowshik1729 Thank you....
    Very help full your replay ...

    read more