Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. RFID-RC522 and sending text via serialgateway

RFID-RC522 and sending text via serialgateway

Scheduled Pinned Locked Moved My Project
3 Posts 2 Posters 806 Views 2 Watching
  • 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.
  • O Offline
    O Offline
    ozyreusz
    wrote on last edited by ozyreusz
    #1

    Hello
    I have a problem with sending out data from arduino to controller. Without mySensors everything is working, but when I try to introduce mySensors syntax everything just stops

    #define MY_GATEWAY_SERIAL
    
    #include <MySensors.h>  
    #include <SPI.h>
    #include <MFRC522.h>
    
    #define CHILD_ID_USER 20 
    #define SS_PIN 53
    #define RST_PIN 5
    
    MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class
     
    const byte michal[] = {0xD4,0x9E,0x17,0xA3};
    const byte martyna[] = {0x16,0xCF,0x8F,0x12};
    MyMessage msgUSER(CHILD_ID_USER, V_TEXT);
    
    void setup() { 
      Serial.begin(115200);
      SPI.begin(); 
      rfid.PCD_Init(); 
    }
    
    void presentation()  
    { 
      sendSketchInfo("USER", "1.1");
      present(CHILD_ID_USER, S_INFO);
    }
     
    void loop() {
      // Look for new cards
      if ( ! rfid.PICC_IsNewCardPresent()) 
        return;
     
      // Verify if the NUID has been readed
      if ( ! rfid.PICC_ReadCardSerial())
        return;
     
      if (rfid.uid.uidByte[0] == michal[0] || 
          rfid.uid.uidByte[1] == michal[1] || 
          rfid.uid.uidByte[2] == michal[2] || 
          rfid.uid.uidByte[3] == michal[3] ) 
         {
              Serial.println("User: Michal");  
              send(msgUSER.set("Michal"),1);
              delay(1500);
              
      }
      else if (rfid.uid.uidByte[0] == martyna[0] || 
               rfid.uid.uidByte[1] == martyna[1] || 
               rfid.uid.uidByte[2] == martyna[2] || 
               rfid.uid.uidByte[3] == martyna[3] )
                    {
              Serial.println("User: Martyna");  
              send(msgUSER.set("Martyna"),1);
              delay(1500);
              
      }
      else 
      {
              Serial.println("Niepoprawna karta!!!");
              send(msgUSER.set("Obcy"),1);
              delay(2000);
              
      }
      
      // Halt PICC
      rfid.PICC_HaltA();
     
      // Stop encryption on PCD
      rfid.PCD_StopCrypto1();
    }
    

    Meybe someone can see the error in my implementation?

    mfalkviddM 1 Reply Last reply
    0
    • O ozyreusz

      Hello
      I have a problem with sending out data from arduino to controller. Without mySensors everything is working, but when I try to introduce mySensors syntax everything just stops

      #define MY_GATEWAY_SERIAL
      
      #include <MySensors.h>  
      #include <SPI.h>
      #include <MFRC522.h>
      
      #define CHILD_ID_USER 20 
      #define SS_PIN 53
      #define RST_PIN 5
      
      MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class
       
      const byte michal[] = {0xD4,0x9E,0x17,0xA3};
      const byte martyna[] = {0x16,0xCF,0x8F,0x12};
      MyMessage msgUSER(CHILD_ID_USER, V_TEXT);
      
      void setup() { 
        Serial.begin(115200);
        SPI.begin(); 
        rfid.PCD_Init(); 
      }
      
      void presentation()  
      { 
        sendSketchInfo("USER", "1.1");
        present(CHILD_ID_USER, S_INFO);
      }
       
      void loop() {
        // Look for new cards
        if ( ! rfid.PICC_IsNewCardPresent()) 
          return;
       
        // Verify if the NUID has been readed
        if ( ! rfid.PICC_ReadCardSerial())
          return;
       
        if (rfid.uid.uidByte[0] == michal[0] || 
            rfid.uid.uidByte[1] == michal[1] || 
            rfid.uid.uidByte[2] == michal[2] || 
            rfid.uid.uidByte[3] == michal[3] ) 
           {
                Serial.println("User: Michal");  
                send(msgUSER.set("Michal"),1);
                delay(1500);
                
        }
        else if (rfid.uid.uidByte[0] == martyna[0] || 
                 rfid.uid.uidByte[1] == martyna[1] || 
                 rfid.uid.uidByte[2] == martyna[2] || 
                 rfid.uid.uidByte[3] == martyna[3] )
                      {
                Serial.println("User: Martyna");  
                send(msgUSER.set("Martyna"),1);
                delay(1500);
                
        }
        else 
        {
                Serial.println("Niepoprawna karta!!!");
                send(msgUSER.set("Obcy"),1);
                delay(2000);
                
        }
        
        // Halt PICC
        rfid.PICC_HaltA();
       
        // Stop encryption on PCD
        rfid.PCD_StopCrypto1();
      }
      

      Meybe someone can see the error in my implementation?

      mfalkviddM Online
      mfalkviddM Online
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      Welcome to the forum @ozyreusz!

      Could you expand on what you mean by "everything just stops"? Does the sketch not compile? If so, what error are you getting? Does the gateway not send messages through serial? If so, what does the debug output say? (add #define MY_DEBUG at top of your sketch)

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ozyreusz
        wrote on last edited by ozyreusz
        #3

        I get no output from the card I try to read. When I comment out all lines connected with mysensors library it works

        There are no errors
        The sketch checks cards id and returns name of the card owner, if it is known, if not "unknown person" is printed on serial. I wanted to send names detected to domoticz, so based on them it would be possible to create an event

        0;255;3;0;9;0 MCO:BGN:INIT GW,CP=R-NGA---,REL=255,VER=2.3.1
        0;255;3;0;14;Gateway startup complete.
        0;255;0;0;17;2.3.1
        0;255;3;0;11;USER
        0;255;3;0;12;1.1
        0;20;0;0;36;
        0;255;3;0;9;9 MCO:BGN:STP
        0;255;3;0;9;68 MCO:REG:NOT NEEDED
        0;255;3;0;9;71 MCO:BGN:INIT OK,TSP=NA```
        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        14

        Online

        12.0k

        Users

        11.2k

        Topics

        113.4k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular