ESP32 LED PCB Design


A robust beginner-friendly onboard topology for each 24 V high-side channel is:
ESP32 GPIO → optocoupler or NPN level shifter → P-channel MOSFET high-side switch → LED color wire receives +24 V when active
This is simple, through-hole friendly, active-high from GPIO, and much more robust than trying to drive 24 V directly from the NodeMCU or using small signal transistors as the load switch.

First: challenge the assumptions
Before committing, verify these points:
  1. Do the LED “color wires” really need +24 V?
    Many 12/24 V RGB LED strips are common-anode: the common wire is +24 V and the R/G/B wires are switched to ground with low-side N-MOSFETs.
    If that is your LED type, you do not want high-side switching. You want three low-side N-MOSFETs.
  2. If the load wires truly need +24 V when active, then high-side switching is correct.
    That implies the LED/load common return is tied to 0 V/GND.
  3. Do not power the NodeMCU directly from 24 V.
    Use a 24 V-to-5 V buck converter feeding the NodeMCU 5 V/VIN pin, or a proper 3.3 V regulator. Most NodeMCU boards cannot tolerate 24 V on VIN.
  4. The external MT-301R4P-N module must be verified.
    Make sure it actually provides a 24 V sourcing/high-side output. Some opto modules provide sinking/open-collector outputs instead.
  5. If isolation matters, do not accidentally defeat it.
    If the external opto module is meant to isolate the ESP32 from the 24 V side, tying ESP32 GND to 24 V return elsewhere removes that isolation.

Recommended onboard channel circuit
Use this per channel for GPIO25, GPIO26, GPIO27.
Functional block

Text


ESP32 GPIO
   |
   |  logic input resistor
   v
Optocoupler or NPN pull-down stage
   |
   v
P-channel MOSFET gate drive
   |
   v
P-channel MOSFET high-side switch
   |
   v
LED color output receives +24 V when active

Preferred onboard robust version: optocoupled P-MOSFET high-side switch
This keeps the ESP32 side better protected and matches the spirit of the external opto-module fallback.
Per-channel schematic concept

Text


ESP32 side:

GPIO25/26/27 ---- RIN ---->| optocoupler LED ---- ESP32 GND
                    390R to 680R


24 V power side:

Protected +24 V rail
        |
        |
       Source
      QP1 P-channel MOSFET
       Drain -------------------- LED_COLOR_OUT
        |
       load to 0 V/GND externally


P-MOSFET gate network:

+24 V ---- RGS ---- Gate
          47k

Gate ---- DZ ---- +24 V
       12 V zener
       anode at gate,
       cathode at +24 V/source

Gate ---- RG ---- optocoupler transistor collector
       4.7k

optocoupler transistor emitter ---- 24 V return/GND
When the ESP32 GPIO goes high, the optocoupler turns on, pulls the P-MOSFET gate down, the P-MOSFET turns on, and the LED color wire receives +24 V.

Exact suggested values per channel

Table


ItemSuggested value / partNotes
High-side MOSFETFQP27P06, IRF4905, or similar P-channel TO-220 MOSFETUse ≥55/60 V VDS rating. Size current rating to LED load.
Gate pull-up resistor, RGS47 kΩ, 0.25 WKeeps MOSFET off by default.
Gate pull-down series resistor, RG4.7 kΩ, 0.25 WLimits zener/opto current.
Gate-source zener, DZ12 V zener, e.g. BZX55C12 or 1N5242BProtects MOSFET VGS from exceeding max rating.
OptocouplerDIP phototransistor optocoupler, preferably VCEO ≥ 50 VTLP785, VO617A, or similar. Avoid marginal parts if 24 V bus is noisy.
GPIO input resistor, RIN390 Ω to 680 ΩGives roughly 3–5 mA opto LED current from 3.3 V GPIO.
Optional GPIO pulldown100 kΩ from GPIO side input to GNDEnsures off during reset/boot if desired.
Optional output indicatorLED + 10 kΩ, 0.25 W from output to GNDShows channel active.
Optional output bleed100 kΩ from output to GNDPrevents floating output when off.

