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

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


- Gather a dataset of 200–300 receipt images
- Annotate with bounding boxes: total, date, store
- Extract annotated dataset with augmented photos
- Train YOLOv8 using Ultralytics CLI or script
- Export the best weights (e.g. best.pt)
💻Develop App Logic


- app.py – Gradio UI for uploading receipts and displaying results
- ReceiptService.py – Runs YOLOv8 detection → OCR → extracts store, date, total
- OCRUtils.py – Cleans and parses raw OCR text
- ReceiptRepository.py – Handles DB operations (insert, fetch, summarize)
- Database.py – Sets up and manages MySQL connection
🪚 Laser Cutting & Assembly

- Created laser-cut file with:
- Walls, floor, and cutouts for the Raspberry Pi, LCD display, and RGB LED
- Assembled the enclosure by:
- Aligning cut pieces
- Gluing joints securely using wood glue.
Downloads
🍓Raspberry Pi Setup


- Wire the LCD (16x2 I2C) – Displays the total monthly spending
- Connect the RGB LED – Provides real-time status feedback:
- 🟢 green = receipt saved
- 🔴 red = error
- 🟠 orange = idle/default
- Use lgpio and smbus libraries to control GPIO and I2C communication
- Create receipt_dashboard.py – Displays the current monthly total and sets LED color based on sys.argv input (e.g. green, red, etc.)
- 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

- Create a receipts table with fields: id, store, date, total
- Connect via mysql.connector
- Insert rows from the app once confirmed
- Query totals by month
🧪Test & Results


- Upload or capture a receipt
- Verify YOLOv8 detects key elements
- OCR reads text
- Record gets logged in MySQL
- LED turns green + LCD displays total
🧠 Conclusion

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.