To install Raspberry Pi OS for a hardwired industrial or home automation project, use the official Raspberry Pi Imager to flash the 64-bit Bookworm release to a microSD card with pre-configured headless SSH and WiFi. Once the digital foundation is set, physically integrate the Pi into your mains-powered DIN-rail enclosure using a dedicated 5V DC power supply, ensuring strict adherence to wire gauge and termination standards to prevent ground loops or PMIC failure.

This guide bridges the software setup with the physical electrical installation, showing you exactly how to install Raspberry Pi OS while safely wiring the supporting 120V AC to 5V DC power infrastructure for a relay control panel.

Tools, Materials, and Component Ratings

Before opening your enclosure or inserting a microSD card, gather the exact components required for a reliable, code-compliant installation. Using undersized wire or unregulated power supplies is the primary cause of field failures in embedded panels.

Tools Required

  • Digital Multimeter: CAT III rated (minimum 600V) for verifying mains voltage.
  • Wire Strippers & Crimpers: Rated for 14 AWG solid/stranded and 18 AWG stranded.
  • Ferrule Crimper: For terminating 18 AWG stranded wire into screw terminals (prevents splaying).
  • Torque Screwdriver: VDE insulated, adjustable down to 0.5 Nm for terminal screws.
  • MicroSD Card Reader: USB 3.0 for faster flashing.

Materials and Device Ratings

  • Compute Module: Raspberry Pi 4 Model B (4GB or 8GB) or Raspberry Pi 5.
  • Storage: 32GB or 64GB microSD card (Application Class A2 rating for high IOPS).
  • Power Supply: Mean Well DR-15-5 (5V DC, 3A output, DIN-rail mount, 90-264V AC input).
  • Mains Wiring: 14 AWG THHN copper (Black, White, Green) rated for 600V, 90°C.
  • DC Load Wiring: 18 AWG stranded copper (Red, Black) rated for 300V, 105°C.
  • Overcurrent Protection: 15A single-pole breaker (for the 14 AWG branch circuit).

Terminal Mapping and Wire Specifications

Proper termination ensures low-resistance connections and prevents thermal runaway at the power supply block. The table below details exactly which screw terminal and GPIO pin each wire color lands on, along with the required gauge and device rating for this specific 15W load profile.

Source / Destination Terminal / Pin Wire Color Gauge & Type Torque / Note
120V AC Breaker to PSU PSU 'L' (Line) Black 14 AWG THHN 0.8 Nm / Ferrule if stranded
120V AC Neutral Bar PSU 'N' (Neutral) White 14 AWG THHN 0.8 Nm / Ferrule if stranded
Ground Bus Bar PSU Earth Symbol Green 14 AWG THHN 0.8 Nm / Bond to DIN rail
PSU 'V+' Output Pi GPIO Pin 4 (5V) Red 18 AWG Stranded 0.5 Nm / Use bootlace ferrule
PSU 'V-' Output Pi GPIO Pin 6 (GND) Black 18 AWG Stranded 0.5 Nm / Use bootlace ferrule

Note: Powering the Raspberry Pi directly via the 5V GPIO pins bypasses the onboard USB-C polyfuse and power management IC (PMIC) protection. This is standard practice in DIN-rail industrial panels to avoid USB-C connector fragility, but it demands a highly regulated power supply like the Mean Well DR-15-5 to prevent overvoltage events.

Mains Wiring and GPIO Terminations

⚠️ MAINS VOLTAGE SAFETY WARNING

This procedure involves 120V AC mains wiring. Before touching any terminal, de-energize the circuit at the main breaker panel and apply a lockout/tagout (LOTO) device. Verify the circuit is dead using a tested CAT III multimeter across Line-Neutral, Line-Ground, and Neutral-Ground. NEC-style guidance requires all panel work to comply with NFPA 70 (National Electrical Code); your local AHJ has final authority on panel modifications.

  1. Prepare the Mains Conductors: Strip 1/2 inch of insulation from the 14 AWG Black (Line), White (Neutral), and Green (Ground) THHN wires. Crimp insulated ferrules onto the ends if using stranded THHN to prevent fraying in the PSU screw terminals.
  2. Terminate Earth Ground: Land the Green 14 AWG wire onto the PSU terminal marked with the Earth ground symbol (⏚). Tighten to 0.8 Nm. Ensure the metal DIN rail is also bonded to the panel's main ground bus.
  3. Terminate Neutral: Land the White 14 AWG wire onto the PSU terminal labeled 'N'. Tighten to 0.8 Nm. Give the wire a firm tug to verify mechanical retention.
  4. Terminate Line: Land the Black 14 AWG wire onto the PSU terminal labeled 'L'. Tighten to 0.8 Nm.
  5. Prepare DC Output Wires: Strip 1/4 inch of insulation from the 18 AWG Red and Black stranded wires. Crimp 18 AWG bootlace ferrules onto both ends to ensure a clean insertion into the Raspberry Pi GPIO header or a intermediate terminal block.
  6. Connect DC Power to Pi: Route the Red 18 AWG wire from the PSU 'V+' terminal to GPIO Pin 4 (5V power) on the Raspberry Pi. Route the Black 18 AWG wire from the PSU 'V-' terminal to GPIO Pin 6 (Ground). If using a GPIO terminal block adapter (recommended for panel builds), land Red on the 5V screw and Black on the GND screw.

How to Install Raspberry Pi OS (Headless Configuration)

With the physical wiring complete (but the breaker still OFF), you must prepare the software. Because this Pi is mounted in an electrical panel, you will not have a monitor or keyboard attached. You must configure the OS for headless operation before the first boot.

  1. Download the Imager: Install the latest Raspberry Pi Imager (v1.8 or newer) on your Windows, Mac, or Linux workstation.
  2. Select the Hardware: Insert your 32GB A2-rated microSD card. Open the Imager and select your specific board (e.g., Raspberry Pi 4 or 5).
  3. Choose the OS: Navigate to Raspberry Pi OS (other) and select Raspberry Pi OS Lite (64-bit). The 'Lite' version lacks the desktop environment, saving RAM and reducing write-wear on the SD card—ideal for headless relay controllers running Debian 12 Bookworm.
  4. Edit OS Customisation Settings: Click 'Next', then click EDIT SETTINGS when prompted.
    • General: Set a hostname (e.g., panel-relay-01.local). Create a username and a strong password. Enter your 2.4GHz WiFi SSID and password (Pi 4 does not support 5GHz WiFi reliably inside steel panels due to Faraday cage effects; use 2.4GHz or run an Ethernet cable).
    • Services: Check Enable SSH and select 'Use password authentication'. This is mandatory for remote terminal access.
  5. Flash the Card: Save settings, click YES to apply OS customisation, and wait for the write and verify cycles to complete.
  6. Install the SD Card: Safely eject the microSD card and insert it into the Raspberry Pi's slot, ensuring the copper contacts face inward and click securely.

Verification, Testing, and Common Botches

Do not close the panel door until you have verified voltage levels and confirmed a successful headless boot.

Meter Readings and Boot Verification

  1. Pre-Power Check: Set your multimeter to continuity mode. Place one probe on the PSU 'V-' terminal and the other on the Pi's GPIO Pin 6. You should read < 1 ohm. Repeat for 'V+' to Pin 4. This confirms no open circuits.
  2. Energize Mains: Remove LOTO, clear the panel, and flip the 15A breaker ON.
  3. Verify AC Input: Set meter to AC Voltage. Measure across PSU 'L' and 'N'. Expected reading: 114V to 126V AC.
  4. Verify DC Output: Set meter to DC Voltage. Measure across PSU 'V+' and 'V-'. Expected reading: 5.0V to 5.2V DC. (If it reads outside this, turn off power immediately and adjust the PSU trim potentiometer).
  5. Verify Pi GPIO Voltage: Carefully measure across GPIO Pin 4 and Pin 6. Expected reading: 4.9V to 5.1V DC. A drop greater than 0.2V indicates a poor crimp or undersized wire.
  6. Network Boot Check: Wait 60 seconds. The Pi's green ACT LED should flicker irregularly. Open your workstation terminal and type ssh youruser@panel-relay-01.local. A successful login confirms the OS installation and headless config worked.

The Most Common Botch: Dual-Power Backfeed

The Mistake: Wiring 5V into the GPIO pins while simultaneously leaving a USB-C power cable plugged into the Pi for 'testing'.

The Symptom: The Raspberry Pi becomes blazing hot to the touch near the USB-C port, the PWR LED remains off, and the board fails to boot or show up on the network. You may smell ozone or burning plastic.

The Physics: The Raspberry Pi's power path includes a PMIC and polyfuse on the USB-C line. When you inject 5V directly into the GPIO header, current flows backward through the PMIC. If a USB-C cable is also attached, the two power sources fight, creating a ground loop or backfeeding voltage into the USB-C VBUS line, permanently destroying the PMIC and nearby decoupling capacitors.

The Fix: Never apply power to the GPIO pins and the USB-C port simultaneously. In a hardwired DIN-rail panel, physically block or remove the USB-C port, or use a 3D-printed cover to prevent well-meaning technicians from plugging in a phone charger later.