Skip to content

ShravanaHS/ESP32ControlStudio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🤖 ESP32 Control Studio

Logo

A real-time, ultra-low latency robotics controller — built with Flutter & ESP32 over UDP.

Arduino GitHub ESP32 Flutter Protocol Platform


This is the official Arduino C++ library for ESP32 Control Studio, a high-performance Flutter app used to seamlessly control DIY hardware and robotics.

It completely abstracts away all WiFi UDP sockets, bit-shifting, checksum parsing, and connection timeouts into a single clean class.

Installation

You can install this directly via the Arduino IDE Library Manager:

  1. Open Arduino IDE.
  2. Go to Sketch -> Include Library -> Manage Libraries....
  3. Search for ESP32ControlStudio.
  4. Click Install.

Examples Included

The library comes with built-in examples that demonstrate usage in real scenarios. Check out File -> Examples -> ESP32ControlStudio:

  1. BasicControl
  2. MotorControl

Compatibility

  • Works on ESP32 and ESP8266 cores.

🤔 What is this?

ESP32 Control Studio is a mobile app + Arduino library combo that lets you control your ESP32-based robot or drone from your phone — in real time.

Think of it like a PS4 controller, but running over your home WiFi, with:

  • Two analog joysticks (smooth 0–255 range)
  • 8 action buttons (A, B, X, Y + extras)
  • 4 toggle switches (for modes, lights, etc.)
  • Live sensor data back to your phone (battery, telemetry)

⚡ Why UDP?

Most beginner projects use Bluetooth or HTTP. Here's why those fall short for robotics:

Method Latency Problem
Bluetooth Classic 30–100ms Unstable, drops packets
HTTP (REST) 50–200ms Too slow, request/response overhead
WebSockets (TCP) 15–40ms Head-of-line blocking
UDP (this project) < 15ms ✅ Fast, fire-and-forget

UDP doesn't wait for acknowledgment — it just sends. For a robot, a dropped frame is better than a delayed one.


🏛 How it Works

Flutter App  ──── 8-byte UDP packet ────▶  WiFi Router  ──▶  ESP32
   (Phone)         Port 4210                                  (Robot)

ESP32        ──── Telemetry packet ──────▶  WiFi Router  ──▶  Flutter App
   (Robot)         Port 4211                                  (Phone)
  1. Your phone and ESP32 connect to the same WiFi network
  2. The app sends an 8-byte control packet 50 times per second
  3. The ESP32 receives it, drives motors/servos, and sends sensor data back
  4. The app displays live telemetry on screen

📡 Packet Format

Every control packet is exactly 8 bytes. No wasted space, no parsing complexity.

Byte Field What it does Range
0 Header Sync byte — always 0xAA Fixed
1 Joy1 X Left stick horizontal 0–255
2 Joy1 Y Left stick vertical 0–255
3 Joy2 X Right stick horizontal 0–255
4 Joy2 Y Right stick vertical 0–255
5 Buttons A/B/X/Y packed in 4 bits 0–15
6 Toggles T1/T2/T3/T4 packed in 4 bits 0–15
7 Checksum XOR of bytes 0–6 (error check) 0–255

Checksum formula:

checksum = Byte0 ^ Byte1 ^ Byte2 ^ Byte3 ^ Byte4 ^ Byte5 ^ Byte6

If the ESP32 calculates a different checksum, the packet is discarded — protecting against corrupted data.


⚙️ Firmware Setup

1. Install the Library

Download and add ESP32ControlStudio to your Arduino libraries folder.

2. Upload this sketch

#include <ESP32ControlStudio.h>

ESP32ControlStudio controlApp;

void setup() {
  Serial.begin(115200);
  controlApp.begin("YOUR_WIFI_SSID", "YOUR_WIFI_PASSWORD");
  // Listens on UDP port 8888 automatically

  pinMode(2, OUTPUT); // Onboard LED
}

void loop() {
  controlApp.update(); // Must be called every loop — processes incoming packets

  if (controlApp.isConnected()) {

    // Toggle 1 controls the onboard LED
    digitalWrite(2, controlApp.sw1 ? HIGH : LOW);

    // Map left joystick Y to motor throttle (-255 to +255)
    int throttle = map(controlApp.leftY, 0, 255, -255, 255);

    // Add your motor/servo code here...
  }
}

Available Variables

Variable Description
controlApp.leftX / leftY Left joystick axes (0–255)
controlApp.rightX / rightY Right joystick axes (0–255)
controlApp.btnA / btnB / btnX / btnY Button states (true/false)
controlApp.sw1 / sw2 / sw3 / sw4 Toggle switch states (true/false)
controlApp.isConnected() Returns true when app is connected

📱 App Setup

     

Steps:

  1. Connect to WiFi — Make sure your phone and ESP32 are on the same network
  2. Find the IP — Open the Serial Monitor in Arduino IDE; it will print something like ESP32 IP: 192.168.1.50
  3. Open the App — Enter that IP address and tap Connect
  4. Start controlling!
    • Left joystick → Throttle / Yaw
    • Right joystick → Pitch / Roll
    • Buttons → Custom actions
    • Toggles → Persistent mode switches

🛠 Development Journey

The project started with a simple frustration: Bluetooth-based phone controllers lag too much for fast robots.

  • Alpha — Proof of concept with raw Python scripts talking to ESP32 via UDP
  • Beta — Rebuilt the app in Flutter using the Provider pattern for 60fps UI with no jank
  • Release — Finalized the 8-byte protocol with XOR checksum for reliable communication

The biggest insight: for real-time control, losing a packet is fine — but waiting for one is not. UDP was the obvious choice.


📥 Download

Version Link
Standard Build ⬇ Download APK
Spider-Man Special Edition ⬇ Download Special Edition

For Detailed Documentation Click Here

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages