Can I use the RFID Unit with the Grove interface on M5Camera?
-
I am trying to use RFID Unit (https://docs.m5stack.com/#/en/unit/rfid) connected to M5Camera.
But it ’s not working.
Can M5Camera use RFID Unit?I use Wire library and MFRC522 library.
easy example:
MFRC522 mfrc522 (0x28); Wire.begin (); mfrc522.PCD_Init (); // No return
Supplement:
- I2C scan was performed but i2c device was not found.
- I confirmed that it was connected correctly.
- The RFID Unit is operating when connected to M5Stack Gray.
-
Hi @iwasada which version of the camera are you using?
-
Thank you reply @lukasmaximus .
Where can I check the camera version?
Software firmware version?My camera is model B in this photo.
-
In the M5Stack example code there is a sample rfid program. It seems like you are missing a few things.
#include <Wire.h> #include "MFRC522_I2C.h" #include <M5Stack.h> // 0x28 is i2c address on SDA. Check your address with i2cscanner if not match. MFRC522 mfrc522(0x28); // Create MFRC522 instance. void setup() { M5.begin(); M5.Power.begin(); M5.Lcd.fillScreen( BLACK ); M5.Lcd.setCursor(0, 0); M5.Lcd.setTextColor(YELLOW); M5.Lcd.setTextSize(2); M5.Lcd.fillScreen( BLACK ); M5.Lcd.setCursor(0, 0); M5.Lcd.println("M5StackFire MFRC522"); Serial.begin(115200); // Initialize serial communications with the PC Wire.begin(); // Initialize I2C mfrc522.PCD_Init(); // Init MFRC522 ShowReaderDetails(); // Show details of PCD - MFRC522 Card Reader details Serial.println(F("Scan PICC to see UID, type, and data blocks...")); M5.Lcd.println("Scan PICC to see UID, type, and data blocks..."); } void loop() { // Look for new cards, and select one if present if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) { delay(50); return; } // Now a card is selected. The UID and SAK is in mfrc522.uid. // Dump UID Serial.print(F("Card UID:")); M5.Lcd.println(" "); for (byte i = 0; i < mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); Serial.print(mfrc522.uid.uidByte[i], HEX); M5.Lcd.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); M5.Lcd.print(mfrc522.uid.uidByte[i], HEX); } Serial.println(); } void ShowReaderDetails() { // Get the MFRC522 software version byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg); Serial.print(F("MFRC522 Software Version: 0x")); Serial.print(v, HEX); if (v == 0x91) Serial.print(F(" = v1.0")); else if (v == 0x92) Serial.print(F(" = v2.0")); else Serial.print(F(" (unknown)")); Serial.println(""); // When 0x00 or 0xFF is returned, communication probably failed if ((v == 0x00) || (v == 0xFF)) { Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?")); } }
obviously the esp camera does not have an lcd, so you would delete those lines and keep the serial lines.
-
@lukasmaximus
Thank you for the sample. However, I also confirmed this sample.Once again, I will post what I tried based on this sample.
M5.begin () and M5.Power.begin () are recognitions that are unnecessary in M5Camera. When enabled and execed, it stopped at the log "M5Stack Initialize ..".Therefore, comment outed.#include <Wire.h> #include "MFRC522_I2C.h" #include <M5Stack.h> // 0x28 is i2c address on SDA. Check your address with i2cscanner if not match. MFRC522 mfrc522 (0x28); // Create MFRC522 instance. void setup () { //M5.begin (); //M5.Power.begin (); Serial.begin (115200); // Initialize serial communications with the PC Wire.begin (); // Initialize I2C Serial.println (F ("PCD_Init () Start")); mfrc522.PCD_Init (); // Init MFRC522 Serial.println (F ("PCD_Init () Finish")); ShowReaderDetails (); // Show details of PCD-MFRC522 Card Reader details Serial.println (F ("Scan PICC to see UID, type, and data blocks ...")); } void loop () { // Look for new cards, and select one if present if (! mfrc522.PICC_IsNewCardPresent () ||! mfrc522.PICC_ReadCardSerial ()) { delay (50); return; } // Now a card is selected.The UID and SAK is in mfrc522.uid. // Dump UID Serial.print (F ("Card UID:")); for (byte i = 0; i <mfrc522.uid.size; i ++) { Serial.print (mfrc522.uid.uidByte [i] <0x10? "0": ""); Serial.print (mfrc522.uid.uidByte [i], HEX); } Serial.println (); } void ShowReaderDetails () { // Get the MFRC522 software version byte v = mfrc522.PCD_ReadRegister (mfrc522.VersionReg); Serial.print (F ("MFRC522 Software Version: 0x")); Serial.print (v, HEX); if (v == 0x91) Serial.print (F ("= v1.0")); else if (v == 0x92) Serial.print (F ("= v2.0")); else Serial.print (F ("(unknown)")); Serial.println (""); // When 0x00 or 0xFF is returned, communication probably failed if ((v == 0x00) || (v == 0xFF)) { Serial.println (F ("WARNING: Communication failure, is the MFRC522 properly connected?")); } }
Serial output stops with “PCD_Init () Start”. When PCD_Init () is confirmed, it seems to be infinite loop in the following while ().
void MFRC522 :: PCD_Reset () { PCD_WriteRegister (CommandReg, PCD_SoftReset); // Issue the SoftReset command. // The datasheet does not mention how long the SoftRest command takes to complete. // But the MFRC522 might have been in soft power-down mode (triggered by bit 4 of CommandReg) // Section 8.8.2 in the datasheet says the oscillator start-up time is the start up time of the crystal + 37,74�s.Let us be generous: 50ms. delay (50); // Wait for the PowerDown bit in CommandReg to be cleared while (PCD_ReadRegister (CommandReg) & (1 << 4)) { // PCD still restarting-unlikely after waiting 50ms, but better safe than sorry. } } // End PCD_Reset ()
I also found that the following logs continue to appear.
15:01:09.879 -> [I][esp32-hal-i2c.c:1130] i2cProcQueue(): Bus busy, reinit 15:01:09.924 -> [I][esp32-hal-i2c.c:1130] i2cProcQueue(): Bus busy, reinit 15:01:09.968 -> [I][esp32-hal-i2c.c:1130] i2cProcQueue(): Bus busy, reinit ...
-
@lukasmaximus
In the first place, I want to know if M5Camera is a specification that can use RFID Unit.
I think there is no problem. -
@iwasada of course it can use RFID Unit