Skip to content

Kamilr616/SmartBotAPI

Repository files navigation

SmartBotAPI

.NET 8 Blazor ESP32-C3 CI License: GPL v3

πŸ‡΅πŸ‡± Polish version

πŸ—“οΈ Project period: 2024–2025

πŸŽ₯ Live demo: for the project presentation the system was deployed to Azure App Service and fully working β€” an authenticated dashboard with live depth-map streaming from the robot (it is no longer hosted). See it running with the physical robot in the demo video.

SmartBotAPI is a full-stack robotics platform that connects an ESP32-C3–based mobile robot to a real-time web dashboard. The robot streams live telemetry β€” an 8Γ—8 time-of-flight depth map, 6-axis IMU data, and temperature β€” over a secure WebSocket/SignalR channel, while operators drive it remotely with an on-screen joystick or keyboard. Measurements are persisted to SQL Server and visualized as live heatmaps, interpolated depth matrices, and historical charts.


Table of Contents


System Overview

flowchart LR
    subgraph Robot["πŸ€– SmartBot (ESP32-C3)"]
        SENS["VL53L5CX 8Γ—8 ToF<br/>MPU6050 IMU"] -->|"I2C"| MCU["ESP32-C3"]
        MCU -->|"PWM"| MOT["TB6612FNG<br/>motors"]
    end

    subgraph Server["☁️ ASP.NET Core 8"]
        HUB["SignalR Hub<br/>/signalhub"]
        HUB --> VIEW["Heatmap + 32Γ—32 matrix"]
        HUB --> DATA["Telemetry service"] --> DB[("SQL Server")]
    end

    UI["πŸ–₯️ Authenticated Blazor dashboard<br/>control β€’ depth β€’ history"]
    MCU <-->|"WSS / SignalR"| HUB
    HUB <-->|"live data + control"| UI
Loading

Data flow in one sentence: the robot samples its sensors at 15 Hz, pushes ReceiveRobotData invocations to the hub, which stores the measurements, renders the raw 8Γ—8 depth frame into a heatmap and a 32Γ—32 interpolated matrix, and broadcasts everything to connected dashboards β€” while movement commands travel the opposite way as ReceiveRobotCommand with PWM values for both motors.

Screenshots

Robot telemetry and image control panel Live 32Γ—32 ToF depth matrix and robot control panel

SmartBotAPI login page Robot telemetry measurement charts

The depth visualizations in both live-view screenshots are based on a ToF frame captured during a real system test; Live View Matrix presents the frame in the application's 32Γ—32 grid. During operation, both views are updated with live SignalR data from the robot.

The physical tracked robot used during development and corridor driving tests:

SmartBot during a corridor driving test SmartBot electronics and tracked chassis

Custom robot PCB

The robot uses a custom carrier PCB for the controller, motor-driver module, sensor connectors, power switch, and battery connection. A PDF export of the KiCad circuit schematic is available as docs/schemat.pdf.

Custom SmartBot carrier PCB installed on the tracked chassis SmartBot carrier PCB circuit schematic

πŸŽ₯ Demo

A short local driving-test montage and a recorded live presentation of the complete system (Department of Computer Science, Akademia Tarnowska):

Music: β€œNew Direction” β€” Kevin MacLeod, CC BY 4.0. See THIRD_PARTY_NOTICES.md for source and modification details.

Features

  • Real-time remote control β€” virtual joystick (pointer events) and keyboard (arrow keys) input, mapped to dual-motor PWM commands in the -255…+255 range, with dual speedometer gauges for feedback.
  • Live depth vision β€” the 8Γ—8 VL53L5CX depth frame is rendered server-side into a color heatmap (PNG, base64) and a bilinearly interpolated 32Γ—32 grid, streamed to the browser as it arrives.
  • Telemetry dashboard β€” historical line charts (temperature, average distance, 3-axis acceleration, 3-axis rotation) with a date-range picker, backed by SQL Server.
  • Safety built into firmware β€” automatic motor stop after 700 ms without a command, minimum-distance guard (400 mm), and automatic WebSocket reconnection every 5 s.
  • Multi-network firmware β€” the robot tries up to three configured Wi-Fi networks and supports TLS/WSS when connecting to the server address configured in config.h.
  • Authenticated control plane β€” dashboard pages and browser hub connections require ASP.NET Core Identity; the robot authenticates to the same hub with a separate API key.
  • Cloud-ready β€” a Dockerfile and .NET container metadata (kamilr616/smartbotblazorapp), plus a GitHub Actions pipeline that builds, tests, and publishes a deployable artifact.

One-joystick differential drive

One proportional joystick combines throttle and steering, allowing straight driving, smooth arcs, and rotation around the robot's own axis. Arrow keys provide an alternative control method, while two speedometer gauges show the motor PWM commands. See the motion-control documentation for the mixing equations, dead zones, timing, key mapping, and safety behavior.

Tech Stack

Layer Technology
Web framework ASP.NET Core 8.0, Blazor (Interactive Server + WebAssembly hybrid)
UI components MudBlazor 7, Bootstrap 5
Real-time transport SignalR (JSON protocol) over WebSocket/TLS
Data Entity Framework Core 9, SQL Server (LocalDB in development)
Image processing SixLabors.ImageSharp (heatmap rendering, bilinear interpolation)
Identity ASP.NET Core Identity
Firmware Arduino framework on ESP32-C3 (Arduino IDE 2.x)
Firmware libraries ArduinoJson, SparkFun VL53L5CX, Adafruit MPU6050, WebSockets (Markus Sattler)
Hardware ESP32-C3 DevKitM-1, VL53L5CX ToF sensor, MPU6050 IMU, TB6612FNG motor driver, NeoPixel status LED
DevOps Docker, GitHub Actions, Azure App Service (presentation deployment)

Repository Structure

SmartBotAPI/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ server/
β”‚   β”‚   β”œβ”€β”€ SmartBotBlazorApp/          # ASP.NET Core host: SignalR hub, EF Core, Identity, server pages
β”‚   β”‚   β”‚   β”œβ”€β”€ Hubs/SignalHub.cs       # Real-time hub (/signalhub)
β”‚   β”‚   β”‚   β”œβ”€β”€ ImageProcessor.cs       # Heatmap generation & matrix interpolation
β”‚   β”‚   β”‚   β”œβ”€β”€ Data/                   # DbContext, Measurement entity, MeasurementService, migrations
β”‚   β”‚   β”‚   └── Components/Pages/       # Heatmap, matrix, charts, weather pages
β”‚   β”‚   └── SmartBotBlazorApp.Client/   # Blazor WebAssembly client
β”‚   β”‚       └── Pages/Chat.razor        # SignalR text diagnostics page
β”‚   └── arduino/
β”‚       └── sketch_robot_signalr/       # ESP32-C3 firmware (main sketch + config.h)
β”œβ”€β”€ docs/                               # Project documentation, schematic, and hardware references
β”œβ”€β”€ other/                              # Media and archived project material
β”‚   β”œβ”€β”€ media/                          # README screenshots, photos, and demo video
β”‚   └── ...                             # Legacy sketches, PlatformIO project, Azure templates
β”œβ”€β”€ LICENSE                             # GNU GPL v3.0
β”œβ”€β”€ SECURITY.md                         # Vulnerability reporting policy
└── THIRD_PARTY_NOTICES.md              # Separately licensed third-party material

Quick Start

Web Server

Prerequisites: .NET SDK 10.0 (the application targets .NET 8), SQL Server LocalDB on Windows (installed with Visual Studio) or any reachable SQL Server instance.

cd src/server/SmartBotBlazorApp
$env:RobotApiKey = "replace-with-a-url-safe-random-key-of-at-least-32-characters"
dotnet restore
dotnet run --launch-profile https

The app applies EF Core migrations automatically on startup and listens on:

  • https://localhost:7297
  • http://localhost:5221

The https launch profile uses the Development environment, where account registration and the local self-confirmation link are enabled. Create a dashboard account at https://localhost:7297/Account/Register, then sign in. Both options are disabled by default outside Development; configure AccountAccess explicitly and use a real email sender for a public deployment.

To run the automated tests from the repository root:

dotnet test src/server/SmartBotBlazorApp.sln

To use a different database, set the SmartBotDBConnectionString environment variable β€” it takes precedence over ConnectionStrings:DefaultConnection in appsettings.json.

Docker:

docker build -t smartbotblazorapp -f src/server/SmartBotBlazorApp/Dockerfile .
docker run -p 8080:8080 \
  -e SmartBotDBConnectionString="<your-connection-string>" \
  -e RobotApiKey="<same-long-random-key-as-the-firmware>" \
  smartbotblazorapp

The container serves plain HTTP on port 8080 unless you explicitly mount and configure an HTTPS certificate. Registration remains disabled in the default production configuration.

Robot Firmware

Prerequisites: Arduino IDE 2.x with the ESP32 board package; an ESP32-C3 DevKitM-1 wired per the schematic in docs/schemat.pdf.

  1. Copy arduino_secrets.example.h to arduino_secrets.h and set the robot API key plus Wi-Fi credentials:

    #define SECRET_API_KEY "same-url-safe-random-key-as-the-server"
    
    #define SECRET_SSID  "your-wifi"
    #define SECRET_PASS  "your-password"
    #define SECRET_SSID2 "fallback-wifi"
    #define SECRET_PASS2 "fallback-password"
    #define SECRET_SSID3 "third-wifi"
    #define SECRET_PASS3 "third-password"
  2. Point the firmware at your server in config.h (SERVER_IP, SERVER_PORT).

  3. Install the libraries listed in Tech Stack via the Library Manager, select the ESP32-C3 DevKitM-1 board, set Tools β†’ Partition Scheme β†’ Huge APP (3MB No OTA/1MB SPIFFS), and upload sketch_robot_signalr.ino.

Once connected, the robot appears on the Live View Image page of the authenticated dashboard and starts streaming telemetry.

Documentation

Document Contents
Architecture & Communication System design, SignalR message contracts, data flow
Getting Started Detailed setup for server, database, and firmware
Server Application Pages, services, hub API, data model, configuration reference
Firmware & Hardware Pinout, sensor configuration, control loop, safety behavior

The firmware and hardware reference links to the manufacturers' current datasheets. The project circuit schematic is stored in docs/.

Deployment

Pushing to main or opening a pull request against it triggers the GitHub Actions workflow (.github/workflows/smartbotweb.yml), which performs a locked restore, verifies formatting, audits NuGet packages, builds and tests with coverage, builds the container image, and publishes a deployable web-app artifact. It does not deploy to an external environment automatically.

For the project presentation, the application was deployed to the smartbotweb Azure App Service and the firmware targeted smartbotweb.azurewebsites.net:443. That service is no longer hosted; the current firmware configuration uses an explicit placeholder that must be replaced with the address of the current server before use.

Contributing & Security

Issues and pull requests are welcome. To report a security vulnerability, please follow the process described in SECURITY.md instead of opening a public issue.

License

This project is licensed under the GNU General Public License v3.0 β€” Β© 2024 Kamil Rataj. Separately licensed third-party material is listed in THIRD_PARTY_NOTICES.md.

πŸ‘₯ Authors

About

Full-stack platform for real-time ESP32-C3 robot control, telemetry and ToF depth streaming with ASP.NET Core, Blazor and SignalR

Topics

Resources

License

Security policy

Stars

3 stars

Watchers

2 watching

Forks

Contributors