Skip to content

MatheusFerraro/SmartRetail-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏪 Real-Time Smart Retail Inventory System

A full-stack IoT application that automates retail shelf inventory tracking — from hardware sensor to live web dashboard.

C# .NET Core SQL Server ESP32 Chart.js


An ESP32 microcontroller acts as an edge device, constantly measuring physical product stock via an ultrasonic sensor and transmitting telemetry data over Wi-Fi to a C# ASP.NET Core REST API. The backend persists readings in a SQL Server database and serves them to a live web dashboard that auto-updates in real time.

Watch Demo on YouTube


📸 Project Gallery

Hardware Setup
Hardware on the shelf
Live Web Dashboard
Live web dashboard
Live Monitor
Real-time stock monitor
Wiring Setup
ESP32 wiring diagram

🎯 Architecture & Tech Stack

 ┌──────────────┐   HTTP POST (JSON)    ┌──────────────────┐        ┌──────────────┐
 │   ESP32 +    │ ───────────────────►  │  ASP.NET Core    │ ◄────► │  SQL Server  │
 │  HC-SR04     │      Wi-Fi            │  REST API (C#)   │        │   Database   │
 │  SSD1306     │                       └────────┬─────────┘        └──────────────┘
 │  Buzzer      │                                │  GET /api/inventory
 └──────────────┘                       ┌────────▼─────────────┐
                                        │   Live Dashboard     │
                                        │ (HTML/CSS/JS/Chart)  │
                                        └──────────────────────┘

1. Backend — ASP.NET Core Web API

Component Details
Framework ASP.NET Core with C#
ORM Entity Framework Core — code-first migrations, SQL Server
Endpoints POST /api/inventory — receive telemetry from ESP32
GET /api/inventory/latest — most recent stock reading
GET /api/inventory/history — time-series of last 20 readings

2. Edge Device — ESP32 Firmware (C++)

Component Details
MCU ESP32 — Wi-Fi-enabled microcontroller
Sensor HC-SR04 ultrasonic — measures product distance on shelf
Display SSD1306 OLED — shows stock % and boot status locally
Alert Active buzzer — audible alarm when stock < 10%

3. Frontend — Live Dashboard

Component Details
Stack HTML / CSS / JavaScript / Chart.js
Behavior Auto-polling API to render a real-time stock-level line chart — no manual refresh needed

💼 Software Engineering Highlights

Practice Implementation
Secure Credentials Wi-Fi secrets isolated in a git-ignored secrets.h file — zero sensitive data in version control
Robust Data Mapping Firmware maps raw distance (cm) → stock percentage (%) with constrained bounds, preventing false negatives
Async / DI Backend API uses async/await and Dependency Injection following modern enterprise C# patterns
Full-Stack Integration Bridges low-level C++ memory management on the MCU with high-level C# / SQL Server cloud systems

🚀 Getting Started

1. Clone the repo

git clone https://github.com/MatheusFerraro/SmartRetail-System.git

2. Run the backend

cd Backend/SmartRetailApi
dotnet ef database update      # apply migrations
dotnet run                      # starts API on https://localhost:5001

3. Wire the ESP32

Connect the components to the Wemos D1 Mini ESP32 as shown below:

Component Pin ESP32 GPIO
HC-SR04 Trigger TRIG GPIO 14
HC-SR04 Echo ECHO GPIO 12
HC-SR04 VCC / GND 5V / GND
SSD1306 OLED SDA SDA GPIO 21
SSD1306 OLED SCL SCL GPIO 22
SSD1306 OLED VCC / GND 3.3V / GND
Active Buzzer Signal + GPIO 27
Active Buzzer GND GND

4. Flash the firmware

  1. Open Firmware/SmartRetail.ino in the Arduino IDE
  2. Copy secrets_template.hsecrets.h and fill in your Wi-Fi credentials & server IP
  3. Select your ESP32 board and upload

Developed by Matheus Ferraro — Software Development Student at NBCC
LinkedIn

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors