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
- Use-to-connect Gravity interface
- 3.3V/5V power supply
- I2C & UART supported
Specification
- Power Supply: DC3.3V/5V
- Working Current: <70mA
- Communication: I2C, UART
- Image Pixel: 640*480
- Light Source: colorful indicator/green light flashing prompt successful reading
- Code System:
- 1D: EAN13, EAN8, UPCA, UPCE0, UPCE1, Code128, Code39, Code93, CodeBar, Interleaved 2 of 5 - 2D: QR code, Data Matrix, PDF417
- Depth of Field: QR Code (25mm-150mm product performance may be affected to varying degrees due to barcode quality and environmental conditions)
- Contrast: ≥25%
- Reading Angle: roll 360°, pitch 55°, yaw 55°
- Scanning Angle: 69° (horizontal), 56° (vertical)
- Reading Accuracy: ≥5mil
- Working Temperature: 20°C ~60°C
- Storage Temperature: -40°C ~80°C
- Environment Light: 0~100000Lux
- Relative Humidity: 5% to 95% (non-condensing)
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
Hardware
- DFRduino UNO R3 (or similar) x 1
- Gravity: Ring 2D QR Code Scanner x1
- M-M/F-M/F-F Jumper wires
Software
- Arduino IDE
- Download and install the GM60 Library (About how to install the library?)
Connection Diagram
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.
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.