โ† Back to list

Smart QR Code Attendance System ๐Ÿ”ฅ using ESP32-CAM and Python (Auto Google Sheet Update) ๐Ÿ“Š

Introduction

Pritam Kumar Roy ยท 2026-04-15 13:06 ยท 1 claps ยท 3.6 min read
#esp32-cam #python #computer-vision #iot
Open on Medium โ†—
Wiki topics: ๐Ÿ“Ÿ ยท Gadgets & IoT

Smart QR Code Attendance System ๐Ÿ”ฅ using ESP32-CAM and Python (Auto Google Sheet Update) ๐Ÿ“Š

Introduction

Manual attendance systems are still widely used in schools, colleges, and offices. However, they are time-consuming, prone to human error, and allow proxy attendance. Maintaining records manually also becomes difficult over time. To solve these problems, we can build a Smart QR Code Attendance System using the ESP32-CAM module and Python.

This system scans a studentโ€™s QR code using ESP32-CAM, processes it with Python, and automatically updates attendance in Google Sheets along with date and time. The entire process is wireless, automated, and requires very low-cost hardware.

https://youtube.com/shorts/fMEnT9MKLDg

Benefits of this System

  • Low-cost hardware setup
  • Fully wireless operation
  • Contactless attendance
  • Real-time Google Sheet update
  • Duplicate attendance prevention
  • Easy to scale for large classrooms

Project Overview

The system works in a simple pipeline:

  1. ESP32-CAM captures live video and streams it over WiFi
  2. Python script reads the live stream
  3. QR codes are detected using computer vision
  4. Student ID is extracted from the QR
  5. Data is sent to Google Apps Script
  6. Google Sheet updates automatically with timestamp
  7. Duplicate attendance is prevented for the same session

This makes the entire attendance process fully automated and reliable.

Components Required

To build this project, you only need a few components:

  • ESP32-CAM Module
  • ESP32-CAM Development Board (for uploading code)
  • USB Cable (for code upload)
  • WiFi connection
  • Laptop with Python installed

This makes it an ideal beginner-friendly IoT + AI project.

Step 1: Generate QR Codes for Students

Each student needs a unique QR code containing their ID. These QR codes will be scanned by the camera to mark attendance.

Python Code to Generate QR Codes (Snippet)

import qrcode

students = {
    "S01": "Rahul",
    "S02": "Amit",
    "S03": "Priya"
}
for sid, name in students.items():
    img = qrcode.make(sid)
    img.save(f"{sid}_{name}.png")

This script will generate QR code images for each student. You can print these QR codes and distribute them.

Example output:

  • S01_Rahul.png
  • S02_Amit.png
  • S03_Priya.png

Step 2: Setup Google Sheet

Create a new Google Sheet to store attendance. Add the following columns:

| ID | Name | Date | Time |

You can also optionally add:

  • Department
  • Subject
  • Status

This sheet will automatically populate when QR codes are scanned.

Step 3: Setup Google Apps Script

Google Apps Script acts as a bridge between Python and Google Sheets.

Steps

  1. Open Google Sheet
  2. Click Extensions โ†’ Apps Script
  3. Delete default code
  4. Paste the following snippet
function doGet(e) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var id = e.parameter.id;
  var date = new Date();

  sheet.appendRow([id, "", date.toLocaleDateString(), date.toLocaleTimeString()]);

  return ContentService.createTextOutput("Success");
}

Deploy as Web App

  1. Click Deploy โ†’ New Deployment
  2. Select Web App
  3. Access: Anyone
  4. Click Deploy
  5. Copy Web App URL

This URL will be used inside Python code.

Step 4: Setup ESP32-CAM in Arduino IDE

Install ESP32 Board

  1. Open Arduino IDE
  2. Go to Preferences
  3. Add board URL
  4. Install ESP32 boards

Select Board

Tools โ†’ Board โ†’ AI Thinker ESP32-CAM

Configure WiFi

Update WiFi credentials in camera code:

const char* ssid = "YOUR_WIFI";
const char* password = "YOUR_PASSWORD";

Upload the CameraWebServer example code.

After uploading, open Serial Monitor. You will see IP address like:

Camera Ready! Use 'http://192.168.1.5'

Copy this IP address.

Step 5: Python QR Scanner

import cv2
from pyzbar import pyzbar
import requests

ESP32_STREAM = "http://192.168.1.5"
GOOGLE_SCRIPT = "YOUR_WEB_APP_URL"

marked = set()
cap = cv2.VideoCapture(ESP32_STREAM)

(continued...)

This script:

  • Connects to ESP32-CAM stream
  • Detects QR code
  • Extracts student ID
  • Sends data to Google Sheet
  • Prevents duplicate attendance

Required Libraries

  1. OpenCV โ€” for camera stream handling
  2. pyzbar โ€” for QR code detection
  3. requests โ€” to send data to Google Sheet
  4. qrcode โ€” to generate QR codes (optional but recommended)
  5. Pillow โ€” required dependency for qrcode

Install All at Once

Run this command in terminal:

pip install opencv-python pyzbar requests qrcode pillow

How the System Works

  1. Student shows QR card to camera
  2. ESP32-CAM captures image
  3. Python detects QR code
  4. Student ID extracted
  5. Google Sheet updated automatically
  6. Date & time recorded
  7. Duplicate scan ignored

Features

  • Real-time attendance tracking
  • Automatic Google Sheet update
  • Duplicate entry prevention
  • Low cost hardware
  • Wireless system
  • Easy deployment

Applications

This project can be used in:

  • Schools and colleges
  • Office attendance
  • Event entry system
  • Workshop registration
  • Lab attendance
  • Smart classroom automation

Future Improvements

  • Face recognition integration
  • Mobile app dashboard
  • Cloud database storage
  • RFID + QR hybrid system
  • Student name auto mapping

Full Code

For complete working code and setup instructions: ๐Ÿ“ฉ DM me on Instagram and I will share the full project files.

Conclusion

This Smart QR Code Attendance System using ESP32-CAM and Python is a practical IoT project that automates attendance efficiently. It reduces manual work, prevents proxy attendance, and stores records in real time. The system is low cost, scalable, and ideal for educational institutions and offices.


๋ฉ”ํƒ€๋ฐ์ดํ„ฐ
post_id
ae4e65a276f4
slug
smart-qr-code-attendance-system-using-esp32-cam-and-python-auto-google-sheet-update-ae4e65a276f4
url
https://medium.com/@pritamkumarroy/smart-qr-code-attendance-system-using-esp32-cam-and-python-auto-google-sheet-update-ae4e65a276f4
canonical_url
https://medium.com/@pritamkumarroy/smart-qr-code-attendance-system-using-esp32-cam-and-python-auto-google-sheet-update-ae4e65a276f4
author_url
https://medium.com/@pritamkumarroy
status
ok
fetched_at
2026-07-18 18:40:04