JAlcocerTech E-books

Chapter 14 — From Breadboard to Board: Power Stages, PCBs and Enclosures

The plant monitor in Chapter 13 works on the desk. Then it has to live outdoors with a pump that vibrates, a battery that ages and nobody watching it. This chapter is the step from a working prototype to hardware that survives, using the watering build as the running example. (Sensors x PCB x Gerber and IoT x Plants on the blog have the full logs.)

The Lesson That Started It: Not Every MOSFET Listens to 3.3V

The ESP32 drives the pump through a MOSFET. With the small pump, switching it from a 3.3V GPIO worked fine. With a 20W pump it didn’t: a standard MOSFET needs more gate voltage than a 3.3V pin gives to switch fully on, so it sits half-on and heats up.

The fix is a logic-level MOSFET, rated to switch fully at 3.3V. It’s the same lesson as 3.3V vs 5V logic levels in Chapter 3, one layer down: check the gate threshold on the datasheet at your drive voltage, not just the maximum current.

Every Component Prevents a Failure

The power stage for the pump is small, and every part on it is there to stop something specific going wrong:

PartFailure it preventsHowCost
Fuse (5A)Wire short → fireWeak link that melts first$0.10
Diode (1N4007) across the pumpBack-EMF spike (~100V) destroys the MOSFETClamps the spike$0.03
Capacitor C1 (1000µF)Inrush droop (~500mV) resets the ESP32 (brownout)Supplies the fast current$0.50
Capacitor C2 (0.1µF) at the pinHF noise on the 5V rail → false logic transitionsLocal bypass$0.05
Gate resistor (47Ω)Fast edges → EMI, ringing, gate stressSlows switching$0.02
Logic-level MOSFETGPIO can’t fully turn on a standard MOSFETSwitches at 3.3V$0.30
Ground planeGround bounce → logic glitchesLow-impedance return, star groundinglayout

Total: about a euro. If you remove any line, the failure in its second column is what you’ll be debugging three weeks later.

Simulate the Margins Before You Buy

Chapter 3 introduced PySpice for checking a circuit before buying parts. On the watering build, the simulations gave a list of design margins, not just “it works”:

  • Sized properly for a nominal 25 °C, with a 5-year battery warranty.
  • Cold start is marginal at −20 °C with a 5-year-old battery. Fix it with pre-warming or a foldback current limit.
  • Capacitors age: plan to replace them every 7–10 years.
  • If the pump stalls, the watchdog has to trip in under 300ms or the fuse melts (watchdogs in firmware: Chapter 8).

That list turns into a maintenance plan, and a reason to log battery voltage from day one.

Perfboard or a Real PCB?

Hand-soldered perfboardCustom PCB (KiCad)
ReliabilityJoints can crack under vibration; shorts underneathSolder mask, vibration-proof
CurrentDepends on the wire you solderWide traces or pours (2–3mm) handle 5–10A cleanly
AssemblySlow: point-to-point jumpersParts drop into labelled footprints
SizeBulky, 2.54mm gridCompact, fits a printed enclosure
Cost and timePennies, todayAbout $2–5 for 5 boards, 3–7 working days

Use a perfboard to prove the circuit. Use a PCB for anything that will run unattended with a vibrating pump on the same supply.

KiCad to Gerbers: The Short Version

  1. Schematic: the power stage above, plus the ESP32 headers.
  2. Footprints and layout: wide traces on the pump path and a ground pour.
  3. DRC (Design Rules Check): KiCad flags tracks too close together, unconnected pads, overlaps, copper too close to the edge, silkscreen on pads, and a missing board outline. Fix everything it reports.
  4. A second opinion. I had another AI agent review the design before ordering. It’s cheap, and boards are slow to re-spin.
  5. Export Gerbers and zip them for a bare-board order:
    • copper: *.GTL / *.GBL
    • solder mask: *.GTS / *.GBS
    • silkscreen: *.GTO / *.GBO
    • outline: *-Edge_Cuts.gbr (or *.GM1 / *.GKO)
    • drills: *-PTH.drl, *-NPTH.drl
  6. Order with standard specs: 2 layers, 1.6mm FR4, 1oz (35µm) copper, lead-free HASL (or ENIG), green mask, white silkscreen. JLCPCB, PCBWay and Aisler all take these. In Poland, Satland and Tecno Service do too.

The full KiCad learnings, the PRD for the board and both orders are in the poc repository.

The Enclosure

The board then needs a home, and the solar panel needs a mount above the plants. Two tools from the blog:

  • 3D printing: an .STL is all a printer needs (3D printing 101).
  • CAD as code with CadQuery: the enclosure is a Python script, so a change in board size is a change of one parameter, versioned in git like the firmware.

For a part that carries load, like a panel bracket in the wind, ask the FEM question before printing: not where does it go, but what happens to the material when it gets there.

Field-Test Like It’s Already Failing

The desk can’t reproduce what the field does to a node. From earlier chapters:

  • Condensation kills DHT22s near 100% RH (Chapter 7).
  • Solar gives you a few hours of charge a day. The rest is battery (Chapter 6).
  • Cold shrinks battery capacity. See the −20 °C margin above.

Leave a new node outside for weeks before trusting it, and watch its battery voltage and failed-read counts on the monitoring dashboard (Chapter 16).


Takeaway: Prove it on a perfboard. Then give every failure mode a part, simulate the margins, run DRC and get a second opinion, and ship a 2-layer board in a printed enclosure. Field-test for weeks, not days.