MakerGram Logo

    MakerGram

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Users
    • Groups

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

    Arduino
    3
    11
    1232
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      shahidpk last edited by shahidpk

      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

      1 Reply Last reply Reply Quote 1
      • salmanfaris
        salmanfaris last edited by

        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.

        S 2 Replies Last reply Reply Quote 1
        • kowshik1729
          kowshik1729 last edited by

          @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.

          S 2 Replies Last reply Reply Quote 2
          • S
            shahidpk @salmanfaris last edited by

            @salmanfaris ok, lemme try

            1 Reply Last reply Reply Quote 0
            • S
              shahidpk @kowshik1729 last edited by

              @kowshik1729 yup. I had seen it somewhere

              1 Reply Last reply Reply Quote 0
              • S
                shahidpk @kowshik1729 last edited by

                @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.

                kowshik1729 1 Reply Last reply Reply Quote 1
                • kowshik1729
                  kowshik1729 @shahidpk last edited by kowshik1729

                  @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.

                  S 1 Reply Last reply Reply Quote 1
                  • S
                    shahidpk @salmanfaris last edited by

                    @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. 😌😓

                    salmanfaris 1 Reply Last reply Reply Quote 0
                    • S
                      shahidpk @kowshik1729 last edited by

                      @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.

                      1 Reply Last reply Reply Quote 0
                      • kowshik1729
                        kowshik1729 last edited by

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

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        Recent Posts

                        • @codelery Awesome. That's great news. Kudos to @rafitc99 . 🙌

                          @codelery Please keep us updated about your project, looking forward to seeing it in action 🤩

                          • read more
                        • C

                          @rafitc99 I changed the buffer and that solved the problem. Thanks a lot for coming to my rescue.

                          • read more
                        • C

                          @salmanfaris I did change the buffer size and everything is working perfectly. Thanks coming to my rescue.

                          • read more
                        • @codelery said in Help needed: Arduino Wireless Notice Board project:

                          I am using the hardware serial (pin 0 and 1 on Arduino Uno)

                          As @rafitc99 mentioned, you need to expand the Serila buffer, in the hardware serial also the Arduino board package implements a 64-byte ring buffer for send and receive on the hardware serial messages. So you need to change that to 256 as per your message length.

                          • read more
                        • C

                          @rafitc99 The thing is that I am not using the SoftwareSerial library in receiving the message from the first microcontroller. I am using the hardware serial (pin 0 and 1 on Arduino Uno)

                          • read more
                        By MakerGram | A XiStart Initiative | Built with ♥ NodeBB
                        Copyright © 2023 MakerGram, All rights reserved.
                        Privacy Policy | Terms & Conditions | Disclaimer | Code of Conduct