Why the 12 V zener is important
A P-channel MOSFET source sits at +24 V. If you simply pull its gate to 0 V, then:

Text


VGS = 0 V - 24 V = -24 V
Many MOSFETs have an absolute maximum VGS of only ±20 V. That is not safe.
The 12 V zener clamps the gate so that when on:

Text


VGS ≈ -12 V
That fully enhances most power P-MOSFETs while protecting the gate oxide.

Simpler non-isolated onboard version
If you do not need isolation and the ESP32 ground is already tied to the 24 V return, replace the optocoupler output transistor with a through-hole NPN transistor.
Per-channel non-isolated version

Text


ESP32 GPIO ---- 4.7k ---- base of 2N5551 / PN2222
                         |
                       100k
                         |
                        GND

NPN emitter ---- GND

NPN collector ---- 4.7k ---- P-MOSFET gate

P-MOSFET source ---- protected +24 V
P-MOSFET drain  ---- LED_COLOR_OUT

47k from P-MOSFET gate to source/+24 V

12 V zener from gate to source:
    zener cathode to +24 V/source
    zener anode to gate
Recommended NPN: 2N5551 is nice because it has higher voltage margin than a basic 2N3904. PN2222/2N2222 can work, but their 40 V rating gives less transient margin.

Example channel behavior
Assuming the optocoupled or NPN version:

Table


GPIO stateGate stateP-MOSFETOutput
GPIO low / resetGate pulled to +24 VOffFloating/off
GPIO highGate pulled about 12 V below sourceOnLED color wire gets +24 V
So the channel is active-high, which is intuitive for ESP32 firmware.

Power/input safeguards for the whole board
For a beginner-friendly 24 V board, I would add these before the three high-side channels:
1. Input fuse or resettable PTC
Place near the 24 V input connector.
Example:

Text


24 V_IN ---- fuse/PTC ---- protected +24 V rail
Select based on total LED current.
Examples:
  • 500 mA if the load is small indicators.
  • 1 A to 2 A for moderate LED loads.
  • Higher only if traces, connectors, MOSFETs, and supply are sized accordingly.
2. Reverse-polarity protection
Use either:
  • A series Schottky diode, simple but wastes power, or
  • A P-channel MOSFET reverse-polarity protector, better for higher current.
For a beginner board, a series diode may be acceptable at low current. For LED strips, use MOSFET reverse protection.
3. 24 V transient suppressor
Add a TVS diode across the protected 24 V rail:

Text


protected +24 V ---- TVS ---- GND
Suggested:
  • SMBJ33A or SMBJ36A, depending on expected supply tolerance.
Use a unidirectional TVS for DC supply protection.
4. Bulk capacitance
Near the MOSFETs and output connectors:
  • 100 µF to 470 µF, 35 V or 50 V electrolytic
  • 100 nF ceramic in parallel
Use 50 V caps if the 24 V supply is industrial/noisy.

Output safeguards per channel
For each LED color output:
  1. Per-channel fuse/PTC if wiring leaves the board
    Especially useful for beginner wiring mistakes.
  2. Optional output TVS or clamp for long cables
    If LED wires are long, add ESD/transient protection from output to GND.
  3. Flyback diode only if the load may be inductive
    For LEDs it is not required.
    If someone may connect a relay/solenoid, add a diode from GND to output:

Text


diode anode  ---- GND
diode cathode ---- switched output
  1. Use adequately rated screw terminals
    Do not use tiny headers for amp-level 24 V LED currents.

Jumper fallback arrangement
Do not let the onboard driver and external module fight each other. Use a selector jumper per channel.
Output selection jumper
For each color channel, use a 3-pin jumper:

Text


          [ONBOARD_OUT]
                |
                o
                |
LED_COLOR_OUT --o  center pin
                |
                o
                |
          [EXT_MODULE_OUT]
Jumper position chooses:
  • Center to ONBOARD_OUT: onboard P-MOSFET drives the LED wire.
  • Center to EXT_MODULE_OUT: external MT-301R4P-N module drives the LED wire.
This prevents both drivers from being connected to the same LED wire at once.

GPIO/input selection jumper
Also consider a second selector for each GPIO:

Text


GPIO25 ---- center jumper pin
              |
      -----------------
      |               |
 onboard input     external module input
This lets each GPIO drive either:
  • The onboard opto/NPN gate driver, or
  • The external module input.
If you do not add this, at least place series resistors so the GPIO cannot be back-driven by the external module.

Suggested connector/header layout
For the external MT-301R4P-N fallback, provide a header like:

Text


EXT MODULE HEADER

1  +24 V protected
2  24 V return/GND
3  GPIO25 signal, through 330R/1k
4  GPIO26 signal, through 330R/1k
5  GPIO27 signal, through 330R/1k
6  EXT_OUT_25
7  EXT_OUT_26
8  EXT_OUT_27
Then route EXT_OUT_25/26/27 to the output selection jumpers.
Label polarity and active level clearly on silkscreen.

MOSFET choice notes
For beginner through-hole use, TO-220 P-channel MOSFETs are convenient.
Good examples:
  • FQP27P06: 60 V, through-hole, good general choice.
  • IRF4905: 55 V, very low RDS(on), good for higher currents.
  • IRF9540N: common, but higher RDS(on); okay for smaller loads.
For 24 V systems, I would prefer 60 V or higher VDS. A 30 V MOSFET is too close to the bus voltage.

Recommended per-channel circuit summary
Use this as the onboard channel:

Text


GPIO25/26/27
    |
   390R-680R
    |
opto LED
    |
ESP32 GND


24 V side:

+24V_PROTECTED ---- source of P-MOSFET
P-MOSFET drain ---- ONBOARD_OUT_x

47k from gate to source
12 V zener from gate to source:
    cathode to source/+24 V
    anode to gate

4.7k from gate to optocoupler collector
opto emitter to 24 V return/GND
Then:

Text


ONBOARD_OUT_x ---- jumper option A
EXT_MODULE_OUT_x - jumper option B
LED_COLOR_x ------ jumper center

Final recommendation
For each of GPIO25, GPIO26, and GPIO27, use a P-channel MOSFET high-side switch with a 12 V gate-source zener clamp and an optocoupler or NPN pull-down gate driver. Make the onboard circuit active-high, off by default, and isolate it from the external module with proper selector jumpers.
If you want maximum beginner robustness, I would use:
  • FQP27P06 P-channel MOSFET per channel
  • TLP785 / VO617A-class DIP optocoupler per channel
  • 47 kΩ gate-source pull-up
  • 4.7 kΩ gate pull-down series resistor
  • 12 V zener from gate to source
  • 390 Ω to 680 Ω GPIO-to-opto LED resistor
  • Input fuse/PTC
  • SMBJ33A/SMBJ36A TVS
  • 100–470 µF bulk capacitor
  • 3-pin output selector jumper per channel
  • Optional GPIO/input selector jumper per channel
This gives you a safe, through-hole, understandable, field-tolerant high-side 24 V driver while preserving the external opto-module fallback path.
The initial schematic blocks are in: ESP32 socket, daisy-chain 24 V/I2C terminals, buck-module header, optional I2C pull-ups, external isolator fallback header, and onboard opto/MOSFET high-side driver channels.
I created the project spec and started the schematic for the jumper-fallback ESP32 24 V LED controller. The schematic now includes the ESP32 38-pin socket, 24 V/I2C in/out terminal blocks, buck-module header, optional I2C pull-up jumpers, external MT-301R4P-N fallback header, and three onboard opto + P-channel MOSFET high-side output channels; the latest check returned no open ERC warnings/errors.
Project file: Project Specification
Open items:
  • I’m blocked from making more edits right now because the account has no available ACUs.
  • I still need to update the spec with the final schematic details and cleanly mark my last verification todo complete.
  • We still need your LED current rating and eventual enclosure dimensions before PCB layout.
