Receipt Tracker: AI-Powered Receipt Reader With OCR, MySQL, and Raspberry Pi

by Aleksander Brunzlow in Workshop > Woodworking

6 Views, 0 Favorites, 0 Comments

Receipt Tracker: AI-Powered Receipt Reader With OCR, MySQL, and Raspberry Pi

Screenshot 2025-06-23 100752.png

Want to automate your receipt tracking and log totals without typing a thing? In this project, you’ll build a AI-powered receipt scanner that runs on a your device with Raspberry Pi help and logs everything to a MySQL database.

🔧 Train YOLOv8 Model

Picture1.png
Picture2.png
  1. Gather a dataset of 200–300 receipt images
  2. Annotate with bounding boxes: total, date, store
  3. Extract annotated dataset with augmented photos
  4. Train YOLOv8 using Ultralytics CLI or script
  5. Export the best weights (e.g. best.pt)


💻Develop App Logic

Picture3.png
Picture4.png
  1. app.py – Gradio UI for uploading receipts and displaying results
  2. ReceiptService.py – Runs YOLOv8 detection → OCR → extracts store, date, total
  3. OCRUtils.py – Cleans and parses raw OCR text
  4. ReceiptRepository.py – Handles DB operations (insert, fetch, summarize)
  5. Database.py – Sets up and manages MySQL connection


🪚 Laser Cutting & Assembly

Picture5.jpg
  1. Created laser-cut file with:
  2. Walls, floor, and cutouts for the Raspberry Pi, LCD display, and RGB LED
  3. Assembled the enclosure by:
  4. Aligning cut pieces
  5. Gluing joints securely using wood glue.


🍓Raspberry Pi Setup

Picture7.jpg
WhatsApp Image 2025-06-18 at 01.17.20_63ffadd9.jpg
  1. Wire the LCD (16x2 I2C) – Displays the total monthly spending
  2. Connect the RGB LED – Provides real-time status feedback:
  3. 🟢 green = receipt saved
  4. 🔴 red = error
  5. 🟠 orange = idle/default
  6. Use lgpio and smbus libraries to control GPIO and I2C communication
  7. Create receipt_dashboard.py – Displays the current monthly total and sets LED color based on sys.argv input (e.g. green, red, etc.)
  8. Run dashboard_listener.py – A socket listener that waits for signals from the main app and triggers receipt_dashboard.py with the appropriate status command


🗄 MySQL Integration

Picture8.png
  1. Create a receipts table with fields: id, store, date, total
  2. Connect via mysql.connector
  3. Insert rows from the app once confirmed
  4. Query totals by month


🧪Test & Results

Picture9.png
Picture10.jpg
  1. Upload or capture a receipt
  2. Verify YOLOv8 detects key elements
  3. OCR reads text
  4. Record gets logged in MySQL
  5. LED turns green + LCD displays total


🧠 Conclusion

WhatsApp Image 2025-06-18 at 01.26.41_785fac29.jpg

You’ve built a working end-to-end system using AI, OCR, hardware, and databases. With minor upgrades, this project can become a mobile scanner or expense reporting tool.