🤖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

    Modules
    1
    2
    19
    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
      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
        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
        • First post
          Last post