Build Robo Cart: a smart shopping trolley that scans, bills, and packs your groceries!
Robo Cart is a DIY smart shopping trolley powered by a Raspberry Pi camera. Show it a product, and it recognizes what you're buying, adds it to your bill, drops it safely into the basket through a servo-controlled lid, and — once you've paid — pops open the front door so you can grab your bagged shopping!
How Robo Cart thinks, in 4 simple steps
Every time you show it something, the trolley runs through the same friendly little routine — just like a cashier at a shop!
1. Scan
The Pi camera looks at the product you're holding up.
2. Add to bill
It recognizes the item and adds its price to the total.
3. Drop it in
A servo motor lifts the top lid so the item falls into the basket, then closes again.
4. Pay & collect
Once payment is confirmed, the front lid opens so you can bag your shopping.
What you'll need
Most parts are common in beginner robotics kits. Ask an adult to help with anything that needs cutting, gluing, or wiring.
| Part | What it does | Qty |
|---|---|---|
| Raspberry Pi (4B or Zero 2W) | The "brain" that runs the camera and controls everything | 1 |
| Raspberry Pi Camera Module | "Eyes" that scan each product | 1 |
| SG90 micro servo motors | Open and close the two lids | 2 |
| Push button | Simple "Payment Done" confirm button (for the demo) | 1 |
| Buzzer | Beeps when an item is added or payment completes | 1 |
| 16x2 LCD or small OLED display optional | Shows the running bill total | 1 |
| Jumper wires + breadboard | Wiring everything together | 1 set |
| Toy trolley / cardboard cart frame | The body of Robo Cart | 1 |
| 5V power bank (2A+) | Portable power for the Pi | 1 |
| Craft materials (cardboard, hinges, glue, tape) | Building the two lids | as needed |
Circuit diagram
Here's how the camera, servos, button, and buzzer connect to the Raspberry Pi's GPIO pins. Double-check power (red) and ground (black) before you power on!
Ask an adult for the wiring step
Always connect servos and the camera with the Raspberry Pi powered OFF, and get a grown-up to double-check your wiring before you switch it on.
Step-by-step build instructions
Take it one step at a time — Robo Cart doesn't need to be perfect, just working!
Prepare the trolley frame
Take your toy trolley or cardboard cart and mark two spots for the lids: one on the top (for dropping scanned items into the basket) and one on the front (for collecting the finished bag).
Attach the two lids on hinges
Cut two flat lid panels and attach each with a small hinge (tape hinges work fine for cardboard). Glue a servo arm to the underside of each lid.
Mount the servos
Fix Servo 1 near the top lid and Servo 2 near the front lid using hot glue or small screws, so each servo arm connects to its lid.
Tip: test each servo by hand-turning it gently before gluing it in place.Mount the Pi camera on a small pole
Fix the camera on a short pole above where products will be scanned, angled down at the scanning area, and connect it to the Pi's camera port with the ribbon cable.
Wire the servos, button, and buzzer
Follow the circuit diagram above to connect Servo 1 to GPIO17, Servo 2 to GPIO27, the pay button to GPIO22, and the buzzer to GPIO23. Keep power and ground wires on separate rows on your breadboard.
Install the software
On the Raspberry Pi, open a terminal and set up your Python environment:
sudo apt update sudo apt install python3-opencv python3-picamera2 -y pip3 install gpiozero
Add your product list
Decide which products Robo Cart should recognize (start with 2–3 easy ones, like a red apple or a yellow snack box) and note their prices — you'll add these into the code next.
Run the program and test
Run the script below, hold up a product, watch the top lid open and close, then press the pay button to see the front lid open.
If a servo jitters or doesn't move, check its wiring and make sure it's getting a steady 5V.The code that brings Robo Cart to life
This beginner-friendly Python script watches the camera, keeps a running bill, and controls both servo lids. It uses simple color detection to keep things easy to follow — once it works, you can upgrade it with a trained image-recognition model (see the tip below).
# robo_cart.py — Robo Cart's brain ๐ง ๐ import cv2 import numpy as np from picamera2 import Picamera2 from gpiozero import Servo, Button, Buzzer from time import sleep # ---------- Set up the camera ---------- picam2 = Picamera2() picam2.configure(picam2.create_preview_configuration( main={"size": (640, 480)})) picam2.start() # ---------- Set up the hardware ---------- cart_lid = Servo(17) # top lid — drops item into basket front_lid = Servo(27) # front lid — opens after payment pay_button = Button(22) buzzer = Buzzer(23) # ---------- Product list (name: price, color range) ---------- # Prices are in rupees — change these to your own products! PRODUCTS = { "apple": {"price": 20, "lower": (0, 120, 70), "upper": (10, 255, 255)}, "milk_box": {"price": 55, "lower": (100, 80, 80), "upper": (120, 255, 255)}, "biscuit": {"price": 30, "lower": (20, 100, 100), "upper": (35, 255, 255)}, } cart_total = 0 cart_items = [] def open_lid(servo): servo.max() sleep(1) def close_lid(servo): servo.min() sleep(1) def scan_for_product(): """Look at the camera frame and guess which product is shown.""" frame = picam2.capture_array() hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) for name, info in PRODUCTS.items(): mask = cv2.inRange(hsv, info["lower"], info["upper"]) match_pixels = cv2.countNonZero(mask) if match_pixels > 4000: # enough color match = found it! return name return None def add_to_cart(product_name): global cart_total price = PRODUCTS[product_name]["price"] cart_total += price cart_items.append(product_name) print(f"✅ Added {product_name} — ₹{price}") buzzer.beep(n=1, on_time=0.15) open_lid(cart_lid) sleep(2) # give the item time to drop in close_lid(cart_lid) def finish_shopping(): global cart_total, cart_items print(f"๐ฐ Final bill: ₹{cart_total} — payment received!") buzzer.beep(n=3, on_time=0.1) open_lid(front_lid) sleep(5) # time to collect and bag the items close_lid(front_lid) cart_total = 0 cart_items = [] print("๐ Ready for the next shopper!") # ---------- Main loop ---------- print("๐ Robo Cart is ready! Show me a product...") last_item = None while True: item = scan_for_product() if item and item != last_item: add_to_cart(item) print(f"๐งพ Cart total so far: ₹{cart_total}") last_item = item if pay_button.is_pressed: finish_shopping() last_item = None sleep(0.5)
Level-up idea
Once this version works, replace scan_for_product() with a model trained on Google's Teachable Machine, exported as TensorFlow Lite. That lets Robo Cart recognize real product shapes and labels instead of just colors!
Test it like a real cashier
Run through this little checklist with a grown-up before your first "customer" tries it out.
- Hold up one product at a time and confirm Robo Cart calls out the right name and price.
- Check the top lid opens fully, waits, then closes fully every time.
- Press the pay button and confirm the total resets to ₹0 after the front lid closes.
- Try two products in a row to make sure the bill adds up correctly.
- Test in good lighting — color detection works best without harsh shadows.
Frequently asked questions
Do I need to know how to code already?
No! This project is a great first robotics build. If you can follow along and change a few numbers (like prices), you can build Robo Cart. Ask an adult or an older sibling for help with wiring.
Which Raspberry Pi model works best?
A Raspberry Pi 4B or a Raspberry Pi Zero 2 W both work well. The camera and two small servos are light on processing power, so most recent Pi boards will run this project smoothly.
Can it use real payment methods like UPI or cards?
This project uses a simple push button to simulate "payment done," which keeps it safe and simple for a school or home project. For a classroom demo, that's perfectly realistic — real payment integration involves handling money securely and isn't recommended for a DIY kit.
Why does it use color detection instead of real object recognition?
Color detection is a gentle first step that teaches the same ideas — camera input, decision-making, and hardware control — without needing a trained AI model. Once you're comfortable, you can swap in a Teachable Machine model for real product recognition.
Is this project safe for kids to build?
Yes, with adult supervision for wiring, gluing, and any cutting. The electronics use safe low-voltage (5V) power, similar to a USB charger, and there are no sharp or hot components involved.

Comments
Post a Comment