On this page
Draw it, then prototype it
Draw it. Every build starts as a KiCad schematic, drawn on the laptop you hardened in Module 00, with the same symbols you learned to read in Module 02. The drawing is itself the first test: KiCad's electrical rules check automatically detects incorrect and missing connections, flagging an unconnected pin or a power input that no output pin drives, before you've picked up a single part.7 KiCad can go further and lay out a printed circuit board for fabrication, but that is beyond this course. Here, the schematic is the map you build from.
Prototype it. A solderless breadboard lets you assemble a circuit with no soldering at all, so you can try your designs before committing them to solder.1 Beneath its holes sit short metal rows called terminal strips: any two wires or leads plugged into the same strip are electrically connected.6 A gap called the bridge runs down the middle and splits the board in two, so a chip can straddle it with each leg landing on its own terminal strip.6 Along each edge run the power rails, one marked with a red line and the other with a blue line, carrying the supply the length of the board.6
To build the circuit on a breadboard, place the real parts so their connections match the schematic, node for node. Give each leg of a part its own strip, because putting both legs into one strip shorts the part out.6 Then prove the build with the multimeter in two passes:
- Before power, continuity. Set your multimeter to continuity mode. Touch the probes to any two points the schematic shows as connected, and the meter should beep. Touch two points from different parts of the circuit that the schematic does not connect, and the meter should stay silent.
- Under power, voltage. Set your multimeter to DC volts. Put the black probe on ground, then touch the red probe to each point the schematic labels with a voltage, and check that the meter reads that value.
Make it permanent. A breadboard is temporary, since its wires tend to fall out after a while.1 Once a circuit works, transfer it to perfboard or stripboard, a perforated board you cut to size and solder the parts onto: stripboard carries conductive strips underneath, while perfboard has an isolated pad at each hole.1 Positions don't need to match the schematic, only the connections do.
Batteries and power
The basic unit of a battery is the cell; a battery, strictly speaking, is "a group of two or more connected voltaic cells,"8 though in everyday use the word covers both. A cell you use once and throw away is a primary cell, and one you can recharge is a secondary cell.8
A cell has three ratings that matter here: voltage, capacity, and C-rate. Voltage is how hard the cell pushes current; capacity, in milliamp-hours, is how much charge the cell holds.
A 3000 mAh cell can supply 3000 mA, or equivalently 3 A, for one hour.1 Divide the capacity by the current your circuit draws to estimate the runtime: a circuit drawing only 30 mA should run for about 100 hours on that same cell (3000/30).1 Treat that as an estimate, not a guarantee: the harder you draw, the less of the rated capacity you actually get, so build in margin. Real cells typically deliver only about 25 percent of their theoretical capacity (the capacity computed from the raw materials alone); the mAh rating printed on the label already accounts for this and is the number you plan with.9
The third rating, the C-rate, sets how hard you may pull at all. One C means draining the whole capacity in one hour, so a cell rated at 2 Ah with a maximum continuous discharge of 4 A has a C-rate of 2.10 Pulling past that rating overheats the cell, hot enough in some cases to catch fire.1 The calculator below does the runtime arithmetic for you.
The voltage printed on the label is not what you get under load; the reason is internal resistance. A multimeter across a fresh cell reads its full voltage, but the moment current flows, that resistance drops the terminal voltage the cell delivers.8
A fresh 1.5-volt AA settles near 1.3 V under load and still delivers useful power down to about 1 V, so a four-cell pack can sit anywhere between 4 and 6 volts.1 A 9-volt battery delivers between 7 and 10 volts depending on its chemistry and wear.6 Lithium cells sag under load too, and on an RC LiPo you watch that sag closely: the cell should never drop below 3.0 V while in use.10
Cells combine two ways. Wired in series, positive to negative, the voltages add while the current stays the same, so four 1.5-volt cells in series give a total of 6 volts.8 Capacity does not add in series: four 1.5-volt, 2000 mAh cells in series still hold 2000 mAh, just at 6 volts instead of 1.5.1 Parallel is the reverse: the voltage stays the same and the capacities add.8 Parallel comes with one hard rule: match the cells' voltages before you join them, or the fuller cell will try to dump a large amount of energy at once into the less charged one, and that can end in fire.10
Each chemistry is a trade-off. Alkaline cells are the cheapest option: they hold 1.5 volts and keep their charge for years, losing only about 4 percent of it annually, but as primary cells, they must be discarded once dead.9 NiMH rechargeables hold about 75 watt-hours per kilogram, less than an alkaline cell but rechargeable hundreds of times, though they self-discharge faster in storage as temperature and charge level rise.9 Lead-acid stores about 25 Wh/kg, the least of the four, and is heavy for the energy it holds, but it remains the most robust of the technologies, with the least chance of fire or explosion.1 9 That robustness is why lead-acid is still the standard for starter batteries in most cars. Lithium-ion, including its soft-pouch form, stores far more than any of the others, about 150 Wh/kg at 3.6 volts nominal and 4.2 volts full, and survives more than a thousand charge cycles.9
That density is why a lithium cell powers a Raspberry Pi in the field: a Pi requires a steady 5 volts, and a sensor often requires 3.3, so the cell feeds a regulator or a boost converter rather than the board directly.
One term needs a correction before you shop for cells: what the market sells as "LiPo" is not a separate chemistry, but a lithium-ion cell packed in a soft pouch. A true lithium-polymer cell, one with a solid polymer electrolyte, never became a commercial product.10 The high-discharge "RC LiPo" sold for hobby aircraft is a specific cobalt chemistry, and the warning about it is blunt: these cells are dangerous and can catch fire if you don't follow proper charging and discharging procedures.10
Charging a lithium cell takes more than applying voltage. A proper charger runs in two phases, first pushing a steady current until the cell reaches its 4.2 V limit, then holding that voltage while the current tapers off.10 9 In practice that means charging at 4.2 V with the current capped, usually around 0.5 A, and charging slowly, since most lithium cells should not be charged faster than 0.5 C.1 10 The TP4056 board you meet in Build 2 is a single-cell charger that runs this whole sequence for you.
Build 1: power MOSFET switch
This build is the payload switch, the circuit that turns a load on and off from a small control signal. The problem is always the same: a small control signal has to switch a load far heavier than it can drive. A logic pin lives at 3.3 or 5 volts and supplies a few milliamps, while the payload runs on its own supply, at voltages the pin cannot touch and currents up to amps. The answer is a power MOSFET, a transistor used as a switch: it's controlled by voltage rather than current, so the gate turns it on once its voltage passes a threshold, typically around 2 V.1
The part here is the FQP30N06L, a 30 amp N-channel MOSFET with a 2.0 volt gate threshold1 (its datasheet gives the threshold as a 1.0 to 2.5 volt window).3 It is a logic-level MOSFET, meaning its gate threshold is low enough for a microcontroller's digital output pins to drive it directly.1 The FQP30N06L is out of production and listed as obsolete by distributors, with remaining stock thinning.3 If you substitute another logic-level MOSFET, such as the IRLB8721, check the gate threshold on its datasheet, then confirm the swap works with this build's meter checks.
The payload here is the 9 volt siren, which also serves as the relay's load in Build 3 and the alarm in the field exercise. In this build, a knob turns it on. The book's reference circuit runs on a 6 volt (4×AA) pack, and we use a 9 volt block to match the supply standard for these builds. A potentiometer is an adjustable resistor: its two ends span a fixed resistance, and a third terminal, the wiper, taps off a voltage between them that you set by turning the knob. A trimmer is the small board-mounted kind. A 10k trimmer potentiometer sets the gate voltage, the FQP30N06L switches the current, and the siren is the load.
Build it in this order.
- Seat Q1 across three rows. Facing the labeled side, the FQP30N06L's pins are gate, drain, source, left to right.3
- Seat RV1, the 10k trimmer. Its two outer legs go to the +9 volt rail and the ground rail; its center wiper runs to Q1's gate.
- Wire the siren between the +9 volt rail and Q1's drain: its red lead goes to the rail and its black lead to the drain.3
- Run Q1's source to the ground rail.
- Connect the 9 volt block last, and match its leads to the rails' polarity marks.
Prove it. Turn the trimmer across its range with your multimeter on the gate: below the threshold the siren is silent, and just past it the sound snaps on at full volume. A datasheet-grounded simulation of the circuit puts numbers on that snap. The siren is a light load, 15 milliamps at most, and it starts sounding once its terminal voltage passes its 3-volt floor. In the simulation, that happens between about 1.8 and 1.9 volts on the gate, and the whole swing from silent to full spans about a tenth of a volt.3 On your actual MOSFET, the snap lands somewhere within the datasheet's 1.0 to 2.5 volt window; wherever it lands, only the narrowness of the snap itself stays constant. Fully on, the drain-to-source drop is a few millivolts, and the light load pulls the 9 volt block down by only a few hundredths of a volt.3
If it fails. Siren silent at every knob position: measure the wiper to ground. If the reading never rises past the 1.0 to 2.5 volt threshold window, the wiper isn't reaching the gate.3 Siren quiet or ragged with the knob unresponsive: the gate voltage is sitting right at the threshold, where the MOSFET is only partly conducting; turn the knob further past it.3 Siren silent with the gate voltage high: check the siren's polarity, since the red lead belongs on the +9 volt side.3
Build 2: regulate and boost a battery
This build is field power: a steady 5 volts, whether the battery sits above it or below it, because raw battery voltage is never the steady rail a circuit needs. There are two moves, and you build both. To regulate is to hold a higher, sagging voltage steady at a lower value. To boost is to step a voltage that is too low up to the one you need.
First, regulate 9 volts down to 5. The 7805 is a three-pin linear regulator: voltage in, ground, a steady 5 volts out. Any input between 7 V and 25 V can be regulated down to a constant 5 V.1 The 7 volt floor matters: the input must sit about 2 volts above the output, so a single 3.7 volt cell can never feed a 7805. The two capacitors act as small reservoirs of charge that keep the regulator stable, and they matter even more when the load varies, as a Pi's does.1 One reference build omits both capacitors, since its supply is steady and its load is a fixed resistor. Ours is neither, so we keep the datasheet's specified 0.33 µF in and 0.1 µF out.3
Build it in this order.
- Seat the 7805 across three rows. Facing the labeled side, its pins are input, ground, output, left to right.3
- Place C1, 0.33 µF, between the input pin's column and the ground rail, and C2, 0.1 µF, between the output pin's column and the ground rail.3
- Run the ground pin to the ground rail, and the output pin to the +5 volt bus that feeds the load.
- Connect the 9 volt block last, positive to the input side, and match the rails' polarity marks.
Regulating this way wastes the difference as heat. The 78 series is fine for low-power circuits of a few hundred milliamps, but above that it starts to get hot and may need a heatsink.1 A datasheet-grounded simulation confirms the behavior: a steady 5.0 volts out for inputs of 9 V, 7 V, or anything just above the 7 V floor, with regulation collapsing once the input drops below it.3 So the meter check is two readings: the input should sit near 9 volts, and the output at 5.0. If the output is low, measure the input first; below the 7 volt floor the regulator has nothing to regulate with.1
Then boost 3.7 volts up to 5. To run a Pi from one small lithium cell you need the opposite move. A boost converter uses an IC and a small inductor, pulsing current through the coil to step a lower voltage up to a higher one.1 Inexpensive adjustable boost modules are widely available, and a combined board charges the LiPo over USB while boosting its output.1 We build that combination from parts on hand: a 3.7 volt LiPo, a TP4056 charger, and an SX1308 boost module set to 5 volts. It does the same job as a commercial PiSugar supply. One rating matters here: the mini slide switch on the cell line is a 0.5 amp part, and a hard-working Pi Zero 2 W can pull more than that from a 3.7 volt cell. The switch is fine for light loads like a microcontroller and a servo; for the Pi, use a switch rated higher than 0.5 A.
Build the chain in this order.
- Wire the cell's positive lead through the slide switch to the TP4056's B+ pad, and the cell's negative lead to B−. These are the battery pads; the Type-C port is where charge comes in.
- Wire the SX1308's input from the same B+ and B− points, positive to IN+, negative to IN−.
- Before the Pi touches anything, power the chain and set the SX1308's trimmer until its output reads 5.0 volts on your meter. The module adjusts across a wide range, so it is set first and loaded second.3
- Leave the output unconnected; the Pi connects to it in Build 3, positive and negative checked against the meter, not the wire colors.
Prove it, and read the runtime. The output is already set to 5.0 volts from the last step; the load test comes in Build 3, when the Pi is online. Runtime follows the capacity rule from Unit 02, but with two corrections: the boost loses some of the cell's energy as heat, and the Pi's draw varies with load. A 450 mAh cell at 3.7 volts holds a little over 1.6 watt-hours; after the boost's losses, that leaves roughly 1.4 to 1.5 usable watt-hours at 5 volts. A Pi Zero 2 W draws about 120 milliamps at 5 volts sitting idle, and more with Wi-Fi active, so expect one to two hours of light use, and well under an hour when the CPU or Wi-Fi works hard.11 A plain capacity-over-load estimate comes out high; the boost's losses and the Pi's load spikes are why you get less.
Build 3: relay from a Pi
This build brings the Pi online: you set it up here, and the relay is the first thing it drives. The board is a Pi Zero 2 W, the pocket-sized sibling of the Pi 5 that runs your Module 01 node, and its 40-pin header is the same. A relay is essentially an electromagnet that closes switch contacts; because the coil and the contacts are electrically isolated from each other, relays are well suited to switching home-powered devices on and off.1 Where the MOSFET in Build 1 switched a load sharing its ground, a relay gives full isolation: the switched circuit shares nothing with the Pi.
Meet the board before you wire it: the explorer below is the same tour Module 01 gave the Pi 5.
The header comes fitted. This module specifies the Zero 2 WH, the same board with the 40-pin header already on it, so every connection here is a jumper onto a pin. The header is what the future field hardware stacks onto; keep it unobstructed.
Set up the board first. The Zero 2 W arrives blank, and you prepare it exactly the way you prepared the Module 01 node: from the hardened laptop, with no monitor ever attached.
- In Raspberry Pi Imager, choose Raspberry Pi OS Lite (64-bit).2
- In the Imager's settings, give the board its own hostname, enable SSH with the same public key your laptop already uses for the node, and enter your Wi-Fi credentials for the 2.4 GHz network; the Zero 2 W has a 2.4 GHz radio only.2 Ours is named
dolos, after Dolos, the remotely deployed device this series builds toward: this board serves as its controller and keeps the name from here on. - Boot it and reach it from the laptop:
$ ssh [email protected]
The board is now a node on the LAN you built in Module 01, and every command in the rest of this module is typed into that SSH session. It stays a local device for now; it does not join the private VPN your node runs on. That enrollment happens in a later module, when the board takes a cellular link and leaves the building. Two tools do the GPIO work on current Raspberry Pi OS: pinctrl, which ships with the OS and drives a pin from the shell, and gpiozero, the Python library.2 OS Lite may not include the library, so install it once:
dolos $ sudo apt update && sudo apt install -y python3-gpiozeroA Pi cannot drive a relay coil directly. A GPIO pin can source about 16 mA at most,2 while the SRD-05VDC-SL-C's 70 Ω coil pulls about 72 mA at 5 volts,3 several times what the pin can safely give. So a small transistor does the driving. A standard relay driver combines a 2N3904 transistor (the near-twin of Module 02's 2N2222), a 1 kΩ base resistor, a 1N4001 diode, and a 5-volt relay.1 You met the transistor and the diode as symbols and packages in Module 02. The 1-channel relay board used here (high/low level trigger), carrying a SONGLE SRD-05VDC-SL-C relay, already has those parts built in.
Prove it. Drive GPIO18 high and low from the SSH session:
dolos $ pinctrl set 18 op dh # output, drive high: relay closes
dolos $ pinctrl set 18 op dl # drive low: relay releases
The test is the sound: if the build is working, the relay module clicks on and off.1 The indicator LED lights and the isolated siren follows. Confirm the isolation with the meter set to continuity: put one probe on the Pi's ground and the other on the siren's negative terminal. The meter reads OL and never beeps, because the two circuits share nothing. If the pin goes high and nothing clicks, check two things: the trigger jumper's high/low setting, and whether 5 volts is actually present between the module's DC+ and DC− on your meter.
Close Build 2's loop. Shut the board down, connect the pack's output (5 volts to pin 2, ground to pin 6), and boot from the battery. The pack's output holds 5.0 volts on the meter under the running board.
Build 4: motion sensor and a Pi
This build reads a sensor: a PIR (passive infrared) detects a moving source of infrared radiation, such as a person's body heat, crossing its field of view. Supply it with power, and its output goes high when it detects movement, then drops back low a second or two later.1
In this build you wire an HC-SR501 PIR module to a Pi Zero 2 W with three wires. The mapping is ground to ground, VCC to 5 volts, and OUT to GPIO18.1
Build it in this order.
- Read the sensor's silkscreen. OUT is the center pin; find which outer pin is VCC and which is GND on your board.
- Prove the output level first: power the sensor alone, put the meter on OUT, and confirm it swings to about 3.3 volts on motion, not 5.1
- With the Pi shut down, run the three jumpers: 5 volts (pin 2) to VCC, GND (pin 6) to ground, OUT to GPIO18 (pin 12).1
Prove it. Power the Pi, set your multimeter to DC volts on the OUT line, and walk in front of the sensor. The line snaps from 0 volts to about 3.3, holds for the delay you set, then drops. If OUT holds high far longer than you want after each pass, that is the delay trimmer, not a fault; it sets how long OUT stays high after a trigger. Then read the same line in software:
dolos $ pinctrl set 18 ip; pinctrl get 18 # input; reads lo idle, hi on motion
Field exercise
Builds 3 and 4 both use GPIO18, one to drive the relay and one to read the PIR, so combining them means moving one. Keep the PIR on GPIO18 and jumper the relay to GPIO17 instead; you write a short gpiozero bridge script that reads GPIO18 and copies its state to GPIO17, so motion on the sensor closes the relay in real time.
Task: Build a motion-triggered switch that runs on its own power: the PIR feeds the Pi, the Pi drives the relay, the relay sounds an isolated siren, and the Build 2 pack powers the Pi.
Condition: Given your four proven builds, the hardened laptop you reach the Pi from, a Pi Zero 2 W, a breadboard and jumper wires, the siren with its own 9 volt supply, and a multimeter.
Standard: The Pi runs from the Build 2 pack, its boost output confirmed at 5.0 volts before it touches the Pi; motion in front of the sensor closes the relay and sounds the siren; the siren releases after the set delay; every connection matches your drawings, in KiCad or on paper; and the finished breadboard is photographed next to its drawing for your build log.
Module test
Task: Complete the Module 03 test.
Condition: Given ten questions covering units one through seven, without reference to the module units or notes.
Standard: Answer at least eight of ten questions correctly. For each question missed, reread the unit named in the feedback and retake the test until the standard is met.
Glossary
- boost converter
- A part that steps a voltage up, so a 3.7 volt cell can supply 5 volts; the SX1308 module is the example here.
- capacity (mAh)
- How much charge a battery holds; capacity divided by the current drawn gives the runtime.
- Dolos
- The remotely deployed device this series builds toward, more than any one sensor or alarm. The Pi Zero 2 W set up in Build 3 serves as its controller and keeps the hostname; the device itself takes shape in later modules, radio and cellular link included.
- flyback diode
- A diode across an inductive load, such as a relay coil, that absorbs the voltage spike when the current is switched off.
- logic-level MOSFET
- A MOSFET with a low enough gate threshold to be driven directly by a microcontroller pin.
- MOSFET
- A transistor switched fully on or off by a voltage on its gate; used to switch a heavy load from a light signal.
- perfboard
- A board of holes with copper pads to solder to, where a breadboarded circuit becomes permanent.
- PIR sensor
- A passive infrared sensor; its output goes high when it detects a moving source of infrared radiation, such as a person's body heat.
- regulator
- A part that holds its output at a fixed voltage below its input (step down). The 7805 gives a steady 5 volts and needs about 2 volts of headroom.
- relay
- An electrically operated mechanical switch; its coil, energized, closes contacts that switch a separate, isolated circuit.
- voltage sag
- The drop in a battery's voltage under load and as it discharges. It's the reason raw battery voltage needs conditioning.
Sources
- Simon Monk, Hacking Electronics, 2nd ed., McGraw-Hill, 2017. Primary source for the builds. MOSFETs as voltage-controlled switches and the logic-level FQP30N06L (Ch. 3, pp. 45–48); batteries, capacity, discharge rate, series and parallel, and LiPo safety (Ch. 5, pp. 79–93); the 7805 regulator and its 7–25 V input range and capacitors (pp. 93–95); boost converters (pp. 95–96); driving a relay from a transistor and the coil diode (Ch. 6, pp. 113–116); wiring a relay module to a Raspberry Pi (Ch. 7, p. 157); and the PIR sensor with a Pi and its 3.3 V output (Ch. 8, pp. 162–166).
- Raspberry Pi documentation: GPIO and the 40-pin header (pads control). The 40-pin header used here (pin 2 = 5 V, pin 6 = ground, pin 12 = GPIO18) and the 3.3 V logic level of the GPIO pins; the Imager's OS customization for headless setup (hostname, SSH key, Wi-Fi); and the pinctrl shell tool and gpiozero Python library used to drive and read the pins.
- Manufacturer datasheets: FQP30N06L, L7805, SRD-05VDC-SL-C, 1N4001, SX1308, TP4056, HC-SR501, and the SFM-27-class 9 V piezo siren (DC 3 to 24 V, 15 mA maximum, red lead positive). Part ratings, pinouts, and the values used to validate each build in simulation (the MOSFET switching the siren across its gate threshold, the 7805 output and dropout, and the relay coil spike with and without the diode). FQP30N06L lifecycle: listed as obsolete by onsemi in distributor catalogs (verified 2026-07-04).
- “Hacking When It Counts: POW Canteen Radios,” Hackaday, 2016. Lt. Col. R.G. Wells and fellow prisoners in a Japanese camp in Borneo (1942) built a radio receiver from improvised parts: resistors from string impregnated with burnt cinnamon bark, capacitors from tea-chest foil, wire insulation from flour and palm oil, and a chromic-acid wet cell from potassium dichromate and zinc trouser buttons; only the vacuum tube and headset could not be improvised, and the headset was smuggled in.
- “Foxhole radio,” Wikipedia. Improvised WWII receivers built from a razor-blade-and-pencil-lead detector; corroborates the practice of prisoners of war building improvised radio receivers in WWII, though the article does not itself name R.G. Wells or Borneo.
- Jonathan Bartlett, Electronics for Beginners, Apress, 2020. The schematic as an abstraction where only the connections matter; the solderless breadboard's five-hole terminal strips, the center gap that straddles a chip, and the power rails; and translating a schematic to a breadboard layout (Ch. 5–6).
- KiCad Eeschema documentation: the Electrical Rules Check. KiCad's ERC performs “automatic detection of incorrect and missing connections,” including unconnected pins and an input power pin “not driven by any Output Power pins.”
- Electrical Science, Module 4: Batteries (DOE-HDBK-1011/2-92), US Department of Energy. Cell fundamentals: the battery as connected voltaic cells; primary versus secondary cells; series and parallel wiring (four 1.5 V cells give 6 V in series, and parallel adds current capacity); ampere-hour capacity; and internal resistance dropping the terminal voltage under load (VL = VB − ILRi).
- David Linden and Thomas B. Reddy, Handbook of Batteries, 3rd ed., McGraw-Hill, 2002. Authoritative comparison figures (Tables 1.2, 7.3, 22.3): nominal cell voltage, specific energy, self-discharge rate, and cycle life for alkaline (1.5 V), lead-acid (2.0 V), NiMH (1.2 V), and lithium-ion and lithium-polymer (3.6 V nominal, 4.2 V full); and the practical capacity being only about 25 percent of theoretical under real load.
- Micah Toll, DIY Lithium Batteries: How to Build Your Own Battery Packs. The lithium-ion and LiPo voltage window and the correction that most “LiPo” cells are lithium-ion pouch cells; the C-rate; series (S-count) and parallel pack math and the rule to match cell voltages before joining them in parallel; voltage sag; constant-current, constant-voltage charging; thermal-runaway thresholds; and using salvaged cells conservatively.
- CNX Software: “Raspberry Pi Zero 2 W power consumption” (2021). Bench measurements: about 120 mA at 5 V idle headless on Raspberry Pi OS Lite, roughly 75 mA with HDMI and services disabled, peaks near 600 mA under CPU stress and up to about 1.4 A under combined load (verified 2026-07-04).