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

    Unit QRCode suddenly stuck in Manual Scanning and doesn't read QR-Codes anymore

    Scheduled Pinned Locked Moved Modules
    3 Posts 2 Posters 2.1k Views 1 Watching
    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.
    • T Offline
      ThronKatze0
      last edited by

      I have a M5Stack CoreS3 and want to connect the Unit QRCode to it. At first everything worked well by just using the example code from Github.

      /*
       * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
       *
       * SPDX-License-Identifier: MIT
       */
      
      /**
       * @file i2c_mode.ino
       * @brief Unit QRCode I2C Mode Example
       * @version 0.2
       * @date 2024-06-19
       *
       *
       * @Hardwares: M5Core + Unit QRCode
       * @Platform Version: Arduino M5Stack Board Manager v2.1.0
       * @Dependent Library:
       * M5Unified: https://github.com/m5stack/M5Unified
       * M5GFX: https://github.com/m5stack/M5GFX
       * M5UnitQRCode: https://github.com/m5stack/M5Unit-QRCode
       */
      
      #include <M5Unified.h>
      #include <M5GFX.h>
      #include "M5UnitQRCode.h"
      
      M5Canvas canvas(&M5.Display);
      
      M5UnitQRCodeI2C qrcode;
      
      #define I2C_AUTO_SCAN_MODE
      
      void setup() {
          M5.begin();
      
          canvas.setColorDepth(1);  // mono color
          canvas.createSprite(M5.Display.width(), M5.Display.height());
          canvas.setTextSize((float)canvas.width() / 160);
          canvas.setTextScroll(true);
      
          Wire.begin(9,8); // Port B
          while (!qrcode.begin(&Wire, UNIT_QRCODE_ADDR, 21, 22, 100000U)) {
              canvas.println("Unit QRCode I2C Init Fail");
              Serial.println("Unit QRCode I2C Init Fail");
              canvas.pushSprite(0, 0);
              delay(1000);
          }
      
          canvas.println("Unit QRCode I2C Init Success");
          Serial.println("Unit QRCode I2C Init Success");
      #ifdef I2C_AUTO_SCAN_MODE
          canvas.println("Auto Scan Mode");
          canvas.pushSprite(0, 0);
          qrcode.setTriggerMode(AUTO_SCAN_MODE);
      #else
          canvas.println("Manual Scan Mode");
          canvas.pushSprite(0, 0);
          qrcode.setTriggerMode(MANUAL_SCAN_MODE);
      #endif
      }
      
      void loop() {
          if (qrcode.getDecodeReadyStatus() == 1) {
              uint8_t buffer[512] = {0};
              uint16_t length     = qrcode.getDecodeLength();
              Serial.printf("len:%d\r\n", length);
              qrcode.getDecodeData(buffer, length);
              Serial.printf("decode data:");
              for (int i = 0; i < length; i++) {
                  Serial.printf("%c", buffer[i]);
                  canvas.printf("%c", buffer[i]);
              }
              Serial.println();
              canvas.println();
              canvas.pushSprite(0, 0);
          }
      #ifndef I2C_AUTO_SCAN_MODE
          M5.update();
          if (M5.BtnA.wasPressed()) {
              // start scan
              qrcode.setDecodeTrigger(1);
          }
          if (M5.BtnB.wasPressed()) {
              // stop scan
              qrcode.setDecodeTrigger(0);
          }
      #endif
      }
      

      just had to add the Wire.begin(9,8) line.

      When I first plugged the scanner in, it was automatically in Auto Scan Mode and it worked fine, but all of a sudden (I can't remember if I did anything to cause this, sry) the unit only scans when I hit the trigger button and I can't read the codes anymore.

      Maybe I just need to do a factory reset of the scanner, but I wasn't able to find information on that.

      Would really appreciate your help!

      T 1 Reply Last reply Reply Quote 0
      • T Offline
        ThronKatze0 @ThronKatze0
        last edited by

        Solved it, just had to scan this QR Code
        https://community.m5stack.com/assets/uploads/files/1742537195503-bad5272e-aaac-47df-857b-c6d130524d36-image.png

        1 Reply Last reply Reply Quote 0
        • S Offline
          sk-ys
          last edited by

          Hi, I encountered a similar issue. When the QR code reader is in auto-scan mode, if the barcode is scanned more than once while the main program is in a delay state (e.g., 5000 ms), the barcode reader stops responding after the delay ends, and the data can no longer be read. I also tried reading the barcode from the image in the previous post, but nothing changed.
          Additionally, I have confirmed that communication is restored and the device becomes usable again by unplugging and reconnecting the I2C cable. Is it possible to reset the barcode reader programmatically?

          1 Reply Last reply Reply Quote 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
          • First post
            Last post