Smart Autonomous Guided Vehicle (AGV) System Complete Wokwi Hardware Wiring, System Architecture & Final C++ Code Manual 100% WOKWI SIMULATOR COMPATIBLE π Project Description: This technical documentation provides a complete step-by-step guide to building a Smart Industrial Autonomous Guided Vehicle (AGV) system in the Wokwi Simulator . The AGV features RFID station identification, ultrasonic safety obstacle avoidance with alarm feedback (RGB LED & Buzzer), real-time status output on a 16x2 I2C LCD, and precision position movement driven by a Bipolar Stepper Motor with an A4988 driver. 1. Wokwi Exact Components List The following hardware components match the exact library names available in the Wokwi Simulator : ESP32 Board: board-esp32-devkit-c-v4 RFID Module: MFRC522 SPI RFID Reader (Station / RFID Tag Reader) LCD Display: LiquidCrystal I2C Display (16x2 Character LCD) Stepper Motor Driver: A4988 Stepper Motor Driver Stepper Motor: NEMA 17 / Bipolar Stepper Motor (4-wire) Distance Sensor: HC-SR04 Ultrasonic Distance Sensor RGB LED: Common Cathode RGB LED (Red, Green, Blue pins) Piezo Speaker: Piezo Buzzer (Audio Warning Indicator) 2. Complete Circuit Wiring Matrix (Pin Mapping) Connect all hardware modules in Wokwi according to the precise pin mapping table below: Hardware Module Component Pin ESP32 GPIO / Rail Pin Wire Color Signal & Wiring Function MFRC522 RFID (SPI) VCC 3.3V Red 3.3V Logic Power GND GND Black Common Ground RST GPIO 4 Orange Reset Pin SDA (SS) GPIO 5 Yellow SPI Chip Select MOSI GPIO 23 Blue SPI Master-Out-Slave-In MISO GPIO 19 Green SPI Master-In-Slave-Out SCK GPIO 18 Purple SPI Serial Clock LCD 16x2 (I2C) GND GND Black Ground VCC 5V (VIN) Red 5V Power Supply SDA GPIO 21 Blue I2C Data Line SCL GPIO 22 Yellow I2C Clock Line HC-SR04 Ultrasonic VCC 5V (VIN) Red 5V Power Supply GND GND Black Ground TRIG GPIO 13 Orange Trigger Output Pulse ECHO GPIO 12 Green Echo Input Duration Pulse A4988 & Stepper Motor VDD / GND (Logic) 3.3V / GND Red / Black Driver Logic Power VMOT / GND (Motor) 5V (VIN) / GND Red / Black Motor Power Rail STEP GPIO 14 Blue Step Clock Signal DIR GPIO 27 Yellow Direction Control Pin SLEEP connected to RESET Green Enable Driver Logic Output β’ β’ β’ β’ β’ β’ β’ β’ Smart Industrial AGV System β Wokwi Guide & Technical Reference Page 1 of 4 Hardware Module Component Pin ESP32 GPIO / Rail Pin Wire Color Signal & Wiring Function MS1, MS2, MS3, SLEEP, RESET 1A, 1B, 2A, 2B Stepper Motor Wires (A+, A-, B+, B-) Blue / Red Bipolar Motor Coils Connection RGB LED & Buzzer RGB Red Pin GPIO 25 Red Emergency Stop / Red Light RGB Green Pin GPIO 26 Green Normal Running / Green Light RGB Blue Pin / GND GND (Common Cathode) Black Ground Connection Piezo Buzzer (+) / (-) GPIO 33 / GND Purple / Black Audio Alarm Tone Output 3. Step-by-Step Circuit Assembly Procedure Power Rails Setup: Connect the ESP32's 3.3V and 5V (VIN) pins to the Wokwi breadboard power rails. Connect ESP32 GND to the common ground rail. I2C LCD 16x2 Connection: Wire SDA to GPIO 21 and SCL to GPIO 22 . Supply 5V to VCC and connect GND. MFRC522 RFID SPI Connection: Wire RST to GPIO 4 , SDA to GPIO 5 , SCK to GPIO 18 , MISO to GPIO 19 , and MOSI to GPIO 23 . Power with 3.3V logic. HC-SR04 Ultrasonic Sensor: Connect TRIG to GPIO 13 and ECHO to GPIO 12 . Supply 5V to VCC. A4988 Driver & Stepper Motor Wiring: Connect STEP to GPIO 14 and DIR to GPIO 27 . Connect SLEEP directly to RESET pin on the A4988 driver module. Wire motor coils 1A, 1B, 2A, 2B to the 4 pins of the Bipolar Stepper Motor. RGB LED & Buzzer Setup: Wire the Red pin of the RGB LED to GPIO 25 , Green pin to GPIO 26 , and Common Cathode to GND. Connect Piezo Buzzer positive pin to GPIO 33 4. Complete Final Firmware Code (ESP32 C++ in Wokwi) Paste this exact code into the sketch.ino tab in Wokwi Simulator: #include <SPI.h> #include <MFRC522.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> // Pin Definitions #define SS_PIN 5 #define RST_PIN 4 #define TRIG_PIN 13 #define ECHO_PIN 12 #define STEP_PIN 14 #define DIR_PIN 27 #define RGB_RED 25 #define RGB_GREEN 26 #define BUZZER_PIN 33 // Instance Creations MFRC522 rfid(SS_PIN, RST_PIN); LiquidCrystal_I2C lcd(0x27, 16, 2); void setup() { Serial.begin(115200); SPI.begin(); rfid.PCD_Init(); lcd.init(); lcd.backlight(); pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); pinMode(STEP_PIN, OUTPUT); pinMode(DIR_PIN, OUTPUT); pinMode(RGB_RED, OUTPUT); pinMode(RGB_GREEN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT); digitalWrite(DIR_PIN, HIGH); // Forward direction 1. 2. 3. 4. 5. 6. Smart Industrial AGV System β Wokwi Guide & Technical Reference Page 2 of 4 // Boot Screen lcd.setCursor(0, 0); lcd.print("SMART AGV SYSTEM"); lcd.setCursor(0, 1); lcd.print("INITIALIZING..."); delay(2000); lcd.clear(); } long readDistanceCM() { digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); long duration = pulseIn(ECHO_PIN, HIGH, 30000); if (duration == 0) return 999; // No pulse / out of range return duration * 0.034 / 2; } void loop() { long distance = readDistanceCM(); // 1. OBSTACLE AVOIDANCE & EMERGENCY STOP (E-STOP) if (distance > 0 && distance < 20) { // Red Light & Buzzer Warning digitalWrite(RGB_RED, HIGH); digitalWrite(RGB_GREEN, LOW); tone(BUZZER_PIN, 1000); lcd.setCursor(0, 0); lcd.print("E-STOP: OBSTACLE"); lcd.setCursor(0, 1); lcd.print("DIST: "); lcd.print(distance); lcd.print(" cm "); delay(100); return; // Stop stepper motor execution } else { noTone(BUZZER_PIN); digitalWrite(RGB_RED, LOW); digitalWrite(RGB_GREEN, HIGH); // Safe condition } // 2. STATION DETECTION VIA RFID SCAN if (rfid.PICC_IsNewCardPresent() && rfid.PICC_ReadCardSerial()) { tone(BUZZER_PIN, 2000, 150); // Station beep lcd.setCursor(0, 0); lcd.print("STATION DETECTED"); lcd.setCursor(0, 1); lcd.print("UNLOADING CARGO "); // Stop and pause for 4 seconds at station for (int i = 0; i < 40; i++) { digitalWrite(RGB_GREEN, !digitalRead(RGB_GREEN)); delay(100); } digitalWrite(RGB_GREEN, HIGH); rfid.PICC_HaltA(); rfid.PCD_StopCrypto1(); lcd.clear(); } // 3. NORMAL PATH NAVIGATION & STEPPER MOTION lcd.setCursor(0, 0); lcd.print("STATUS: RUNNING "); lcd.setCursor(0, 1); lcd.print("PATH CLEAR "); digitalWrite(STEP_PIN, HIGH); delayMicroseconds(1000); digitalWrite(STEP_PIN, LOW); delayMicroseconds(1000); } Smart Industrial AGV System β Wokwi Guide & Technical Reference Page 3 of 4 5. Real-World Practical Applications π Industrial & Commercial Use-Cases: Smart Warehouses (Amazon-style Logistics): Autonomous material transport following floor RFID markers between storage racks and shipping docks. Automotive & Electronics Manufacturing: Automated component delivery to robotic assembly lines with instant ultrasonic collision protection. Pharmaceuticals & Cleanrooms: Hands-free transit of sensitive chemical compounds and sterile medicines without human contamination. β’ β’ β’ Smart Industrial AGV System β Wokwi Guide & Technical Reference Page 4 of 4