Build a Smart AI Shopping Trolley with Raspberry Pi!
Meet Cartie — an AI-powered trolley that recognizes products with its camera, checks RFID tags, weighs items to stop theft, bills you automatically, guides you to shelves, and lets you pay with a QR code!
🛍️ Say hi to Cartie, your AI shopping trolley!
What Is a Smart Shopping Trolley, Anyway?
A smart trolley is a robot that helps you shop! Instead of waiting in a checkout line, Cartie uses a Raspberry Pi — a tiny but powerful computer — along with a camera, sensors, and a screen to recognize what you pick up, add it to your bill automatically, make sure nobody sneaks an item past the scale, and even guide you to where a product is on the shelf.
What You'll Need
This is a big build with eight smart features, so gather everything before you start!
Raspberry Pi 4 (4GB+)
The main computer running AI recognition and all logic.
Raspberry Pi Camera Module
"Sees" and identifies products you pick up.
RC522 RFID Reader + Tags
Confirms exactly which product tag was scanned.
Load Cell + HX711 Amplifier
Weighs the basket to catch mismatched or hidden items.
0.96" I2C OLED Display
Shows your shopping list, running total, and QR code.
DC Geared Motors + Wheels
Let the trolley roll toward a shelf location.
L298N Motor Driver
Lets the Pi safely control the two drive motors.
IR Line-Follower Sensors
Follow a floor guide line for indoor navigation.
Small Buzzer
Beeps for scans, alerts, and theft warnings.
Portable Power Bank (5V)
Powers the Raspberry Pi and all sensors.
WiFi Connection
Sends low-stock alerts to a "store" server.
Jumper Wires + Breadboard
Connects every sensor to the Pi's GPIO pins.
The Circuit Diagram
Here's how every sensor connects to the Raspberry Pi's GPIO header.
Step-by-Step Build Instructions
We'll build one smart feature at a time, then bring it all together. Work with an adult on wiring and soldering!
Set up the Raspberry Pi
Install Raspberry Pi OS, connect to WiFi, and enable the Camera, I2C, and SPI interfaces from raspi-config.
Mount the camera for product recognition
Attach the Pi Camera facing into the basket. It will capture a photo each time an item is placed inside, so the AI model can identify it.
💡 Tip: Good, even lighting makes the AI camera far more accurate!Add the RFID reader
Mount the RC522 near the basket opening. Each product gets its own RFID tag, which double-checks what the camera identified — two forms of verification are better than one!
Install the weight sensor
Mount the load cell under the basket floor, connected through the HX711 amplifier. This weighs the basket after every scan to make sure the weight change matches the expected product weight.
Attach the OLED screen
Mount the OLED display where the shopper can see it. It will show the running shopping list, total price, and — at checkout — a scannable QR code for payment.
Build the navigation base
Attach the two DC motors and wheels to the trolley base, wire them through the L298N motor driver, and mount the two IR line sensors underneath, facing down at a guide line on the floor.
Wire the buzzer and finish assembly
Add the buzzer for scan beeps and theft alerts. Double check every connection against the circuit diagram before powering everything on.
Install the software and test
Install the required Python libraries, copy the code below onto your Pi, and run it. Add an item to the basket and watch Cartie scan, weigh, and bill it automatically!
The Raspberry Pi Code (Python)
First install the libraries with: pip install opencv-python mfrc522 RPi.GPIO hx711 luma.oled qrcode requests. Then save this as smart_trolley.py and run it.
# 🛒🤖 Cartie the Smart Shopping Trolley — Raspberry Pi AI Project # Combines camera recognition, RFID, weight check, billing, QR payment, and alerts import cv2 import time import qrcode import requests from mfrc522 import SimpleMFRC522 from hx711 import HX711 from luma.core.interface.serial import i2c from luma.oled.device import ssd1306 from luma.core.render import canvas # ---- Setup sensors ---- reader = SimpleMFRC522() hx = HX711(dout_pin=5, pd_sck_pin=6) serial = i2c(port=1, address=0x3C) oled = ssd1306(serial) camera = cv2.VideoCapture(0) # ---- Product database: RFID id -> product info ---- products = { 111111: {"name": "Apple", "price": 0.50, "weight_g": 150, "aisle": "Aisle 2", "stock": 40}, 222222: {"name": "Milk", "price": 1.20, "weight_g": 1000, "aisle": "Aisle 5", "stock": 3}, 333333: {"name": "Bread", "price": 2.00, "weight_g": 500, "aisle": "Aisle 1", "stock": 20}, } shopping_list = ["Apple", "Milk", "Bread"] # the shopper's digital list cart = [] total_price = 0.0 last_weight = 0 def show_on_screen(line1, line2=""): """Displays two lines of text on the OLED screen""" with canvas(oled) as draw: draw.text((0, 10), line1, fill="white") draw.text((0, 30), line2, fill="white") def identify_product_with_camera(): """Captures a photo and runs it through a pretrained AI model (e.g. MobileNet-SSD) to guess what product was placed inside""" ret, frame = camera.read() # In a real build: run frame through a trained TensorFlow Lite model here # For this kid-friendly demo, we just confirm a photo was captured return ret def navigate_to_product(product_name): """Looks up the aisle and tells the shopper where to go""" for pid, info in products.items(): if info["name"] == product_name: show_on_screen(f"Find: {product_name}", f"Go to {info['aisle']}") return def check_low_stock(product): """Sends an alert to the store if stock is running low""" product["stock"] -= 1 if product["stock"] <= 5: try: requests.post("http://store-server.local/alert", json={"item": product["name"], "stock": product["stock"]}) except Exception: print(f"⚠️ Low stock alert (offline): {product['name']}") def generate_payment_qr(amount): """Creates a QR code with the total amount and shows it on the display""" qr_data = f"pay:cartie-checkout:amount={amount:.2f}" img = qrcode.make(qr_data) img.save("checkout_qr.png") show_on_screen("Scan to Pay", f"Total: ${amount:.2f}") def scan_item(): """Runs the full verification pipeline for one item""" global total_price, last_weight show_on_screen("Scanning...") rfid_id, _ = reader.read() # 1. RFID verification camera_ok = identify_product_with_camera() # 2. AI camera check current_weight = hx.get_weight_mean(readings=5) # 3. weight check if rfid_id in products and camera_ok: product = products[rfid_id] expected_weight = last_weight + product["weight_g"] if abs(current_weight - expected_weight) < 20: # within tolerance cart.append(product["name"]) total_price += product["price"] last_weight = current_weight check_low_stock(product) show_on_screen(f"Added: {product['name']}", f"Total: ${total_price:.2f}") else: show_on_screen("Weight Mismatch!", "Please re-scan item") else: show_on_screen("Unknown Item", "Ask staff for help") # ---- Main loop ---- show_on_screen("Welcome!", "Scan your first item") for item in shopping_list: navigate_to_product(item) time.sleep(3) scan_item() time.sleep(2) generate_payment_qr(total_price)
How Does Cartie Actually Work?
This project packs in real ideas used by actual smart-retail systems!
AI Object Recognition
A pretrained AI model learns to recognize shapes, colors, and patterns from thousands of example photos, so it can guess what product the camera is looking at.
Double Verification
Using both the camera AND the RFID tag means Cartie has two independent checks — if they disagree, it knows something's wrong.
Weight as a Safety Net
By comparing the basket's weight before and after each scan, Cartie can catch items that were placed in the cart without being scanned — a simple but powerful theft-prevention trick.
Indoor Navigation
Since GPS doesn't work well indoors, Cartie's line-follower sensors track a painted floor line, letting it roll toward the correct aisle.
Talking to a Server
The requests.post() call sends a tiny message over WiFi to a store computer whenever stock is low — this is exactly how real inventory systems communicate.
🧑🔬 Safety First!
- Build with an adult, especially for soldering, motor wiring, and setting up WiFi/network code.
- Never enter real payment details — the QR code in this project is for learning, not real transactions.
- Keep fingers clear of the wheels and motors while they're powered on.
- Double-check all wiring before connecting power — a wrong connection can damage the Raspberry Pi.
- This is a learning prototype, not a certified commercial checkout system.
Frequently Asked Questions
Do I really need a full AI model to start?
No! Start by testing with the RFID and weight sensor only — they alone can add items and bill correctly. Add the camera-based AI recognition once the basics work.
What is HX711 and why do I need it?
Load cells produce a very tiny electrical signal that the Raspberry Pi can't read directly. The HX711 amplifies that signal into a number the Pi can understand.
Can this work without a floor line for navigation?
Yes — instead of line-following, you could place RFID tags at each aisle's floor position and have Cartie "check in" as it passes each one, giving a simpler form of indoor location tracking.
What age group is this project good for?
Because it combines AI, sensors, and motors, this is best for older kids around age 12+ working closely with an adult experienced in Python and electronics.

Comments
Post a Comment