ESP32 PCB Design Assistance
Table
| Function | ESP32 GPIO | Schematic net | Connected to | Direction | Notes |
|---|---|---|---|---|---|
| Motor 1 TX | GPIO17 | MOTOR1_TX | J1 pin 2 | Output | UART TX from ESP32 to external motor board. |
| Motor 1 RX | GPIO16 | MOTOR1_RX | J1 pin 3 | Input | UART RX into ESP32 from external motor board. |
| Motor 2 TX | GPIO25 | MOTOR2_TX | J2 pin 2 | Output | Second logic serial channel; implemented in software serial in this starter. |
| Motor 2 RX | GPIO26 | MOTOR2_RX | J2 pin 3 | Input | Second logic serial channel; implemented in software serial in this starter. |
| Servo TX | GPIO33 | SERVO_TX | J3 pin 2 | Output | UART TX to external servo driver board. |
| Servo RX | GPIO32 | SERVO_RX | J3 pin 3 | Input | UART RX from external servo driver board. |
| EN | EN | EN | R1/C3 reset delay | Input | Hardware enable/reset circuit. |
| Boot | GPIO0 | BOOT0 | R2 pull-up | Input | Pull low only for bootloader/download mode. |
| IO12 strap | GPIO12 | ESP32_IO12_BOOT_PD | R3 pull-down | Input | Kept low at boot for 3.3 V flash operation. |
Ini
[env:esp32dev] platform = espressif32 board = esp32dev framework = arduino monitor_speed = 115200 lib_deps = plerup/EspSoftwareSerial@^8.2.0
Cpp
#include <Arduino.h> #include <WiFi.h> #include <SoftwareSerial.h> // Schematic pin mapping #define MOTOR1_TX_PIN 17 #define MOTOR1_RX_PIN 16 #define MOTOR2_TX_PIN 25 #define MOTOR2_RX_PIN 26 #define SERVO_TX_PIN 33 #define SERVO_RX_PIN 32 #define DEBUG_BAUD 115200 #define MOTOR_UART_BAUD 115200 #define SERVO_UART_BAUD 115200 // Hardware UARTs on original ESP32 HardwareSerial Motor1Serial(2); // UART2: RX=GPIO16, TX=GPIO17 HardwareSerial ServoSerial(1); // UART1: RX=GPIO32, TX=GPIO33 // Extra software serial channel for Motor 2. For high baud/low jitter, move this to another hardware UART or add a UART expander. SoftwareSerial Motor2Serial(MOTOR2_RX_PIN, MOTOR2_TX_PIN); const char* WIFI_SSID = "YOUR_SSID"; const char* WIFI_PASSWORD = "YOUR_PASSWORD"; void initWiFi() { WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Connecting to WiFi"); for (int i = 0; i < 20 && WiFi.status() != WL_CONNECTED; ++i) { delay(500); Serial.print('.'); } if (WiFi.status() == WL_CONNECTED) { Serial.printf("\nWiFi connected, IP=%s\n", WiFi.localIP().toString().c_str()); } else { Serial.println("\nWiFi not connected; continuing offline."); } } void sendLine(Stream& port, const char* line) { port.print(line); port.print('\n'); } void bridgeIncoming(Stream& from, const char* label) { while (from.available()) { int c = from.read(); Serial.printf("[%s] %c", label, (char)c); } } void setup() { Serial.begin(DEBUG_BAUD); delay(200); Serial.println("ESP32 Power Bus Controller firmware starting"); Motor1Serial.begin(MOTOR_UART_BAUD, SERIAL_8N1, MOTOR1_RX_PIN, MOTOR1_TX_PIN); Motor2Serial.begin(MOTOR_UART_BAUD); ServoSerial.begin(SERVO_UART_BAUD, SERIAL_8N1, SERVO_RX_PIN, SERVO_TX_PIN); initWiFi(); sendLine(Motor1Serial, "PING_MOTOR_1"); sendLine(Motor2Serial, "PING_MOTOR_2"); sendLine(ServoSerial, "PING_SERVO"); } void loop() { static unsigned long lastPingMs = 0; unsigned long now = millis(); bridgeIncoming(Motor1Serial, "M1"); bridgeIncoming(Motor2Serial, "M2"); bridgeIncoming(ServoSerial, "SERVO"); if (now - lastPingMs >= 1000) { lastPingMs = now; sendLine(Motor1Serial, "STATUS?"); sendLine(Motor2Serial, "STATUS?"); sendLine(ServoSerial, "STATUS?"); } if (WiFi.status() != WL_CONNECTED) { // Keep running local serial links; reconnect opportunistically. static unsigned long lastReconnectMs = 0; if (now - lastReconnectMs > 10000) { lastReconnectMs = now; initWiFi(); } } }
Bash
pio run pio run -t upload pio device monitor
Platform & Toolchain
Pin Mapping
platformio.ini
Complete Firmware Source
Build & Flash