
Description
Especially after the recent success of Amazon Go cashierless convenience stores, there is a surge in adaptations of this relatively new approach to the shopping experience, including computer vision, sensor fusion, and deep learning. Since the nonpareil concept of cashierless stores is to make shoppers avoid tedious checkout lines and self-checkout stations, the stores equipped with this technology improve the customer experience and increase profit margins comparatively. While implementing this technology in a grocery or convenience store, smart grocery carts are the most prominent asset to provide an exceptional customer experience like Amazon Go. Although smart grocery carts improve the customer experience and plummet maintenance costs by providing an automated product tracking and payment system, the current integration methods are expensive investments for small businesses in the food retail industry since these methods require renovating (remodeling) store layouts or paying monthly fees to cloud services. After perusing recent research papers on smart grocery carts, I noticed there is no appliance devised for converting regular grocery carts into smart grocery carts without changing anything else in an existing establishment. Therefore, I decided to build a budget-friendly and easy-to-use device giving smart grocery cart perks to regular grocery carts with a user-friendly interface. To detect different food retail products accurately, I needed to create a valid data set in order to train my object detection model with notable veracity. Since OpenMV Cam H7 is a considerably small high-performance microcontroller board designed specifically for machine vision applications, I decided to utilize OpenMV Cam H7 in this project. Also, I was able to capture product images easily while collecting data and store them on an SD card since OpenMV Cam H7 has a built-in MicroSD card module. Then, I employed a color TFT screen (ST7735) to display a real-time video stream, the prediction (detection) results, and the selection (options) menu. After completing my data set including various food retail products, I built my object detection model with Edge Impulse to detect products added or removed to/from the grocery cart. I utilized Edge Impulse FOMO (Faster Objects, More Objects) algorithm to train my model, which is a novel machine learning algorithm that brings object detection to highly constrained devices. Since Edge Impulse is nearly compatible with all microcontrollers and development boards, I had not encountered any issues while uploading and running my model on OpenMV Cam H7. As labels, I utilized the product brand names, such as Nutella and Snickers. After training and testing my object detection (FOMO) model, I deployed and uploaded the model on OpenMV Cam H7 as an OpenMV firmware. Therefore, the device is capable of detecting products by running the model independently without any additional procedures or latency. Since I wanted to create a full-fledged device providing a wholesome shopping experience, I decided to build a web application from scratch in PHP, JavaScript, CSS, and MySQL. Therefore, I installed an Apache HTTP Server (XAMPP) on LattePanda 3 Delta, which also has a MariaDB database. This complementing web application lets customers create accounts via its interface, receives requests from the device to add or remove products to/from the customerβs database table, and creates a concurrent shopping list from the products added to the grocery cart. Also, the application sends an HTML email to the customerβs registered email address when the customer finishes shopping and is ready to leave the store, including the generated shopping list and the payment link. Since OpenMV Cam H7 does not provide Wi-Fi or cellular connectivity, I employed Beetle ESP32-C3 to get commands from OpenMV Cam H7 via serial communication and communicate with the web application via HTTP GET requests, which is an ultra-small size development board intended for IoT applications. To send commands via serial communication and control the selection menu after a product is detected by the model, I connected a joystick to OpenMV Cam H7. I also utilized the joystick while taking and storing pictures of various food retail products. To enable the device to determine when the customer completes shopping and is ready to leave the store, I connected an MFRC522 RFID reader to Beetle ESP32-C3 so as to detect the assigned RFID key tag provided by the store per grocery cart. Also, I connected a buzzer and an RGB LED to Beetle ESP32-C3 to inform the customer of the device status. After completing the wiring on a breadboard for the prototype and testing my code and object detection model, I decided to design a PCB for this project to make the device assembly effortless. Since Scrooge McDuck is one of my favorite cartoon characters and is famous for his wealth and stinginess, I thought it would be hilarious to design a shopping-related PCB based on him. Lastly, to make the device as robust and sturdy as possible while being attached to a grocery cart and utilized by customers, I designed a semi-transparent hinged case compatible with any grocery cart due to its hooks and snap-fit joints (3D printable). So, this is my project in a nutshell π In the following steps, you can find more detailed information on coding, capturing food retail product images, storing pictures on an SD card, building an object detection (FOMO) model with Edge Impulse, running the model on OpenMV Cam H7, developing a full-fledged web application, and communicating with the web application via Beetle ESP32-C3. ππ¨ Huge thanks to PCBWay for sponsoring this project. ππ¨ Huge thanks to DFRobot for sponsoring these products: β Beetle ESP32-C3 | Inspect β LattePanda 3 Delta 864 | Inspect β DFRobot 8.9β 1920x1200 IPS Touch Display | Inspect ππ¨ Also, huge thanks to Creality for sending me a Creality Sonic Pad, a Creality Sermoon V1 3D Printer, and a Creality CR-200B 3D Printer.