Optional I2C pull-up jumper explanation: I2C needs SDA/SCL pull-up resistors, but in a daisy chain you usually only want one set enabled. JP7 enables/disables the SDA pull-up and JP8 enables/disables the SCL pull-up; install the shunts on only one board/master location, and remove them on the other slave boards.
Update spec later
Set LED current
Add jumper notes
Check BOM cost

Waiting for input


Last modified 3mo ago

Project Specification: ESP32 24V LED Controller
Project Overview
  • Status: Draft
  • Device: Through-hole-friendly carrier PCB for a 38-pin NodeMCU ESP-32S development board.
  • Purpose: Convert the working prototype into one easier-to-wire PCB for controlling a 24 V industrial LED/light using I2C commands.
Intended Use
  • Installed inside daisy-chained slave boxes.
  • A master controller sends commands over I2C.
  • Each slave box receives 24 V, GND, SDA, and SCL, passes them onward, and controls one 24 V LED with red/yellow/green channels.
  • Prototype/learning build first; later enclosure constraints will guide layout.
What the Device Should Do
  • Accept 24 V DC and GND from an incoming terminal block.
  • Pass 24 V, GND, SDA, and SCL to an outgoing terminal block.
  • Power a plug-in 38-pin NodeMCU ESP-32S board from the 24 V input through a regulator.
  • Connect ESP32 GPIO21 to I2C SDA and GPIO22 to I2C SCL.
  • Use GPIO25, GPIO26, and GPIO27 as red/yellow/green control outputs.
  • Drive 24 V LED color wires where each active color wire receives +24 V.
  • Provide jumper-selectable fallback so each color output can use either an external MT-301R4P-N isolator module or an onboard opto/high-side driver circuit.
Main Features
  • 38-pin ESP32 dev-board socket using through-hole female headers.
  • 24 V/I2C input and output terminal blocks.
  • Through-hole/solder-in 24 V to 5 V buck regulator module footprint.
  • Optional I2C pull-up resistors enabled/disabled by jumpers.
  • Three selectable output paths: external isolator module input or onboard opto driver.
  • LED output terminal block for black/+24 V, red, yellow, and green.
  • Through-hole components preferred wherever practical.
System Architecture

Diagram


Input terminal: node_24V GND SDA SCL Pass-through bus Output terminal: node_24V GND SDA SCL 24V to node_5V buck module 38-pin NodeMCU ESP-32S socket 3x output select jumpers External MT-301R4P-N header Onboard opto/high-side drivers LED terminal: +24V red yellow green
Hardware Subsystems
Power
  • 24 V input powers the system and LED.
  • 24 V is converted to 5 V for the NodeMCU ESP-32S VIN/5V pin.
  • The ESP32 dev board's onboard regulator generates 3.3 V logic power.
  • 3.3 V may also feed the external isolator module's input side.
ESP32 Carrier Socket
  • Board target: NodeMCU ESP-32S v1.1, 38-pin development board.
  • Required connected pins:
    • VIN/5V from regulator output
    • GND
    • GPIO21 SDA
    • GPIO22 SCL
    • GPIO25 red command
    • GPIO26 yellow command
    • GPIO27 green command
    • 3V3 available for I2C pull-ups and external isolator input-side supply if the dev board exposes it
I2C Daisy Chain
  • Incoming SDA/SCL are tied to outgoing SDA/SCL and ESP32 GPIO21/GPIO22.
  • Optional pull-ups to 3.3 V are included but disabled/enabled by jumpers.
  • Only one location on the whole I2C bus should normally enable pull-ups.
LED Output Drivers
  • LED behavior confirmed by user: black/common power wire needs +24 V; each color wire turns on when that color wire also receives +24 V.
  • Therefore outputs must be 24 V high-side/source-style outputs, not low-side ground switches.
  • Rev-1 schematic includes both paths:
    1. External MT-301R4P-N isolator/level-converter module path.
    2. Onboard opto/high-side driver circuit path.
  • A jumper per channel selects which path receives the ESP32 GPIO signal.
Interfaces and Connections

Table


