ESP32 C3 Robotics Controller
Resize the hexagonal outline to the smallest practical compact size
Place all components for single-layer CNC routing
Verify board fit, antenna keepout, and placement DRC
5V_LOGIC; do not connect external 5 V and USB power simultaneously unless the exact purchased board revision is independently verified to include safe power-path isolation.platformio.ini:Ini
[env:esp32-c3-supermini] platform = espressif32 board = esp32-c3-devkitm-1 framework = arduino monitor_speed = 115200 board_build.flash_size = 4MB build_flags = -D ARDUINO_USB_MODE=1 -D ARDUINO_USB_CDC_ON_BOOT=1
Table
| Signal | GPIO |
|---|---|
| AIN1 | 0 |
| AIN2 | 1 |
| PWMA | 3 |
| BIN1 | 4 |
| BIN2 | 5 |
| PWMB | 6 |
| STBY command | 7 |
Cpp
#include <Arduino.h> #include <WiFi.h> #include <NimBLEDevice.h> static constexpr uint8_t AIN1=0, AIN2=1, PWMA=3; static constexpr uint8_t BIN1=4, BIN2=5, PWMB=6, STBY=7; static constexpr uint32_t FAILSAFE_MS=500; static uint32_t lastCommandMs = 0; static bool armed = false; void motorStop() { ledcWrite(PWMA, 0); ledcWrite(PWMB, 0); digitalWrite(AIN1, LOW); digitalWrite(AIN2, LOW); digitalWrite(BIN1, LOW); digitalWrite(BIN2, LOW); digitalWrite(STBY, LOW); armed = false; } void motorSet(uint8_t in1, uint8_t in2, uint8_t pwmPin, int speed) { speed = constrain(speed, -255, 255); digitalWrite(in1, speed > 0); digitalWrite(in2, speed < 0); ledcWrite(pwmPin, abs(speed)); } void applyCommand(int left, int right) { if (!armed) { digitalWrite(STBY, HIGH); // reaches driver only while hardware RUN/ENABLE is closed armed = true; } motorSet(AIN1, AIN2, PWMA, left); motorSet(BIN1, BIN2, PWMB, right); lastCommandMs = millis(); } void setup() { pinMode(STBY, OUTPUT); digitalWrite(STBY, LOW); // first safety action pinMode(AIN1, OUTPUT); pinMode(AIN2, OUTPUT); pinMode(BIN1, OUTPUT); pinMode(BIN2, OUTPUT); ledcAttach(PWMA, 20000, 8); ledcAttach(PWMB, 20000, 8); motorStop(); Serial.begin(115200); WiFi.mode(WIFI_STA); // Wi-Fi may be connected/configured by application NimBLEDevice::init("ESP32-C3-Robot"); // controller supports Wi-Fi/BLE coexistence lastCommandMs = millis(); } void loop() { // Network/BLE handlers must call applyCommand(left,right) for each valid packet. // Any disconnect handler should call motorStop() immediately. if (armed && (millis() - lastCommandMs > FAILSAFE_MS)) motorStop(); delay(2); }
ledcAttach()/ledcWrite(pin,duty) match current Arduino-ESP32 3.x. For older 2.x cores, replace with channel-based ledcSetup, ledcAttachPin, and ledcWrite(channel,duty).Toolchain
GPIO Mapping
Compilable Arduino Starter
Safety/Startup Sequence