Step 1: Designing and soldering the Scrooge McDuck-inspired PCB
Before prototyping my Scrooge McDuck-inspired PCB design, I tested all connections and wiring with OpenMV Cam H7 and Beetle ESP32-C3. Then, I checked the connection status between Beetle ESP32-C3 and the web application hosted on LattePanda 3 Delta.







Step 1.1: Making connections and adjustments

Step 2: Designing and printing a semi-transparent hinged case
Since I focused on building a budget-friendly and easy-to-use device that captures food retail product images, detects products with object detection, and provides an exceptional customer experience, I decided to design a robust and sturdy semi-transparent hinged case allowing the customer to access the RFID reader and the joystick effortlessly. To avoid overexposure to dust and prevent loose wire connections, I added two snap-fit joints to the hinged case. Also, I decided to emboss different grocery cart icons on the top part of the hinged case to emphasize the shopping theme gloriously :) Since I needed to connect the top and bottom parts of the hinged case seamlessly, I designed a pin with pin ends (caps). To make the device compatible with any grocery cart, I added two hooks on the back of the bottom part. Also, I added a ring to the bottom part to attach the assigned RFID key tag. I designed the top and bottom parts of the hinged case, the pin, and the pin ends in Autodesk Fusion 360. You can download their STL files below.











- Natural


.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=f7e0414724182bfe83f20920c9d714c7)
.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=5edc39bf7053ea864ed871977b922355)
.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=d8ab559a6327f8c490f9a6298cd91c05)
.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=80edfc36452dd2bbb05224b6f8f029ab)
.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=bf06dbbf72fe9bd879e16fb7c50eb163)

.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=c3cf554c8d846c6323cd5476e8dabac5)
.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=9d01bd3d9ac7a0055902ec844deef7e1)

.png?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=4220d8451d57dd88afb53f36609c5334)
.png?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=2366671f9bb70d60152663428c1994ad)
.png?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=494e052fc41dbf5ef80a4f4a8710d19c)

Step 2.1: Improving print quality and speed with the Creality Sonic Pad
Since I wanted to improve my print quality and speed with Klipper, I decided to upgrade my Creality CR-200B 3D Printer with the Creality Sonic Pad. Creality Sonic Pad is a beginner-friendly device to control almost any FDM 3D printer on the market with the Klipper firmware. Since the Sonic Pad uses precision-oriented algorithms, it provides remarkable results with higher printing speeds. The built-in input shaper function mitigates oscillation during high-speed printing and smooths ringing to maintain high model quality. Also, it supports G-code model preview. Although the Sonic Pad is pre-configured for some Creality printers, it does not support the CR-200B officially yet. Therefore, I needed to add the CR-200B as a user-defined printer to the Sonic Pad. Since the Sonic Pad needs unsupported printers to be flashed with the self-compiled Klipper firmware before connection, I flashed my CR-200B with the required Klipper firmware settings via FluiddPI by following this YouTube tutorial. If you do not know how to write a printer configuration file for Klipper, you can download the stock CR-200B configuration file from here. :hash: After flashing the CR-200B with the Klipper firmware, copy the configuration file (printer.cfg) to a USB drive and connect the drive to the Sonic Pad. :hash: After setting up the Sonic Pad, select Other models. Then, load the printer.cfg file..jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=9443f6f79cfe290c0893d5df52372cb9)
.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=3f843529448d488e83266c82b9bd0996)

.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=3792f881dd9fa020939416a52ab669dc)
.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=97f02e2696f8b8b6b35f711d8be153ab)

.jpg?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=1638cf5b16b54d0c5625fef41a95cf04)
Step 2.2: Assembling the semi-transparent hinged case
After printing all parts (models), I placed the pin through the hinges on the top and bottom parts and fixed the pin via the pin ends (caps). I affixed the Scrooge McDuck PCB to the bottom part of the hinged case via a hot glue gun. Then, I attached the ST7735 TFT display to the hinged case via its slot on the bottom part to make customers see the screen even if the hinged case is closed via its built-in snap-fit joints.












Step 3: Creating a Twilio SendGrid account to send emails from localhost
Since I wanted to provide a wholesome user experience with this device, I decided to make it able to send the list of the products added to the grocery cart and the payment link to the customerβs registered email address on the database. However, I did not want to make this feature dependent on a paid email forwarder or cloud service. Therefore, I decided to send HTML emails directly from localhost via Twilioβs SendGrid Email API. SendGrid Email API provides proven email deliverability with its cloud-based architecture and has free of charge plan with 100 emails per day for relatively small projects like this. Also, SendGrid API provides official libraries for different programming languages, including PHP. :hash: First of all, sign up for SendGrid and create a new free trial account.









