Sepic UPS Hat

Since the original Sepic UPS project a lot has changed with the raspberry pi model line up, many new models have been introduced with different current consumptions and a new standard hat format so the original Sepic UPS project which was done for the original model A & B raspberry pi needed a major overhaul.

The circuit shown below has some major improvements over the original

  • Available in a HAT format
  • Wider input voltage range 3.3V-40V
  • Output current up to 3A
  • Reverse diode protection included to avoid back powering of the HAT
  • Status Indicator LED’s for Output voltage, Input voltage and battery voltage
  • Read back of battery and input voltage via on board ADC
  • Automatic shutdown of raspberry pi when battery becomes to low

Power is supplied via J1 and it trickle charges the backup battery via D3 & R6, the maximum  charge rate is set by the input voltage and the battery stack and should be restricted to a <C/20 charge rate for safe charging. By default it is set to a value of 200 Ohms.

To calculate the charge rate

Charge Rate = (Vin(Max) – 0.3)-(Vbat(Min) / R6

For example for a 4AA 1000mAH pack and a 9V input the  maximum charge rate would be

Charge Rate = (9 -0.3)-(4*0.9)/200 = 25mA

For a 1000mAH pack it will be charging at C/40(which is >C/20) and should charge in around 40 hours.

Sepic UPS Rev 2 Schematic

Capacitor C1 & C2 are supplied from the diode OR circuit formed by D1 & D4, whichever is the higher of the input voltage or the battery. This ensures that when the input voltage fails the battery voltage is automatically supplied giving no switchover time to the battery backup.

The Sepic converter based around the LM3478 controller IC then ensures that this input voltage is regulated to a 5V output from an input voltage from 4V-40V input.

Current limit protection and Reverse diode protection is provided by the circuit around U2 & Q2. This prevents the raspberry pi back powering the hat board

Both the input voltage and battery voltage are monitored via the MCP3202 ADC via the potential dividers formed by R12-R15

How long does the Back up Last ?

Running tests on a raspberry Pi model B + with various battery packs gave the following results. The Raspberry pi was powering a hub with keyboard and mouse and a Wifi adapter during this test, the device was put into shutdown when the voltage reached 1V per cell

Number of NiMH Cells        Time to shutdown
4                                            2h22
6                                            5h21
8                                            5h24
10                                          8h58

Tests where also run with a raspberry Pi zero in a completely headless configuration (i.e) the hub was removed, again with the threshold to shutdown set at 1V per cell.

Number of NiMH Cells        Time to Shutdown
4                                          18h43
6                                          23h15
8                                          29h47
10                                        39h56


The software is written in python and can be downloaded here


It runs from the command line and shows the current input voltage and battery voltage state, also the threshold that the device goes into shutdown can be set by changing the battery threshold variable in the software enabling it to be easily modified for different battery packs.

When the input voltage is removed the UPS powers itself from the battery and  the software indicates that it is in backup mode

When the battery voltage decays below the battery threshold voltage then the software automatically halts the raspberry pi by issuing a sudo halt command.


The project is laid out on a dual layer PCB in a Hat format as shown below

This project is suitable for the raspberry pi’s with the 40 pin connector below

The bill of materials for this project is

—  ———           —–
1    R1                  0.025
1    R2                  60K
1    R3                  20k
1    R4                  40k
1    R5                  4.7K
1    R6                  200
4    R7,R13,R15,R16      10k
1    R8                  47k
3    R9-R11              270
2    R12,R14             90K

8    C1-C4,C8-C11        22uF
3    C5-C7               100nF

Integrated Circuits
1    U1                  LM3478
1    U2
1    U3                  MCP3202

1    Q1                  IRF7811AV
1    Q2                  IRLML6401TR

3    D1,D2,D4            MBRS540
1    D3                  DIODE-SC
3    D5-D7               LED

1    CN1                 DCJACK
1    J1                  TBLOCK-I2
1    J2                  CONN-DIL40
2    J3,J4               CONN-SIL2
2    L1,L2               SDR1307-100ML
8    TP1-TP6,TP9,TP10    VEROPIN