{"id":168239,"date":"2025-03-27T12:03:51","date_gmt":"2025-03-27T12:03:51","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=168239"},"modified":"2025-03-27T12:03:55","modified_gmt":"2025-03-27T12:03:55","slug":"esp32-cam-qr-code-reader-scanner-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-cam-qr-code-reader-scanner-arduino\/","title":{"rendered":"ESP32-CAM QR Code Reader\/Scanner (Arduino IDE)"},"content":{"rendered":"\n<p>Learn how to build a QR code reader\/scanner with the ESP32-CAM board programmed with Arduino IDE. The ESP32-CAM is constantly using its camera to scan for new QR codes using the <span class=\"rnthl rntliteral\">ESP32QRCodeReader<\/span> library and a modified version of the <span class=\"rnthl rntliteral\">quirc<\/span> library. When it detects a valid QR code, it prints the QR code data in the Serial Monitor.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32-CAM QR Code Reader Scanner Arduino IDE\" class=\"wp-image-168336\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Project Overview<\/h2>\n\n\n\n<p>Here is a quick overview of how the project works.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"850\" height=\"251\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner-Overview.jpg?resize=850%2C251&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32-CAM QR Code Scanner Project Overview\" class=\"wp-image-168338\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner-Overview.jpg?w=850&amp;quality=100&amp;strip=all&amp;ssl=1 850w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner-Overview.jpg?resize=300%2C89&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner-Overview.jpg?resize=768%2C227&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>The ESP32-CAM is constantly scanning for new QR Codes<\/li>\n\n\n\n<li>When it detects a valid QR Code, it prints its data in the Arduino IDE Serial Monitor<\/li>\n<\/ul>\n\n\n\n<p>This project can be used for a ticket attendance system, for product tracking, to act as an access system by checking QR codes to unlock doors or lockers, and many other applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parts Required<\/h2>\n\n\n\n<p>We&#8217;ll be using the ESP32-CAM board labeled as AI-Thinker module, but other modules should also work by making the correct pin assignment in the code. Another example is the <a href=\"https:\/\/randomnerdtutorials.com\/getting-started-freenove-esp32-wrover-cam\/\" title=\"\">Freenove ESP32-Wrover CAM Board<\/a>.<\/p>\n\n\n\n<p>The <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-cam\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32-CAM board<\/a> is a $9 device (or less) that combines an ESP32-S chip, an OV2640 camera, a microSD card slot, and several GPIO pins.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/ESP32-CAM-camera.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32-CAM board is a $9 device with an OV2640 camera, microSD card slot and several GPIO pins\" class=\"wp-image-82440\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/ESP32-CAM-camera.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/ESP32-CAM-camera.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>To follow this tutorial you need the following components:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-cam\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32-CAM with OV2640<\/a><\/strong> &#8211; read <a aria-label=\"Best ESP32-CAM Dev Boards (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/esp32-camera-cam-boards-review-comparison\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best ESP32-CAM Dev Boards<\/a> (or another ESP32-CAM with the OV2640 camera)<\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/esp32-cam-mb-usb-programmer\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Recommended &#8211; ESP32-CAM-MB Micro USB Programmer<\/a> or <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/ftdi-programmer-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">FTDI programmer<\/a><\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<p>For an introduction to the ESP32-CAM, you can follow the next tutorials:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-cam-video-streaming-face-recognition-arduino-ide\/\">ESP32-CAM Video Streaming and Face Recognition with Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-cam-ai-thinker-pinout\/\">ESP32-CAM AI-Thinker Pinout Guide: GPIOs Usage Explained<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-cam-troubleshooting-guide\/\">ESP32-CAM Troubleshooting Guide<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-cam-projects-ebook\/\">Build ESP32-CAM Projects using Arduino IDE (eBook)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Preparing the Arduino IDE<\/h2>\n\n\n\n<p>We&#8217;ll program the ESP32 board using Arduino IDE. So you need the Arduino IDE installed as well as the ESP32 add-on. You can follow the next tutorial to install the ESP32 add-on, if you haven\u2019t already:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-esp32-arduino-ide-2-0\/\" title=\"\">Installing ESP32 Board in Arduino IDE 2 (Windows, Mac OS X, Linux)<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Installing the&nbsp;ESP32QRCodeReader<\/h3>\n\n\n\n<p>For this tutorial, we\u2019ll use the&nbsp;<span class=\"rnthl rntliteral\">ESP32QRCodeReader<\/span> library by Alvarowolfx, which makes it easy to read QR codes with the ESP32-CAM board.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/github.com\/RuiSantosdotme\/ESP32QRCodeReader\/archive\/refs\/heads\/master.zip\" target=\"_blank\" rel=\"noopener\" title=\"\">Click here to download the ESP32QRCodeReader library<\/a><\/strong><\/li>\n<\/ul>\n\n\n\n<p>Then, in the Arduino IDE, go to&nbsp;<strong>Sketch<\/strong>&nbsp;&gt; <strong>Include Library<\/strong>&nbsp;&gt;&nbsp;<strong>Add .ZIP library<\/strong> and install the library that you&#8217;ve just downloaded in the previous link.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"560\" height=\"293\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/Arduino-Install-Library-Sketch-include-library-add-zip-library.png?resize=560%2C293&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino Install Library Sketch include library add zip library\" class=\"wp-image-168263\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/Arduino-Install-Library-Sketch-include-library-add-zip-library.png?w=560&amp;quality=100&amp;strip=all&amp;ssl=1 560w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/Arduino-Install-Library-Sketch-include-library-add-zip-library.png?resize=300%2C157&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Code &#8211; ESP32-CAM QR Code Reader\/Scanner<\/h2>\n\n\n\n<p>Copy the QR Code Scanner code to your Arduino IDE.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp32-cam-qr-code-reader-scanner-arduino\/\n*********\/\n\n#include &lt;Arduino.h&gt;\n#include &lt;ESP32QRCodeReader.h&gt;\n\n\/\/ FOR THIS PROJECT, YOUR ESP32-CAM NEEDS TO HAVE PSRAM.\n\/\/ Some of the compatible boards: CAMERA_MODEL_AI_THINKER | CAMERA_MODEL_WROVER_KIT | CAMERA_MODEL_ESP_EYE\n\/\/ CAMERA_MODEL_M5STACK_PSRAM | CAMERA_MODEL_M5STACK_V2_PSRAM | CAMERA_MODEL_M5STACK_WIDE  \nESP32QRCodeReader reader(CAMERA_MODEL_AI_THINKER);\n\nvoid onQrCodeTask(void *pvParameters) {\n  struct QRCodeData qrCodeData;\n\n  while (true) {\n    if (reader.receiveQrCode(&amp;qrCodeData, 100)) {\n      Serial.println(&quot;Scanned new QRCode&quot;);\n      if (qrCodeData.valid) {\n        Serial.print(&quot;Valid payload: &quot;);\n        Serial.println((const char *)qrCodeData.payload);\n      }\n      else {\n        Serial.print(&quot;Invalid payload: &quot;);\n        Serial.println((const char *)qrCodeData.payload);\n      }\n    }\n    vTaskDelay(100 \/ portTICK_PERIOD_MS);\n  }\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  Serial.println();\n\n  reader.setup();\n  Serial.println(&quot;Setup QRCode Reader&quot;);\n\n  reader.beginOnCore(1);\n  Serial.println(&quot;Begin on Core 1&quot;);\n\n  xTaskCreate(onQrCodeTask, &quot;onQrCode&quot;, 4 * 1024, NULL, 4, NULL);\n}\n\nvoid loop() {\n  delay(100);\n}<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/ESP32-CAM-Arduino-IDE\/raw\/master\/ESP32-CAM-ESP32QRCodeReader\/ESP32-CAM-ESP32QRCodeReader.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How the Code Works<\/h2>\n\n\n\n<p>The code starts by including the necessary libraries to perform the QR code scanning with the ESP32-CAM board:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;Arduino.h&gt;\n#include &lt;ESP32QRCodeReader.h&gt;<\/code><\/pre>\n\n\n\n<p>Then, create an object called <span class=\"rnthl rntliteral\">reader<\/span> for the QR code scanner, for this guide we are using the the AI-Thinker ESP32-CAM model.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ FOR THIS PROJECT, YOUR ESP32-CAM NEEDS TO HAVE PSRAM.\n\/\/ Some of the compatible boards: CAMERA_MODEL_AI_THINKER | CAMERA_MODEL_WROVER_KIT | CAMERA_MODEL_ESP_EYE\n\/\/ CAMERA_MODEL_M5STACK_PSRAM | CAMERA_MODEL_M5STACK_V2_PSRAM | CAMERA_MODEL_M5STACK_WIDE\n\nESP32QRCodeReader reader(CAMERA_MODEL_AI_THINKER);<\/code><\/pre>\n\n\n\n<p><strong>Note:<\/strong> your board needs to have PSRAM. This code was tested and it should be compatible with these ESP32-CAM board versions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CAMERA_MODEL_AI_THINKER<\/li>\n\n\n\n<li>CAMERA_MODEL_WROVER_KIT<\/li>\n\n\n\n<li>CAMERA_MODEL_ESP_EYE<\/li>\n\n\n\n<li>CAMERA_MODEL_M5STACK_PSRAM<\/li>\n\n\n\n<li>CAMERA_MODEL_M5STACK_V2_PSRAM<\/li>\n\n\n\n<li>CAMERA_MODEL_M5STACK_WIDE<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">setup()<\/h3>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span> function start by initializing a Serial communication at 115200 baud rate for debugging purposes.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void setup() {\n  Serial.begin(115200);\n  Serial.println();<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">reader.setup()<\/span> starts the camera hardware using the library\u2019s default settings for the AI-Thinker board or other board that you chose to define.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>reader.setup();\nSerial.println(\"Setup QRCode Reader\");<\/code><\/pre>\n\n\n\n<p>The camera reader will run on CPU core 1 (<a href=\"https:\/\/randomnerdtutorials.com\/esp32-dual-core-arduino-ide\/\">the ESP32 chip has two cores<\/a>).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>reader.beginOnCore(1);\nSerial.println(\"Begin on Core 1\");<\/code><\/pre>\n\n\n\n<p>Finally, create a FreeRTOS task to run the <span class=\"rnthl rntliteral\">onQrCodeTask<\/span> function. This allows us to continue running the QR code scanner in the background.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>xTaskCreate(onQrCodeTask, \"onQrCode\", 4 * 1024, NULL, 4, NULL);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">onQrCodeTask()<\/h3>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">onQrCodeTask<\/span> function, it keeps constantly scanning for new QR codes with the <span class=\"rnthl rntliteral\">while (true)<\/span> and when it detects a valid QR code it prints the data in the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void onQrCodeTask(void *pvParameters) {\n  struct QRCodeData qrCodeData;\n\n  while (true) {\n    if (reader.receiveQrCode(&amp;qrCodeData, 100)) {\n      Serial.println(\"Scanned new QRCode\");\n      if (qrCodeData.valid) {\n        Serial.print(\"Valid payload: \");\n        Serial.println((const char *)qrCodeData.payload);\n      }\n      else {\n        Serial.print(\"Invalid payload: \");\n        Serial.println((const char *)qrCodeData.payload);\n      }\n    }\n    vTaskDelay(100 \/ portTICK_PERIOD_MS);\n  }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Upload Code to ESP32-CAM AI-Thinker using ESP32-CAM-MB USB Programmer<\/h2>\n\n\n\n<p>To upload code to the ESP32-CAM board, attach the <a href=\"https:\/\/makeradvisor.com\/tools\/esp32-cam-mb-usb-programmer\/\" target=\"_blank\" rel=\"noopener\" title=\"\">ESP32-CAM-MB micro USB programmer<\/a> to your board (you can <a href=\"https:\/\/randomnerdtutorials.com\/upload-code-esp32-cam-mb-usb\/\">learn how it works by reading this guide<\/a>).<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/01\/ESP32-CAM-MB-Micro-USB-Programmer-CH340G-Serial-Chip-OV2640-Camera.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32-CAM-MB Micro USB Programmer CH340G Serial Chip OV2640 Camera\" class=\"wp-image-101577\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/01\/ESP32-CAM-MB-Micro-USB-Programmer-CH340G-Serial-Chip-OV2640-Camera.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/01\/ESP32-CAM-MB-Micro-USB-Programmer-CH340G-Serial-Chip-OV2640-Camera.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Then, connect the board to your computer using a USB cable.<\/p>\n\n\n\n<p>After that, in your Arduino IDE, go to&nbsp;<strong>Tools&nbsp;<\/strong>&gt;&nbsp;<strong>Board&nbsp;<\/strong>and select the&nbsp;<strong>AI-Thinker ESP32-CAM<\/strong>. Or search for that board on the top bar. You must have the&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-windows-instructions\/\">ESP32 add-on installed<\/a>. Otherwise, this board won\u2019t show up on the Boards menu.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"666\" height=\"586\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/select-AI-Thinker-Arduino-IDE.png?resize=666%2C586&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Select the AI-Thinker ESP32-CAM in Arduino IDE\" class=\"wp-image-168335\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/select-AI-Thinker-Arduino-IDE.png?w=666&amp;quality=100&amp;strip=all&amp;ssl=1 666w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/select-AI-Thinker-Arduino-IDE.png?resize=300%2C264&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/figure><\/div>\n\n\n<p>Go to&nbsp;<strong>Tools&nbsp;<\/strong>&gt;&nbsp;<strong>Port&nbsp;<\/strong>and select the COM port the ESP32-CAM is connected to.<\/p>\n\n\n\n<p class=\"rntbox rntcred\"><strong>Note: <\/strong> if the board doesn&#8217;t show up, it means that you probably don&#8217;t have the CH340C drivers installed on your computer. Go to Google and search &#8220;<strong>CH340C drivers<\/strong>&#8221; followed by your operating system and install the drivers.<\/p>\n\n\n\n<p>Finally, click the&nbsp;<strong>Upload&nbsp;<\/strong>button in your Arduino IDE.<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"32\" height=\"32\" src=\"https:\/\/i2.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/upload-button-arduino-ide.png?resize=32%2C32&amp;quality=100&amp;strip=all&amp;ssl=1\" alt=\"Program ESP32-CAM with Arduino IDE\" class=\"wp-image-91745\"\/><\/figure><\/div>\n\n\n<p>And that&#8217;s it! Your QR code scanner code should be running in your ESP32-CAM.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>After uploading the code, open the Serial Monitor at a baud rate of 115200. Press the ESP32-CAM reset button. It should initialize the QR code scanner. Check the Arduino IDE Serial Monitor window to see if everything is working as expected.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"620\" height=\"185\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-QR-Code-Scanner-Reader-Example-Arduino-IDE-Start-ok.png?resize=620%2C185&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32-CAM QR Code Scanner Reader Example Arduino IDE Start ok\" class=\"wp-image-168279\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-QR-Code-Scanner-Reader-Example-Arduino-IDE-Start-ok.png?w=620&amp;quality=100&amp;strip=all&amp;ssl=1 620w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-QR-Code-Scanner-Reader-Example-Arduino-IDE-Start-ok.png?resize=300%2C90&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/figure><\/div>\n\n\n<p>Point the ESP32-CAM to a QR code, here&#8217;s a sample QR code with the data <span class=\"rnthl rntliteral\">https:\/\/randomnerdtutorials.com\/<\/span>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"500\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/QR-Code-Examples-RandomNerdTutorials.png?resize=500%2C500&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"QR Code Example RandomNerdTutorials.com\" class=\"wp-image-168277\" style=\"width:224px;height:auto\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/QR-Code-Examples-RandomNerdTutorials.png?w=500&amp;quality=100&amp;strip=all&amp;ssl=1 500w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/QR-Code-Examples-RandomNerdTutorials.png?resize=300%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/QR-Code-Examples-RandomNerdTutorials.png?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner-Reader-Testing-Arduino-IDE-Serial-Monitor-Demonstration.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32-CAM Camera QR Code Scanner Reader Testing Arduino IDE Serial Monitor Demonstration\" class=\"wp-image-168282\" style=\"width:750px;height:auto\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner-Reader-Testing-Arduino-IDE-Serial-Monitor-Demonstration.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner-Reader-Testing-Arduino-IDE-Serial-Monitor-Demonstration.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The payload data should be printed in the Arduino IDE Serial Monitor:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"318\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-QR-Code-Scanner-Reader-Example-Arduino-IDE-Serial-Monitor-Demonstration.png?resize=764%2C318&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32-CAM QR Code Scanner Reader Example Arduino IDE Serial Monitor Demonstration\" class=\"wp-image-168278\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-QR-Code-Scanner-Reader-Example-Arduino-IDE-Serial-Monitor-Demonstration.png?w=764&amp;quality=100&amp;strip=all&amp;ssl=1 764w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-QR-Code-Scanner-Reader-Example-Arduino-IDE-Serial-Monitor-Demonstration.png?resize=300%2C125&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 764px) 100vw, 764px\" \/><\/figure><\/div>\n\n\n<p>If in the Arduino IDE Serial Monitor, you keep getting this message:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Invalid payload: ECC failure<\/code><\/pre>\n\n\n\n<p>You might need to use a smaller QR code, make the camera more stable, and point it directly to the QR code with better lighting conditions.<\/p>\n\n\n\n<p>The ESP32-CAM has some limitations in resolution and struggles with motion, so you need to aim it steadily at the QR code. Also, detecting QR codes can be difficult in poor lighting conditions, whether it&#8217;s too bright or too dark.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting and Tips<\/h2>\n\n\n\n<p>As we&#8217;ve mentioned earlier, this QR Code scanner uses a lot of memory, so your ESP32-CAM must have PSRAM. Here are some boards that were tested and should work with this example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CAMERA_MODEL_AI_THINKER<\/li>\n\n\n\n<li>CAMERA_MODEL_WROVER_KIT<\/li>\n\n\n\n<li>CAMERA_MODEL_ESP_EYE<\/li>\n\n\n\n<li>CAMERA_MODEL_M5STACK_PSRAM<\/li>\n\n\n\n<li>CAMERA_MODEL_M5STACK_V2_PSRAM<\/li>\n\n\n\n<li>CAMERA_MODEL_M5STACK_WIDE<\/li>\n<\/ul>\n\n\n\n<p>If you\u2019re getting any of the following errors, read our&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/esp32-cam-troubleshooting-guide\/\"><strong>ESP32-CAM Troubleshooting Guide: Most Common Problems Fixed<\/strong><\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Failed to connect to ESP32: Timed out waiting for packet header<\/li>\n\n\n\n<li>Camera init failed with error 0x20001 or similar<\/li>\n\n\n\n<li>Brownout detector or Guru meditation error<\/li>\n\n\n\n<li>Sketch too big error \u2013 Wrong partition scheme selected<\/li>\n\n\n\n<li>Board at COMX is not available \u2013 COM Port Not Selected<\/li>\n\n\n\n<li>Psram error: GPIO isr service is not installed<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>We hope you&#8217;ve found this tutorial useful and you can use it in your projects. If you don&#8217;t have an ESP32-CAM board, you can <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-cam\/\" target=\"_blank\" rel=\"noreferrer noopener\">click here to get one<\/a>.<\/p>\n\n\n\n<p>As mentioned previously, we have other tutorials with the ESP32-CAM that you may like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-cam-pir-motion-detector-photo-capture\/\">ESP32-CAM PIR Motion Detector with Photo Capture (saves to microSD card)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-cam-take-photo-display-web-server\/\">ESP32-CAM Take Photo and Display in Web Server<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-cam-projects-ebook\/\"><strong>Build ESP32-CAM Projects (eBook)<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32-cam\/\"><strong>Read all our ESP32-CAM Projects, Tutorials and Guides<\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<p>Thank you for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to build a QR code reader\/scanner with the ESP32-CAM board programmed with Arduino IDE. The ESP32-CAM is constantly using its camera to scan for new QR codes using &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32-CAM QR Code Reader\/Scanner (Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-cam-qr-code-reader-scanner-arduino\/#more-168239\" aria-label=\"Read more about ESP32-CAM QR Code Reader\/Scanner (Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":168336,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[281,276,277,319,264],"tags":[],"class_list":["post-168239","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32-project","category-esp32","category-esp32-arduino-ide","category-esp32-cam","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2025\/03\/ESP32-CAM-QR-Code-Scanner.jpg?fit=1920%2C1080&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/168239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=168239"}],"version-history":[{"count":13,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/168239\/revisions"}],"predecessor-version":[{"id":168364,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/168239\/revisions\/168364"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/168336"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=168239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=168239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=168239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}