ESP32 Smart Conveyor Speed Controller Embedded Systems & Industrial Automation Prototype Documentation Microcontroller: ESP32 Driver: A4988 Display: SSD1306 OLED Language: C++ (Arduino Framework) 1. Executive Summary & Project Overview This technical document details the design, hardware architecture, firmware code, and operational workflow of an ESP32-Based Industrial Conveyor Belt Speed Controller . Designed as a functional prototype, this system provides real-time speed regulation using an analog potentiometer, driving an A4988 stepper motor driver for precise speed scaling ($0\% ightarrow 100\%$). Simultaneously, the system features dynamic telemetry updates on a $128 imes 64$ I2C OLED screen (displaying exact speed percentages and a visual progress bar) and an analog diagnostic LED indicator that dynamically brightens or dims via Hardware PWM (LEDC) Key Feature: Hardware-level timing control via ESP32 PWM allows smooth LED fading and precise motor step- delay calculation without visual stutter on the telemetry screen. 2. System Components & Functional Breakdown Component Pin Assignment Functional Description ESP32 Dev Module MCU Board 32-bit Dual-core processing unit executing loop timing, reading ADC values, updating display over I2C, and firing pulse-bursts. Potentiometer GPIO 34 (ADC1) Functions as a variable voltage divider ($0 ext{V} - 3.3 ext{V}$), providing continuous manual analog input for speed tuning. A4988 Driver & Stepper GPIO 13 (STEP) GPIO 12 (DIR) Translates high-frequency microsecond step pulses into mechanical torque, accelerating the motor from crawl speed to max RPM. SSD1306 OLED Screen GPIO 21 (SDA) GPIO 22 (SCL) $128 imes 64$ I2C display rendering real-time user interface with numerical speed percentage and dynamic visual bar graph. Status Diagnostic LED GPIO 2 (LEDC PWM) Gives instant hardware diagnostic feedback; brightness scales linearly ($0 ightarrow 255$) proportional to motor speed percentage. 3. System Circuit Logic & Operating Procedure Analog Input Sampling: The potentiometer position is sampled by ESP32's 12-bit ADC (GPIO 34), yielding raw digital values between $0$ and $4095$. Value Normalization: The firmware maps raw ADC values directly into a clean $0\% - 100\%$ speed factor. 1. 2. ESP32 Industrial Conveyor Speed Controller Page 1 of 3 Diagnostic LED PWM Fading: Using ESP32's `ledcWrite()` API, the $0\% - 100\%$ speed is translated into an 8-bit duty cycle ($0 - 255$), producing smooth linear brightness fading on the diagnostic LED. Dynamic Stepper Burst Calculation: To ensure high-speed visual responsiveness in simulation and hardware, step pulse counts ($1 ightarrow 40$ pulses/cycle) and step delay intervals ($12,000\mu ext{s} ightarrow 200\mu ext{s}$) scale dynamically. Real-time I2C Telemetry Refresh: The OLED screen updates every loop iteration to render speed numbers and a proportional progress bar fill width ($0 ightarrow 124$ pixels). 4. Complete Firmware Source Code (C++) conveyor_controller.ino #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // Pin Definitions const int POT_PIN = 34; const int STEP_PIN = 13; const int DIR_PIN = 12; const int LED_PIN = 2; // PWM Configuration for ESP32 Core 3.x const int PWM_FREQ = 5000; const int RESOLUTION = 8; void setup() { Serial.begin(115200); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { for(;;); // Loop forever on OLED initialization failure } pinMode(STEP_PIN, OUTPUT); pinMode(DIR_PIN, OUTPUT); digitalWrite(DIR_PIN, HIGH); // Initialize Hardware PWM for Indicator LED ledcAttach(LED_PIN, PWM_FREQ, RESOLUTION); ledcWrite(LED_PIN, 0); // Initial Boot Display display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(15, 25); display.println("CONVEYOR INITIALIZED"); display.display(); delay(1000); } void loop() { int rawValue = analogRead(POT_PIN); int percentage = map(rawValue, 0, 4095, 0, 100); 3. 4. 5. ESP32 Industrial Conveyor Speed Controller Page 2 of 3 // Update LED PWM Brightness (0 - 255) int ledPWM = map(percentage, 0, 100, 0, 255); ledcWrite(LED_PIN, ledPWM); // Refresh OLED Telemetry updateOLED(percentage); // Stepper Pulse Control Logic if (percentage == 0) { digitalWrite(STEP_PIN, LOW); delay(50); } else { int pulsesPerCycle = map(percentage, 1, 100, 1, 40); int stepDelayUs = map(percentage, 1, 100, 12000, 200); for (int i = 0; i < pulsesPerCycle; i++) { digitalWrite(STEP_PIN, HIGH); delayMicroseconds(50); digitalWrite(STEP_PIN, LOW); delayMicroseconds(stepDelayUs); } } } void updateOLED(int percentage) { display.clearDisplay(); // Header Box display.drawRect(0, 0, 128, 16, SSD1306_WHITE); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(12, 4); display.println("CONVEYOR CONTROL"); // Speed Readout display.setTextSize(2); display.setCursor(5, 24); display.print("SPD: "); display.print(percentage); display.print("%"); // Progress Bar int barWidth = (percentage * 124) / 100; display.drawRect(0, 48, 128, 14, SSD1306_WHITE); display.fillRect(2, 50, barWidth, 10, SSD1306_WHITE); display.display(); } 5. Industrial Applications & Real-World Use Cases Automated Smart Factory Lines: Dynamically adjusts conveyor throughput based on real-time operator assembly pace or optical AI inspection camera feedback. Bottling & Packaging Automation: Synchronizes indexing conveyor positioning speeds with liquid filling nozzles and capping mechanisms. Material Dosing & Chemical Processing: Regulates bulk material feeder screws to maintain exact volumetric ingredient dosing rates. • • • ESP32 Industrial Conveyor Speed Controller Page 3 of 3