Skip to main content

3. Electronic Design

3.1. PCB Design V1

I had design a PCB at week06 assignment. But I find some problems with the design.

3.1.1 Problems

Key Pin Conflicts & Lessons Learned

  1. GPIO2: Strapping Pin Conflict (Button)
  • Issue: The button connected to GPIO2 failed to respond or caused boot failures.

  • Reason: GPIO2 is a strapping pin that controls the ESP32 boot mode. It must be LOW during power-up to boot from Flash. If a button circuit pulls this pin HIGH at startup, the system may fail to enter the correct operating mode.

  • Lesson: Avoid using strapping pins (GPIO 0, 2, 5, 12, 15) for critical input components like buttons.

  1. GPIO18/19: Missing ADC Support (Potentiometer)
  • Issue: The rotary potentiometer failed to provide data when connected to GPIO18 or GPIO19.

  • Reason: These pins are digital-only and do not support ADC (Analog-to-Digital Conversion). Potentiometers require ADC pins to read varying voltage levels.

  • Lesson: Always verify the ESP32 Pinout to ensure analog sensors are connected to ADC-capable pins (preferably ADC1 to avoid conflicts with Wi-Fi).

3.2. PCB Design V2

3.2.1 Optimized Pin Assignments for ESP32

I would like to Optimized Pin Assignments for ESP32 in PCB Design V2. As my final project requires a wireless controller, I would like to add more button ,and pin header in PCB Design V2.

I search from google gemini ,and get some useful optimized suggestions.

To avoid boot conflicts (Strapping Pins) and ensure compatibility with Wi-Fi and analog sensors, use the following layout:

    1. 6 Digital Buttons (Input) Recommended Pins: GPIO 13, 14, 25, 32, 33 (and GPIO 23 if 27 is used for LED).

Reason: These are non-strapping pins. Using them ensures the ESP32 boots into Flash mode correctly every time, regardless of whether a button is pressed during startup.

    1. 2 Analog Inputs (Potentiometers) Recommended Pins: GPIO 34, 35

Reason: These belong to ADC1, which remains functional even when Wi-Fi is active (unlike ADC2). Note: These pins are Input-Only and lack internal pull-up/down resistors, making them ideal for voltage-divided analog signals like potentiometers.

    1. 2 Digital I/O (Retained from V1) Pins: GPIO 18, 19

Reason: Standard digital pins. They are reliable for general I/O and can also serve as the SPI interface (SCK/MISO) if needed later.

    1. 2 Onboard LEDs (Fixing GPIO 26 Issue) LED 1: GPIO 4 (Moving from 27 to free it up for buttons).

LED 2: GPIO 5 (Replacing the problematic 26).

3.2.2 Optimized Pin Assignments for ESP32

Here is ESP32 PCB V2 optimized pin assignment plan:

Function CategoryQuantityRecommended GPIODescription / Notes
Digital Buttons613, 14, 12, 27, 25, 23Avoids GPIO 0/2 to ensure smooth boot-up without strapping conflicts.
Analog Input (ADC)234, 35Dedicated to potentiometers. Use ADC1 (won't conflict with Wi-Fi).
General Digital I/O218, 19Retained from V1. Supports PWM, Digital Input, and Output.
Onboard LEDs24, 5Replaces the problematic GPIO 26 to ensure reliable lighting.
I2C (OLED Display)221 (SDA), 22 (SCL)Standard I2C pins for maximum library compatibility.

3.3. PCB Design V2 Design

3.3.1 Update Schematic

I open my V1 PCB design in JLCEDA, and update it.

I update the schematic ,add 4button , two 3pin headers, and one 4pin header.

I

After I finished the Schematic, I select auto update to PCB design.

3.3.2 Update PCB Design

I move the button, pin header to the right side.

I select auto routing ,and make some adjustments.

I meet some connection error. I adjust the connection and make some adjustments.

I finished the PCB design.

I have performed copper pouring on both the top layer and the bottom layer.

I

3.3.3 3D View

Finaly,I can review the PCB 3D view.

3.4 PCB V2 Testing

  • I submitted the PCB to JLC online.

  • After few days ,I receive the PCB from JLC PCB.

I

  • I soldered the PCB.

I

  • Here is the video of testing.