🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    UHF RFID on M5Stack Core S3

    PRODUCTS
    2
    4
    69
    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.
    • D
      deano82
      last edited by

      I'm new to the M5Stack environment but I have the UHF RFID reader and a Core S3.

      I'm using Arduino IDE to attempt to upload the UHF Example but i keep encountering the following error when compiling or uploading to the device.

      Arduino\libraries\M5Stack\src\utility\Power.cpp:20:10: fatal error: esp32/rom/rtc.h: No such file or directory
      20 | #include "esp32/rom/rtc.h"
      | ^~~~~~~~~~~~~~~~~
      compilation terminated.
      exit status 1

      Compilation error: exit status 1

      This is the example i'm trying.

      #include <M5CoreS3.h>
      
      /*
       * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
       *
       * SPDX-License-Identifier: MIT
       */
      
      #include <M5Stack.h>
      #include <M5GFX.h>
      
      #include "UNIT_UHF_RFID.h"
      
      M5GFX display;
      M5Canvas canvas(&display);
      Unit_UHF_RFID uhf;
      
      String info = "";
      
      void setup() {
          M5.begin();  // Init M5Core.  初始化 M5Core
          // Serial2.begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t
          // txPin, bool invert) uhf.begin(HardwareSerial *serial = &Serial2, int
          // baud=115200, uint8_t RX = 16, uint8_t TX = 17, bool debug = false);
          uhf.begin(&Serial2, 115200, 16, 17, false);
          //   uhf.begin();
          while (1) {
              info = uhf.getVersion();
              if (info != "ERROR") {
                  Serial.println(info);
                  break;
              }
          }
      
          // max: 26dB
          uhf.setTxPower(2600);
      
          display.begin();
          canvas.setColorDepth(1);  // mono color
          canvas.setFont(&fonts::efontCN_14);
          canvas.createSprite(display.width(), display.height());
          canvas.setTextSize(2);
          canvas.setPaletteColor(1, GREEN);
          canvas.setTextScroll(true);
          canvas.println(info);
          canvas.println("1.BtnB Polling Card EPC");
          canvas.println("2.BtnC Select Card EPC");
          canvas.println("3.BtnA Write or Read Card Info");
          canvas.pushSprite(0, 0);
      }
      
      uint8_t write_buffer[]  = {0xab, 0xcd, 0xef, 0xdd};
      uint8_t reade_buffer[4] = {0};
      
      void log(String info) {
          Serial.println("Write Data...");
          canvas.println(info);
          canvas.pushSprite(0, 0);
      }
      
      void loop() {
          if (M5.BtnA.wasPressed()) {
              log("Write Data...");
              // uhf.writeCard(uint8_t *data, size_t size, uint8_t membank, uint16_t
              // sa, uint32_t access_password = 0);
              if (uhf.writeCard(write_buffer, sizeof(write_buffer), 0x04, 0, 0x00000000)) {
                  log("Write OK");
              } else {
                  log("Write ERROR");
              }
              delay(1000);
              log("Read Data...");
              // uhf.readCard(uint8_t *data, size_t size, uint8_t membank, uint16_t
              // sa, uint32_t access_password = 0);
              if (uhf.readCard(reade_buffer, sizeof(reade_buffer), 0x04, 0, 0x00000000)) {
                  log("Read OK");
                  log("Data Content");
                  for (uint8_t i = 0; i < sizeof(reade_buffer); i++) {
                      Serial.printf("%x", reade_buffer[i]);
                      canvas.printf("%x", reade_buffer[i]);
                  }
                  canvas.pushSprite(0, 0);
              } else {
                  log("Read ERROR");
              }
          }
          if (M5.BtnB.wasPressed()) {
              log("polling once");
              uint8_t result = uhf.pollingOnce();
              // polling 10 times
              // uint8_t result = uhf.pollingMultiple(20);
              Serial.printf("scan result: %d\r\n", result);
              if (result > 0) {
                  for (uint8_t i = 0; i < result; i++) {
                      log("pc: " + uhf.cards[i].pc_str);
                      log("rssi: " + uhf.cards[i].rssi_str);
                      log("epc: " + uhf.cards[i].epc_str);
                      log("-----------------");
                      delay(10);
                  }
              }
          }
          if (M5.BtnC.wasPressed()) {
              if (uhf.select(uhf.cards[0].epc)) {
                  log("Select OK");
              } else {
                  log("Select ERROR");
              }
              log("Current Select EPC:");
              log(uhf.selectInfo());
          }
          M5.update();
      }
      

      Can anyone point me in the direction of whatever i'm doing wrong? I've tried installing all the relevant libraries, removing them and adding them again i get no joy from doing any of this.

      Many thanks.

      1 Reply Last reply Reply Quote 0
      • Y
        yuyun2000
        last edited by

        The error you're encountering (fatal error: esp32/rom/rtc.h: No such file or directory) typically occurs when the Arduino IDE is not properly configured with the correct ESP32 board support package (BSP) or when there's a mismatch between the installed libraries and the board you're targeting (Core S3 in this case).
        Here are the steps to resolve the issue:

        1. Install or Update the ESP32 Board Support Package

        Open the Arduino IDE.
        Go to File > Preferences.
        In the "Additional Boards Manager URLs" field, ensure you have the following URL:https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

        If it's not there, add it and click "OK."
        Go to Tools > Board > Boards Manager.
        Search for esp32 and install or update the esp32 package by Espressif Systems.

        1. Select the Correct Board

        After installing the ESP32 BSP, go to Tools > Board and select M5Stack CoreS3 (or the closest match if "CoreS3" isn't listed explicitly).
        Ensure the Flash Mode, Partition Scheme, and other settings are appropriate for the Core S3.

        1. Check the M5Stack Library Version

        The error suggests a conflict with the M5Stack library. Ensure you're using the latest version of the M5Stack library compatible with the Core S3.
        Go to Sketch > Include Library > Manage Libraries.
        Search for M5Stack and install the latest version.
        If you already have it installed, try uninstalling and reinstalling it.

        1. Verify the Example Code

        The example you're using includes M5Stack.h and M5CoreS3.h. Ensure these headers are compatible with your setup.
        If the example is from an older version of the library, it might not work with the Core S3. Look for updated examples in the latest library documentation.

        1. Check the Serial Port and Upload Settings

        Ensure the correct serial port is selected under Tools > Port.
        If uploading fails, try pressing the reset button on the Core S3 just before uploading.

        1. Clean the Sketch Folder

        Sometimes, leftover files from previous builds can cause issues. Try creating a new sketch and copying the code into it.

        1. Debugging Further

        If the issue persists, share the exact steps you followed to set up the Arduino IDE and install the libraries. This will help pinpoint the problem.

        https://chat.m5stack.com/

        D 2 Replies Last reply Reply Quote 0
        • D
          deano82 @yuyun2000
          last edited by

          @yuyun2000 Hi, thanks for the response, i tried the M5Stack chat before posting, so i've tried all that you listed and still nothing works.

          1 Reply Last reply Reply Quote 0
          • D
            deano82 @yuyun2000
            last edited by

            @yuyun2000

            This is the sketch i'm using.

            /*
             * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
             *
             * SPDX-License-Identifier: MIT
             */
            
            
            #include <M5GFX.h>
            #include <M5CoreS3.h>
            #include <FastLED.h>
            #include "UNIT_UHF_RFID.h"
            
            M5GFX display;
            M5Canvas canvas(&display);
            Unit_UHF_RFID uhf;
            
            #define LED_PIN 35     // GPIO pin for the NeoPixel LED
            #define NUM_LEDS 1     // Number of LEDs (1 for Core S3)
            
            CRGB leds[NUM_LEDS];   // Define the LED array
            
            String info = "";
            
            void setup() {
                M5.begin();  // Init M5Core.  初始化 M5Core
                // Serial2.begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t
                // txPin, bool invert) uhf.begin(HardwareSerial *serial = &Serial2, int
                // baud=115200, uint8_t RX = 16, uint8_t TX = 17, bool debug = false);
                Serial2.begin(115200, SERIAL_8N1, 17, 18);
                uhf.begin(&Serial2, 115200, 17, 18, false);    
                //   uhf.begin();
                while (1) {
                    info = uhf.getVersion();
                    if (info != "ERROR") {
                        Serial.println(info);
                        break;
                    }
                }
            
                String info = uhf.getVersion();
            if (info != "ERROR") {
              Serial.println("UHF Module Connected. Version: " + info);
            } else {
              Serial.println("Failed to communicate with UHF Module!");
            }
                
                    // Initialize the NeoPixel LED
                FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);    
                // Set the LED to green
                leds[0] = CRGB::Green;
                FastLED.show();
            
                // max: 26dB
                uhf.setTxPower(2600);
            
                display.begin();
                canvas.setColorDepth(1);  // mono color
                canvas.setFont(&fonts::efontCN_14);
                canvas.createSprite(display.width(), display.height());
                canvas.setTextSize(2);
                canvas.setPaletteColor(1, GREEN);
                canvas.setTextScroll(true);
                canvas.println(info);
                canvas.println("1.BtnB Polling Card EPC");
                canvas.println("2.BtnC Select Card EPC");
                canvas.println("3.BtnA Write or Read Card Info");
                canvas.pushSprite(0, 0);
                Serial.println("Display initialized");
            }
            
            uint8_t write_buffer[]  = {0xab, 0xcd, 0xef, 0xdd};
            uint8_t reade_buffer[4] = {0};
            
            void log(String info) {
                Serial.println("Write Data...");
                canvas.println(info);
                canvas.pushSprite(0, 0);
            }
            
            void loop() {
                if (M5.BtnA.wasPressed()) {
                    log("Write Data...");
                    // uhf.writeCard(uint8_t *data, size_t size, uint8_t membank, uint16_t
                    // sa, uint32_t access_password = 0);
                    if (uhf.writeCard(write_buffer, sizeof(write_buffer), 0x04, 0, 0x00000000)) {
                        log("Write OK");
                    } else {
                        log("Write ERROR");
                    }
                    delay(1000);
                    log("Read Data...");
                    // uhf.readCard(uint8_t *data, size_t size, uint8_t membank, uint16_t
                    // sa, uint32_t access_password = 0);
                    if (uhf.readCard(reade_buffer, sizeof(reade_buffer), 0x04, 0, 0x00000000)) {
                        log("Read OK");
                        log("Data Content");
                        for (uint8_t i = 0; i < sizeof(reade_buffer); i++) {
                            Serial.printf("%x", reade_buffer[i]);
                            canvas.printf("%x", reade_buffer[i]);
                        }
                        canvas.pushSprite(0, 0);
                    } else {
                        log("Read ERROR");
                    }
                }
                if (M5.BtnB.wasPressed()) {
                    log("polling once");
                    uint8_t result = uhf.pollingOnce();
                    // polling 10 times
                    // uint8_t result = uhf.pollingMultiple(20);
                    Serial.printf("scan result: %d\r\n", result);
                    if (result > 0) {
                        for (uint8_t i = 0; i < result; i++) {
                            log("pc: " + uhf.cards[i].pc_str);
                            log("rssi: " + uhf.cards[i].rssi_str);
                            log("epc: " + uhf.cards[i].epc_str);
                            log("-----------------");
                            delay(10);
                        }
                    }
                }
                if (M5.BtnC.wasPressed()) {
                    if (uhf.select(uhf.cards[0].epc)) {
                        log("Select OK");
                    } else {
                        log("Select ERROR");
                    }
                    log("Current Select EPC:");
                    log(uhf.selectInfo());
                }
                M5.
            

            The sketch compiles perfectly fine and uploads to the device without error. this is the output.

            Sketch uses 796606 bytes (25%) of program storage space. Maximum is 3145728 bytes.
            Global variables use 37948 bytes (11%) of dynamic memory, leaving 289732 bytes for local variables. Maximum is 327680 bytes.
            esptool.py v4.8.1
            Serial port COM4
            Connecting...
            Chip is ESP32-S3 (QFN56) (revision v0.2)
            Features: WiFi, BLE
            Crystal is 40MHz
            MAC: 24:ec:4a:38:34:98
            Uploading stub...
            Running stub...
            Stub running...
            Changing baud rate to 921600
            Changed.
            Configuring flash size...
            Flash will be erased from 0x00000000 to 0x00004fff...
            Flash will be erased from 0x00008000 to 0x00008fff...
            Flash will be erased from 0x0000e000 to 0x0000ffff...
            Flash will be erased from 0x00010000 to 0x000d2fff...
            Compressed 20208 bytes to 13058...
            Writing at 0x00000000... (100 %)
            Wrote 20208 bytes (13058 compressed) at 0x00000000 in 0.2 seconds (effective 865.4 kbit/s)...
            Hash of data verified.
            Compressed 3072 bytes to 144...
            Writing at 0x00008000... (100 %)
            Wrote 3072 bytes (144 compressed) at 0x00008000 in 0.0 seconds (effective 980.9 kbit/s)...
            Hash of data verified.
            Compressed 8192 bytes to 47...
            Writing at 0x0000e000... (100 %)
            Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 1299.6 kbit/s)...
            Hash of data verified.
            Compressed 796752 bytes to 486375...
            Writing at 0x00010000... (3 %)
            Writing at 0x0001c618... (6 %)
            Writing at 0x0002181a... (10 %)
            Writing at 0x00026c91... (13 %)
            Writing at 0x0002c065... (16 %)
            Writing at 0x00031626... (20 %)
            Writing at 0x00036cfa... (23 %)
            Writing at 0x0003c073... (26 %)
            Writing at 0x00041262... (30 %)
            Writing at 0x000464a9... (33 %)
            Writing at 0x0004bdf3... (36 %)
            Writing at 0x00050f48... (40 %)
            Writing at 0x00056163... (43 %)
            Writing at 0x0005b41c... (46 %)
            Writing at 0x00061b58... (50 %)
            Writing at 0x00078b12... (53 %)
            Writing at 0x0007eb7e... (56 %)
            Writing at 0x00084ad7... (60 %)
            Writing at 0x0008a5e3... (63 %)
            Writing at 0x0008fa40... (66 %)
            Writing at 0x0009554d... (70 %)
            Writing at 0x0009ad33... (73 %)
            Writing at 0x000a05f6... (76 %)
            Writing at 0x000a5df1... (80 %)
            Writing at 0x000ab922... (83 %)
            Writing at 0x000b14ca... (86 %)
            Writing at 0x000b8d06... (90 %)
            Writing at 0x000c2507... (93 %)
            Writing at 0x000c86ae... (96 %)
            Writing at 0x000ce386... (100 %)
            Wrote 796752 bytes (486375 compressed) at 0x00010000 in 4.1 seconds (effective 1536.0 kbit/s)...
            Hash of data verified.
            
            Leaving...
            Hard resetting with RTC WDT...
            

            When the upload has completed the device does nothing. No screen activity at all, it's powered on but just a blank display. I've tried everything, obviously i'm missing something, i just don't know what it is.

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