Step 4: Developing a web application with a user-friendly interface in PHP, JavaScript, CSS, and MySQL
To provide an exceptional online customer experience, I developed a full-fledged web application from scratch in PHP, JavaScript, CSS, and MySQL. This web application lets customers create accounts via its interface, receives requests from the device to add or remove the products detected by the object detection model to/from the customerβs database table, and creates a concurrent shopping list. Also, it sends an HTML email to the customerβs registered email address via SendGrid Email API when the customer finishes shopping and is ready to leave the store, including the generated shopping list and the payment link. As shown below, the web application consists of one folder and 7 code files:- /assets
- β /sendgrid-php
- β background.jpg
- β class.php
- β icon.png
- β index.css
- β index.js
- β update_list.php
- index.php
- product_list.php
- shopping.php












Step 4.1: Setting and running the web application on LattePanda 3 Delta 864
Since I have got a test sample of the brand-new LattePanda 3 Delta 864, I decided to host my web application on LattePanda 3 Delta. Therefore, I needed to set up a LAMP web server. LattePanda 3 Delta is a pocket-sized hackable computer that provides ultra performance with the Intel 11th-generation Celeron N5105 processor. Plausibly, LattePanda 3 Delta can run the XAMPP application. So, it is effortless to create a server with a MariaDB database on LattePanda 3 Delta.


Step 4.2: Providing a wholesome retail customer experience via the web application
After setting the web application on LattePanda 3 Delta 864: πποΈπ² The web application interface (index.php) lets the customer create an account by filling out the form:- First name
- Last name
- Account name
- Card number











Step 5: Capturing and storing product images w/ OpenMV Cam H7
Before proceeding with the following steps, I needed to install the OpenMV IDE in order to program OpenMV Cam H7. Plausibly, the OpenMV IDE includes all required libraries and modules for this project. Therefore, I did not need to download additional modules after installing the OpenMV IDE from here. You can get more information regarding the specific OpenMV MicroPython libraries from here. After setting up OpenMV Cam H7 on the OpenMV IDE, I programmed OpenMV Cam H7 to capture product images in order to store them on the SD card and create appropriately labeled samples for the Edge Impulse object detection (FOMO) model. Since I decided to distinguish foods and drinks with classes while creating a valid data set for the object detection model, I utilized the joystick attached to OpenMV Cam H7 so as to choose among two different classes. After selecting a class, OpenMV Cam H7 captures a picture, appends the selected class name (Food or Drink) with the current date & time to the file name, and then saves the captured image to the SD card under the samples folder.- Joystick (Up) β‘ Food
- Joystick (Down) β‘ Drink


Step 5.1: Saving the captured product images to the SD card as samples
After uploading and running the code for capturing product images and saving them to the SD card on OpenMV Cam H7: πποΈπ² The device shows a real-time video stream on the ST7735 color TFT display.








- Barilla
- Milk
- Nutella
- Pringles
- Snickers


Step 6: Building an object detection (FOMO) model with Edge Impulse
When I completed capturing food retail product images and storing them on the SD card, I started to work on my object detection (FOMO) model to detect different products. Since Edge Impulse supports almost every microcontroller and development board due to its model deployment options, I decided to utilize Edge Impulse to build my object detection model. Also, Edge Impulse provides an elaborate machine learning algorithm (FOMO) for running more accessible and faster object detection models on edge devices such as OpenMV Cam H7. Edge Impulse FOMO (Faster Objects, More Objects) is a novel machine learning algorithm that brings object detection to highly constrained devices. FOMO models can count objects, find the location of the detected objects in an image, and track multiple objects in real-time, requiring up to 30x less processing power and memory than MobileNet SSD or YOLOv5. Even though Edge Impulse supports JPG or PNG files to upload as samples directly, each training or testing sample needs to be labeled manually. Therefore, I needed to follow the steps below to format my data set so as to train my object detection model accurately:- Data Scaling (Resizing)
- Data Labeling
- Barilla
- Milk
- Nutella
- Pringles
- Snickers
Step 6.1: Uploading images (samples) to Edge Impulse and labeling samples
After collecting training and testing image samples, I uploaded them to my project on Edge Impulse. Then, I utilized the product brand names to label each sample. :hash: First of all, sign up for Edge Impulse and create a new project.



















Step 6.2: Training the FOMO model on various food retail products
After labeling my training and testing samples successfully, I designed an impulse and trained it on detecting a small group of food retail products. An impulse is a custom neural network model in Edge Impulse. I created my impulse by employing the Image preprocessing block and the Object Detection (Images) learning block. The Image preprocessing block optionally turns the input image format to grayscale and generates a features array from the raw image. The Object Detection (Images) learning block represents a machine learning algorithm that detects objects on the given image, distinguished between model labels. :hash: Go to the Create impulse page and set image width and height parameters to 160. Then, select the resize mode parameter as Fit shortest axis so as to scale (resize) given training and testing image samples. :hash: Select the Image preprocessing block and the Object Detection (Images) learning block. Finally, click Save Impulse.





