Vanclief / ESP32QRCodeReader

A library to read QR Codes using an ESP32 with a camera module.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESP32 QR Code Reader

This library provides a interface to read QR Codes using an ESP32 with a camera.

Internally this lib uses a slight modified version of the Quirc library and some code from OpenMV port on the MaixPy project.

This fork is adapted to work on Arduino IDE

Demos

Usage

Arduino IDE

This fork is adapted to work on Arduino IDE

Platformio

See the orignal project by Alvarowolfx

Examples

This library comes with a number of example sketches. See File > Examples > ESP32QRCodeReader within the Arduino application. You can see them on the examples folder on this repository.

Basic example:

#include <ESP32QRCodeReader.h>

// See available models on README.md or ESP32CameraPins.h
ESP32QRCodeReader reader(CAMERA_MODEL_AI_THINKER);

void onQrCodeTask(void *pvParameters)
{
  struct QRCodeData qrCodeData;

  while (true)
  {
    if (reader.receiveQrCode(&qrCodeData, 100))
    {
      Serial.println("Found QRCode");
      if (qrCodeData.valid)
      {
        Serial.print("Payload: ");
        Serial.println((const char *)qrCodeData.payload);
      }
      else
      {
        Serial.print("Invalid: ");
        Serial.println((const char *)qrCodeData.payload);
      }
    }
    vTaskDelay(100 / portTICK_PERIOD_MS);
  }
}

void setup()
{
  Serial.begin(115200);
  Serial.println();

  reader.setup();
  reader.beginOnCore(1);
  xTaskCreate(onQrCodeTask, "onQrCode", 4 * 1024, NULL, 4, NULL);
}

A QR-code for test is available qr-code_example.png

Limitations

  • Need an ESP32 module with PSRAM - See below.

Compatible Hardware

The QR Code recognition lib required a lot of memory, so I was only able to get this to work with an ESP32 that has PSRRAM available and also the Quirc library is modified to use that directly.

  • ESP32 module
  • PSRAM Available
  • Camera module - Tested with OV2640

ESP32 modules with camera that have PSRAM and should work:

  • CAMERA_MODEL_WROVER_KIT
  • CAMERA_MODEL_ESP_EYE
  • CAMERA_MODEL_M5STACK_PSRAM
  • CAMERA_MODEL_M5STACK_V2_PSRAM
  • CAMERA_MODEL_M5STACK_WIDE
  • CAMERA_MODEL_AI_THINKER

ESP32 modules without PSRAM that will not work:

  • CAMERA_MODEL_M5STACK_ESP32CAM
  • CAMERA_MODEL_TTGO_T_JOURNAL

License

This code is released under the MIT License.

References

About

A library to read QR Codes using an ESP32 with a camera module.

License:MIT License


Languages

Language:C 91.3%Language:C++ 8.7%