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:
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.
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.
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.
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.
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
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
Item
Suggested value / part
Notes
High-side MOSFET
FQP27P06, IRF4905, or similar P-channel TO-220 MOSFET
Use ≥55/60 V VDS rating. Size current rating to LED load.
Gate pull-up resistor, RGS
47 kΩ, 0.25 W
Keeps MOSFET off by default.
Gate pull-down series resistor, RG
4.7 kΩ, 0.25 W
Limits zener/opto current.
Gate-source zener, DZ
12 V zener, e.g. BZX55C12 or 1N5242B
Protects MOSFET VGS from exceeding max rating.
Optocoupler
DIP phototransistor optocoupler, preferably VCEO ≥ 50 V
TLP785, VO617A, or similar. Avoid marginal parts if 24 V bus is noisy.
GPIO input resistor, RIN
390 Ω to 680 Ω
Gives roughly 3–5 mA opto LED current from 3.3 V GPIO.
Optional GPIO pulldown
100 kΩ from GPIO side input to GND
Ensures off during reset/boot if desired.
Optional output indicator
LED + 10 kΩ, 0.25 W from output to GND
Shows channel active.
Optional output bleed
100 kΩ from output to GND
Prevents 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 state
Gate state
P-MOSFET
Output
GPIO low / reset
Gate pulled to +24 V
Off
Floating/off
GPIO high
Gate pulled about 12 V below source
On
LED 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:
Per-channel fuse/PTC if wiring leaves the board
Especially useful for beginner wiring mistakes.
Optional output TVS or clamp for long cables
If LED wires are long, add ESD/transient protection from output to GND.
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:
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.
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.
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.
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.
A jumper per channel selects which path receives the ESP32 GPIO signal.
Interfaces and Connections
Table
Interface
Pins / Signals
Notes
24 V/I2C input terminal
24V_IN, GND, SDA, SCL
From master/upstream box
24 V/I2C output terminal
24V_OUT, GND, SDA, SCL
To downstream box
ESP32 socket
38-pin NodeMCU ESP-32S
Through-hole female headers
Regulator module
VIN+, VIN-, VOUT+, VOUT-
Solder-in buck module preferred
External isolator header
3.3V, GND, IN1-IN4, 24V-side terminals as needed
Supports known-working MT-301R4P-N fallback
LED terminal
+24V/black, red, yellow, green
Color 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
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.