- Number of training cycles β‘ 100
- Learning rate β‘ 0.005
- Validation set size β‘ 5
- FOMO (Faster Objects, More Objects) MobileNetV2 0.35

Step 6.3: Evaluating the model accuracy and deploying the model
After building and training my object detection model, I tested its accuracy and validity by utilizing testing image samples. The evaluated accuracy of the model is 90%. :hash: To validate the trained model, go to the Model testing page and click Classify all.





Step 7: Setting up Beetle ESP32-C3 on the Arduino IDE
Before proceeding with the following steps, I needed to set up Beetle ESP32-C3 on the Arduino IDE and install the required libraries for this project. If your computer cannot recognize Beetle ESP32-C3 when plugged in via a USB cable, connect Pin 9 to GND (pull-down) and try again. :hash: To add the ESP32-C3 board package to the Arduino IDE, navigate to File β‘ Preferences and paste the URL below under Additional Boards Manager URLs. https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package\_esp32\_index.json.png?fit=max&auto=format&n=577XzA-QE9Zpi0WI&q=85&s=0807137f3d2d4f7dbff66c02791d1431)
.png?fit=max&auto=format&n=cTLnQohdrJO-nQ6f&q=85&s=880d841d2c984d0925dce6813451f491)
.png?fit=max&auto=format&n=577XzA-QE9Zpi0WI&q=85&s=f86627550a4afc46e8e03c062732ac4f)



Step 7.1: Programming Beetle ESP32-C3 to get commands from OpenMV Cam H7 and communicate with the web application
Since OpenMV Cam H7 does not provide Wi-Fi or cellular connectivity, I employed Beetle ESP32-C3 to get commands from OpenMV Cam H7 via serial communication and communicate with the web application via HTTP GET requests. Also, Beetle ESP32-C3 determines when the customer concludes shopping and is ready to leave the store if it detects the assigned RFID key tag UID of the grocery cart via the MFRC522 RFID reader. You can download the smart_grocery_cart_app_connection.ino file to try and inspect the code for obtaining commands from OpenMV Cam H7 via serial communication and communicating with the web application. β Include the required libraries.




Step 8: Setting up the Edge Impulse FOMO model on OpenMV Cam H7
After building, training, and deploying my object detection (FOMO) model as an OpenMV firmware on Edge Impulse, I needed to flash OpenMV Cam H7 with the generated firmware to run the model directly so as to create an easy-to-use and capable device operating with minimal latency, memory usage, and power consumption. FOMO object detection models do not output bounding boxes but provide the detected objectβs location using centroids. Therefore, I was able to modify the returned object location variables to draw circles around the detected objects on the ST7735 color TFT screen with the assigned circle color β magenta. Since Edge Impulse optimizes and formats preprocessing, configuration, and learning blocks into BIN files for each OpenMV version while deploying models as OpenMV firmware, I was able to flash OpenMV Cam H7 effortlessly to run inferences. :hash: After downloading the generated OpenMV firmware in the ZIP file format, plug OpenMV Cam H7 into your computer and open the OpenMV IDE. :hash: Then, go to Tools β‘ Run Bootloader (Load Firmware).


- Joystick (Button) β‘ Get the latest registered table name in the database
- Joystick (Up + Button) β‘ Add the detected product to the database table
- Joystick (Down + Button) β‘ Remove the detected product from the database table
- Add Cart
- Remove




Step 9: Running the FOMO model on OpenMV Cam H7 to detect products and communicating with the web application via Beetle ESP32-C3
My Edge Impulse object detection (FOMO) model scans a captured image and predicts possibilities of trained labels to recognize an object on the given captured image. The prediction result (score) represents the modelβs βconfidenceβ that the detected object corresponds to each of the five different labels (classes) [0 - 4], as shown in Step 6:- Barilla
- Milk
- Nutella
- Pringles
- Snickers




- Add Cart
- Remove































Videos and Conclusion
Data collection | IoT AI-driven Smart Grocery Cart w/ Edge Impulse Experimenting with the model | IoT AI-driven Smart Grocery Cart w/ Edge ImpulseFurther Discussions
By applying object detection models trained on numerous food retail product images in detecting products automatically while shopping, we can achieve to: πποΈπ² convert regular grocery carts into AI-assisted smart grocery carts, πποΈπ² make shoppers avoid tedious checkout lines and self-checkout stations, πποΈπ² improve the customer experience, πποΈπ² provide an automated product tracking and payment system, πποΈπ² reduce the total cost of integrating smart grocery carts for small businesses in the food retail industry, πποΈπ² provide an exceptional online shopping experience.