InterfacePins / SignalsNotes
24 V/I2C input terminal24V_IN, GND, SDA, SCLFrom master/upstream box
24 V/I2C output terminal24V_OUT, GND, SDA, SCLTo downstream box
ESP32 socket38-pin NodeMCU ESP-32SThrough-hole female headers
Regulator moduleVIN+, VIN-, VOUT+, VOUT-Solder-in buck module preferred
External isolator header3.3V, GND, IN1-IN4, 24V-side terminals as neededSupports known-working MT-301R4P-N fallback
LED terminal+24V/black, red, yellow, greenColor wires need +24 V when active
Power and Runtime Expectations
  • Input source: nominal 24 V DC.
  • Runtime: continuous when powered.
  • No battery charging or low-power sleep requirement currently specified.
  • ESP32 WiFi/BLE use not currently required; I2C is the command interface.
Power Tree and Power Budget

Diagram


24V input 24V LED power/common and color drivers 24V to node_5V buck module 5V rail NodeMCU VIN/5V NodeMCU onboard 3.3V I2C pull-ups if enabled External/onboard opto input LEDs
Initial sizing assumptions until exact LED and regulator details are known:
  • ESP32 dev board peak current: design regulator for at least 500 mA available at 5 V.
  • Opto input channels: estimate 5–10 mA each when active.
  • LED 24 V current: TBD from LED product; terminal blocks and output drivers must be sized after the LED current is known.
  • Recommended buck module target: 24 V input capable, 5 V output, at least 1 A output for margin.
Manufacturing and Assembly Expectations
  • User prefers through-hole soldering.
  • Use through-hole terminal blocks, headers, jumpers, DIP optocouplers, axial resistors, and radial/disc capacitors where practical.
  • Solder-in buck converter module preferred over a tiny SMD switching regulator for rev 1.
  • PCB layout will wait for enclosure and mechanical constraints.
Firmware-Relevant Hardware Requirements
  • ESP32 I2C pins:
    • GPIO21 = SDA
    • GPIO22 = SCL
  • ESP32 output pins:
    • GPIO25 = red
    • GPIO26 = yellow
    • GPIO27 = green
  • Firmware should allow OFF, red, yellow, green, and mixed/intermediate colors by controlling the three outputs.
  • I2C addressing strategy is TBD.
Physical Design Expectations
  • Board should accept a 38-pin NodeMCU ESP-32S dev board.
  • Terminal blocks should be accessible at board edges.
  • Enclosure dimensions and mounting details are TBD and will be added later.
  • Keep the ESP32 antenna area clear during layout if the dev board antenna remains onboard.
Important Design Decisions
  • Use a plug-in NodeMCU ESP-32S dev board instead of a bare ESP32 module for rev 1.
  • Feed the dev board from 5 V/VIN rather than directly into 3.3 V.
  • Add jumper fallback for output-driver experimentation.
  • Include optional, jumper-enabled I2C pull-ups so pull-up strength can be controlled across the daisy chain.
  • Prefer through-hole assembly for learning/debugging.
Assumptions
  • The NodeMCU ESP-32S board exposes usable VIN/5V, GND, 3V3, GPIO21, GPIO22, GPIO25, GPIO26, and GPIO27 pins on its 38-pin headers.
  • The LED color wires require +24 V to activate.
  • The external isolator module is an MT-301R4P-N family 3.3 V-to-24 V 4-channel optocoupler/PLC converter.
  • The I2C daisy-chain cable length is short enough for I2C to be acceptable for a prototype. If the cable length grows, RS-485 or CAN should be considered.
Change Notes
  • Initial specification created from user requirements.
  • Added jumper fallback architecture for each color output.
  • Added optional I2C pull-up jumper requirement.
  • Project Overview

  • Intended Use

  • What the Device Should Do

  • Main Features

  • System Architecture

  • Hardware Subsystems

  • Power

  • ESP32 Carrier Socket

  • I2C Daisy Chain

  • LED Output Drivers

  • Interfaces and Connections

  • Power and Runtime Expectations

  • Power Tree and Power Budget

  • Manufacturing and Assembly Expectations

  • Firmware-Relevant Hardware Requirements

  • Physical Design Expectations

  • Important Design Decisions

  • Assumptions

  • Change Notes