A DIY QR Code Scanner project using Raspberry Pi, OpenCV, and ZBar library to scan and decode QR codes in real-time with a camera module.
- Real-time QR Code Detection - Scans and decodes QR codes instantly using a camera
- OpenCV Integration - Processes video feed for accurate QR code recognition
- ZBar Library Support - Robust QR code decoding with high reliability
- Display Output - Shows decoded QR code data on screen or terminal
- Customizable - Easily adaptable for various applications
- Cost-Effective - Affordable setup compared to commercial scanners
- Data Logging - Option to save scanned QR code data
- Portable Design - Compact system for versatile deployment
- Raspberry Pi 4B (1x) - Single-board computer (other models like 3B+ compatible)
- Raspberry Pi Camera Module (1x) - Official camera or USB webcam
- MicroSD Card (16GB+) - For Raspberry Pi OS and storage
- Power Supply - 5V 3A USB-C adapter for Raspberry Pi
- Monitor/Display - HDMI-compatible screen or SSH access
- Keyboard and Mouse - For setup and configuration
- Jumper Wires - For additional hardware connections (if needed)
- LCD Display - For portable display output
- Buzzer - Audio feedback for successful scans
- LED Indicators - Visual feedback for scan status
- External Storage - USB drive for additional data logging
Raspberry Pi Connections:
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
โ Raspberry Pi Pinโ Component โ Function โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโค
โ CSI Port โ Camera Module โ Video Input โ
โ 5V, GND โ Power Supply โ Power Input โ
โ HDMI โ Monitor โ Display Output โ
โ USB โ Keyboard/Mouse โ Input Devices โ
โโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโ
๐ Complete Circuit Diagram: View Detailed Schematic
- Install Raspberry Pi OS (Raspbian) on the MicroSD card using Raspberry Pi Imager
- Enable camera interface via
raspi-config
:sudo raspi-config # Navigate to Interface Options -> Camera -> Enable
- Update the system:
sudo apt update && sudo apt upgrade -y
Install required libraries:
sudo apt install python3-pip python3-opencv
pip3 install zbar-py
Clone the project repository:
git clone https://github.com/Circuit-Digest/QR-Code-Scanner-Raspberry-Pi.git
cd QR-Code-Scanner-Raspberry-Pi
Run the main script:
python3 qr_code_scanner.py
- Connect the camera module or USB webcam to the Raspberry Pi
- Run the Python script (
qr_code_scanner.py
) - Point the camera at a QR code
- View decoded data on the terminal or connected display
- Press
q
to exit the scanner
import cv2
import zbar
from zbar import Scanner
def main():
cap = cv2.VideoCapture(0)
scanner = Scanner()
while True:
ret, frame = cap.read()
if not ret:
break
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
symbols = scanner.scan(gray)
for symbol in symbols:
print(f"QR Code Data: {symbol.data}")
cv2.imshow('QR Scanner', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
main()
โโโ Code/
โ โโโ qr_code_scanner.py # Main QR code scanner script
โโโ Documentation/
โ โโโ Component_Connections.md # Detailed connections
โโโ Circuit Diagram/
โ โโโ QR_Code_Scanner_Circuit.png # Wiring schematic
โโโ README.md # This file
main()
- Initializes camera and processes QR code scanningscanner.scan()
- Decodes QR codes using ZBarcv2.imshow()
- Displays live video feedcv2.cvtColor()
- Converts frame to grayscale for processing
Camera Not Detected
- Verify camera connection in CSI port or USB
- Ensure camera is enabled in
raspi-config
- Check camera compatibility with Raspberry Pi
QR Code Not Decoded
- Adjust lighting conditions for better contrast
- Ensure QR code is within camera focus range
- Update OpenCV and ZBar libraries
Performance Issues
- Reduce camera resolution for faster processing
- Use a Raspberry Pi 4 for better performance
- Close unnecessary applications
- Product Scanning - Track inventory with QR codes
- Payment Systems - Process QR-based payments
- Asset Management - Monitor equipment usage
- Attendance Tracking - Scan student QR codes
- Library Management - Track book borrowing
- Event Check-in - Manage event registrations
- Access Control - QR-based entry systems
- Visitor Management - Log visitor details
- Ticketing Systems - Validate event tickets
- WiFi Connectivity - ESP8266 for cloud-based logging
- Mobile App Integration - Remote access to scan data
- Database Support - Store scans in MySQL/MongoDB
- Multi-Camera Support - Simultaneous scanning
- Audio Feedback - Buzzer for scan confirmation
- Web Interface - Real-time monitoring dashboard
Parameter | Value |
---|---|
Operating Voltage | 5V DC |
Current Consumption | 2.5A (with camera active) |
Camera Resolution | 1080p (adjustable) |
Scan Range | 5-30cm |
Processing Time | <1s per scan |
Operating System | Raspberry Pi OS |
Operating Temperature | 0ยฐC to 50ยฐC |
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit changes (
git commit -m 'Add AmazingFeature'
) - Push to branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- Follow Python PEP 8 coding standards
- Test modifications on Raspberry Pi hardware
- Update documentation for new features
- Include comments for complex code sections
- ๐ Complete Tutorial: CircuitDigest - QR Code Scanner Guide
- ๐ More Raspberry Pi Projects: Circuit Digest Raspberry Pi Collection
- ๐ OpenCV Tutorials: OpenCV Projects and Guides
If this project helped you, please โญ star this repository and share it with others!
Built with โค๏ธ by Circuit Digest | Making Electronics Simple
raspberry pi qr code scanner
opencv qr code project
diy qr code scanner
zbar python project
raspberry pi camera project
qr code reader
real-time qr scanner
raspberry pi projects
opencv applications