Ring 1D 2D QR Code Scanner / Mini Barcode Reader Wiki - DFRobot

Introduction

This highly integrated QR code scanner with excellent performance can recognize common 1D codes and 2D codes. With a small size, it employs easy-to-connect Gravity Interface and is equipped with a RGB indicator that feeds back the sensor recognition status by showing different colors. Operating at 3.3V/5V, the scanner is compatible with UART and I2C communication, which makes it easier to develop on controllers like Arduino, ESP32, Raspberry Pi, etc. It can be used in self-service vending machines, subway gates, access control, payment machines, etc.

Features

Specification

Board Overview

Board Overview

No. Name Function
1 SDA/TX I2C communication data line/UART transmitting data line
2 SCL/RX I2C communication clock line/UART receiving data line
3 GND Power -
4 VCC Power + (3.3/5V)

Tutorial

Requirements

Connection Diagram

Connection

UART Sample Code

Turn the DIP switch of the adapter board to UART and then burn the code into your controller.

/*!
 *@file detect_uart.ino
 *@brief get the qr code information
 *@details  Scan QR codes continuously and serial output the information contained in codes.
 *@copyright   Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 *@license     The MIT license (MIT)
 *@author [fengli](li.feng@dfrobot.com)
 *@version  V1.0
 *@date  2021-6-29
 *@https://github.com/DFRobot/DFRobot_GM60
*/

#include <DFRobot_GM60.h>
DFRobot_GM60_UART  gm60;
/*Use software serial when using UNO or NANO*/
#if ((defined ARDUINO_AVR_UNO) || (defined ARDUINO_AVR_NANO))
    #include <SoftwareSerial.h>
    SoftwareSerial Serial1(2, 3);  //RX, TX
    #define FPSerial Serial1

#else
    #define FPSerial Serial1
#endif

void setup(){
  //Rx and tx should be mapping into D2 and D3 when using Firebeetle-ESP32
  #if (defined ESP32)
     Serial1.begin(9600, SERIAL_8N1, /*rx =*/D2, /*tx =*/D3);
  #else
  Serial1.begin(9600);
  #endif
  Serial.begin(115200);
  //Init chip
  gm60.begin(Serial1);
  //Restore to factory settings
 // gm60.reset();

  /**
  Read the data encoding mode
  encode Encoding mode
           eGBK,//gbk encoding
           eUTF8,//utf8 encoding
   */
  gm60.encode(/*encode = */gm60.eUTF8);

  /*! Set code config, the value of chip register can be changed by using the module to scan QR code
  on true (Enable setting code)/false (Disable setting code)
  content true (Output the set code content)/false (Not output the set code content)
  */
  gm60.setupCode(/*on =*/true,/*content=*/true);

  /**
    Set the available types of QR code for recognition
    berCode:
    eForbidAllBarcode, //Disable all the QR code recognition
    eEnableAllBarcode, // Enable all the QR code recognition
    eEnableDefaultcode, // Enable the default QR code recognition
  */
  gm60.setIdentify(/*berCode = */gm60.eEnableAllBarcode);
  Serial.println("Start to recognize");
}

void loop(){
  delay(50);
  // Detect the data contained in the scanned QR code, and return the scanned data as a character string.
  Serial.println(gm60.detection());

}

Expected Result

Detect the data contained in the scanned QR code, and return the scanned data as a character string and print it on the serial port.

Connection

I2C Sample Code

Turn the DIP switch of the adapter board to I2C and then burn the code into your controller.

/*!
 *@file detect_i2c.ino
 *@brief get the qr code information
 *@details  Scan QR codes continuously and serial output the information contained in codes.
 *@copyright   Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 *@license     The MIT license (MIT)
 *@author [fengli](li.feng@dfrobot.com)
 *@version  V1.0
 *@date  2021-6-29
 *@https://github.com/DFRobot/DFRobot_GM60
*/

#include <DFRobot_GM60.h>

/*!
 * @brief Constructor 
 * @param pWire I2c controller
 * @param addr  I2C address(0x1A)
 */
DFRobot_GM60_IIC  gm60;

void setup(){
  // Serial1.begin(9600);
  Serial.begin(115200);
  //Init chip
  gm60.begin();
  //Restore to factory settings
  gm60.reset();

  /**
  Read the data encoding mode
  encode Encoding mode
           eGBK,//gbk encoding
           eUTF8,//utf8 encoding
   */
  gm60.encode(gm60.eUTF8);

  /*! Set code config, the value of chip register can be changed by using the module to scan QR code
  on true (Enable setting code)/false (Disable setting code)
  content true (Output the set code content)/false (Not output the set code content)
  */
  gm60.setupCode(/*on =*/true,/*content=*/true);

  /**
    Set the available types of QR code for recognition
    berCode:
    eForbidAllBarcode, //Disable all the QR code recognition
    eEnableAllBarcode, // Enable all the QR code recognition
    eEnableDefaultcode, // Enable the default QR code recognition
  */
  gm60.setIdentify(gm60.eEnableAllBarcode);

  Serial.println("Start to recognize");
}

void loop(){
  delay(50);
  //Detect the data contained in the scanned QR code, and return the scanned data as a char string.
  Serial.println(gm60.detection());
}

Expected Result

Detect the data contained in the scanned QR code, and return the scanned data as a character string and print it on the serial port.

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents