Skip to the content
2 layers170 × 100 mmVoltshift, the printed circuit board in 3D

An ATmega328P based automatic voltage stable line switcher: senses three incoming mains lines, picks the one holding steady near 240V, and drives a stepper controlled selector onto it, or to OFF when no line is safe.

Size
170 × 100 mm
Copper layers
2
Thickness
1.6 mm
Parts
54
Nets
58
Pads
167
Tracks, vias
518, 43
Pours
2
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
6 Oct 2026
Updated
6 Oct 2026

Overview

Voltshift is an open-source printed circuit board by gulshanshah, from the gulshanshah/voltshift repository on GitHub, published under the MIT licence. It is a 2-layer board of 170 × 100 mm with 54 parts on 58 nets, routed with 518 tracks and 43 vias.

It is built around the ATMEGA328P-PU, ULN2003A and BZT52C5V6. Its parts include 21 resistors, 9 capacitors, 5 ICs, 5 diodes and 1 connector. It belongs with the robots and motor control boards and the AVR (ATmega, ATtiny) boards of this library.

Main components

3

README

README.md

VoltShift

Automatic voltage-stable line switcher.

In many villages and homes the supply arrives unbalanced — some lines sit weak, some sit high, and people walk over to the board and move the home supply to the line that behaves. VoltShift does that switching automatically: it watches three incoming lines, picks the one that is stable near 240 V, and drives a selector switch onto it with a stepper motor — or to OFF when no line is safe.

Repository layout

PathWhat it is
pcb/KiCad 9 project — voltshift.kicad_pro, schematic, board and netlist
firmware/ATmega328P firmware (bare-metal C, PlatformIO)
media/Board renders, layer plots, schematic SVG and PDF
docs/Schematic PDF and the ERC report

How it works

  1. Sensing — three identical channels (R, Y, B), each a fusible 4R7 input resistor, three 150k 1 % series resistors stepping the AC line down, and a 1N4007 rectifier turning it into a DC level the MCU can read. A 4k7 shunt, a 5.6 V zener and a 47 µF cap clamp and smooth that level.
  2. Isolation — each channel feeds a PC817 optocoupler, so the mains domain stays galvanically separate from the logic domain; the opto output lands on an ATmega328P ADC input through a 10k pull-down.
  3. Decision — the MCU samples all three inputs continuously, accepts only a line that reads stable near 240 V, and rejects anything too high or too low.
  4. Switching — a 28BYJ-48 stepper driven by a ULN2003A turns the selector through four 45° positions: the healthy line, or OFF when nothing is in range.

The board keeps manual switching out of the equation — the home supply always lands on the healthiest voltage.

Hardware

  • MCU — ATmega328P-PU @ 16 MHz, with ISP (2×3) and 5 V TTL UART headers
  • Drive — ULN2003A → 28BYJ-48 stepper selector
  • Sensing — 3× opto-isolated AC channels → ADC0/1/2
  • Power — external 5 V DC input, ferrite-isolated AVCC
  • Board — 170 × 100 mm, 2-layer, mains domain and logic domain split with ≥ 6 mm creepage between them and a ground pour kept to the logic side only
  • Status — schematic and routed PCB complete, ERC clean (0 errors, 0 warnings)

Safety

This board handles 240 VAC mains. Sense resistors must be rated for the working voltage, creepage/clearance must be respected, and the board must not be touched while powered. It is a prototype — validate it against your local electrical rules before putting it anywhere near a real installation.

Media

VoltShift board render

TopBottom
Board topBoard bottom

Firmware

The firmware lives in firmware/ and runs directly on the ATmega328P — no Arduino framework, no communication, fully automatic, about 1.8 KB of flash.

text
firmware/include/config.h   # thresholds, calibration, pin map, timing
firmware/src/adc.c           # averaged ADC reads + counts-to-decivolts calibration
firmware/src/selector.c      # line validity, best-line choice, hysteresis
firmware/src/stepper.c       # half-step driver for the 28BYJ-48 selector
firmware/src/led.c           # status LED patterns
firmware/src/main.c          # 1 ms tick, sample/evaluate loop, watchdog

Every 10 ms each channel is averaged and converted to decivolts; every 100 ms a line is accepted only if it sits inside 205.0–255.0 V with under 2.0 V of ripple. The selector moves to the accepted line closest to 240 V, only after that line beats the held one by more than 3 V for four consecutive evaluations, and drops to OFF the moment the held line goes invalid. The status LED reports state: slow blink while starting up, solid on a line, fast blink on OFF or while the motor is moving.

Build and flash with PlatformIO:

text
cd firmware
pio run                     # builds firmware.elf / firmware.hex
pio run -t upload           # default programmer is usbasp (ISP)

Calibration is per-channel in include/config.h — VS_CAL_OFFSET_* and VS_CAL_SPAN_*_PER_100V map raw ADC counts to voltage; tune them against a known-good meter before trusting the decisions.

Working on the design

Open pcb/voltshift.kicad_pro in KiCad 9 and edit the schematic and the board directly. Run the Electrical Rules Checker after any change — the last check came back clean (0 errors, 0 warnings).

Keep the two domains apart while editing: mains circuitry stays left of the isolation gap, the ground pour belongs to the logic side only, and the 6 mm creepage between them must survive any move. The exported schematic PDF and the ERC report are in docs/.

Status

Schematic and PCB are done and ERC-clean, and the firmware builds for the ATmega328P. Next up: fab the board and build the first unit.

License

MIT — see LICENSE.

Parts

54
QtyValueFootprintReferences
9150k 1%Resistor_SMD:R_1206_3216MetricR1, R2, R3, R4, R5, R6, R7, R8, R9
710kResistor_SMD:R_0805_2012MetricR13, R14, R15, R16, R17, R18, R19
3100nFCapacitor_SMD:C_0805_2012MetricC6, C7, C8
31N4007Diode_THT:D_DO-41_SOD81_P10.16mm_HorizontalD1, D2, D3
347uF 16VCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC1, C2, C3
34R7 1W FUSIBLEResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalRF1, RF2, RF3
34k7 1%Resistor_SMD:R_0805_2012MetricR10, R11, R12
3BZT52C5V6Diode_SMD:D_SOD-123Z1, Z2, Z3
3PC817Package_DIP:DIP-4_W7.62mmU2, U3, U4
21kResistor_SMD:R_0805_2012MetricR20, R21
222pFCapacitor_SMD:C_0805_2012MetricC4, C5
1+5V TX RX GNDConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ_UART
110uF 16VCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC9
116MHzCrystal:Crystal_HC49-4H_VerticalY1
128BYJ-48Connector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_VerticalJ_MOT
15V DC INTerminalBlock:TerminalBlock_bornier-2_P5.08mmJ_PWR
1ATmega328P-PUPackage_DIP:DIP-28_W15.24mmU1
1Ferrite 600R@100MHzInductor_SMD:L_0805_2012MetricFB1
1ISPConnector_IDC:IDC-Header_2x03_P2.54mm_VerticalJ_ISP
1MAINS R Y B NTerminalBlock:TerminalBlock_bornier-4_P5.08mmJ1
1PWRLED_SMD:LED_0805_2012MetricLED1
1RESETButton_Switch_THT:SW_PUSH_6mmSW1
1STATUSLED_SMD:LED_0805_2012MetricLED2
1ULN2003APackage_DIP:DIP-16_W7.62mmU5

Similar boards

  • 4 layers25.4 × 25.4 mmTwonkie, the printed circuit board in 3D

    Twonkie

    dojoe/Twonkie

    A USB-PD sniffer/injector/sink based on Google's Twinkie, re-designed to be manufactured by mere mortals.

    62 parts415
  • 4 layers100 × 100 mmSTM32Inverter, the printed circuit board in 3D

    STM32Inverter

    Zychlix/Inverter32

    An open source, open hardware plug'n'play 3 phase motor inverter design. It

    154 parts4
  • 2 layers50 × 65 mmChufe v-0-rev a, the printed circuit board in 3D

    Chufe v-0-rev a

    piruetasxyz/kicad-visor-demo

    A working example of kicad-visor by piruetas: on every push to main, a GitHub Actions workflow exports every KiCad project in this repository (schematics, board layers, 3D renders and seamlessly looping turntable…

    23 parts1
  • 2 layers60 × 27 mmBSH Dev Board, the printed circuit board in 3D

    BSH Dev Board

    Bouni/BSH-Dev-Board

    This project is one of many variants of a PCB that can be used to interface with B/S/H appliances using the awsome bsh-home-appliances project.

    67 parts
  • 4 layers132.6 × 100 mmAnarchytechnobox, the printed circuit board in 3D

    Anarchytechnobox

    edwindertien/foundscape

    midi control of things that tap and go boink

    292 parts
  • 2 layers115 × 85 mmBitaxetuner fan board, the printed circuit board in 3D

    Bitaxetuner fan board

    Elemirus1996/BitaxeTuner

    Automatisches Übertakten, Benchmarken und 24/7-Überwachung für Bitaxe- und NerdAxe-Miner – Windows-App und Server für Raspberry Pi, Windows und Docker: Browser & Handy-App, Push, Pool-Steuerung, Ertrag gegen…

    60 partsGPL-3.0
  • 2 layers54 × 47.5 mmPCB updi unbricker, the printed circuit board in 3D

    PCB updi unbricker

    k-takata/PCB_updi_unbricker

    UPDI High Voltage programmer for AVR Dx/Ex and ATtiny series

    63 parts
  • 2 layers50 × 65 mmChufe v-0-rev a, the printed circuit board in 3D

    Chufe v-0-rev a

    piruetasxyz/chufe

    popusintes - chufe

    23 parts

Questions

How big is the Voltshift PCB?

It measures 170 × 100 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Voltshift use?

54 parts, built around the ATMEGA328P-PU, ULN2003A and BZT52C5V6. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Voltshift KiCad files?

From the gulshanshah/voltshift repository on GitHub, at the commit this page was made from: the board is pcb/voltshift.kicad_pcb and its schematic pcb/voltshift.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Voltshift design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).