Skip to content

Hardware Design

jbaumann edited this page Aug 13, 2019 · 19 revisions

The Schematic

The schematic is pretty simple. We use an ATTiny (either 45 or 85, whichever costs less) as the brains of our system. As a side note: It is actually quite impressive what you can press into the small memory of an ATTiny45.

We have the header H1 connecting to the Raspberry, the header H2 that allows us to connect the battery, switch, external voltage and button, and we have P1 that allows us to choose between the RPi voltage and the external connector. Interestingly, in earlier revisions I used a simple 2-pin header that simply cut the connection to the RPi. By using a 3-pin header instead we have a simple mechanical means to guarantee that only one voltage can be fed to the ATTiny and furthermore, that no excessive current can be drawn by e.g. connecting the EXT_V pin to ground while having the jumper connected.

Normally, we would add I2C pull-up resistors (with a typical value of 2k2) to the schematic, but the Raspberry already provides 1k8 pull-up resistors, and the Geekworm UPS HAT has 2k2 resistors as well, leading to an overall pull-up resistance of 990 Ohm. This leads to a current of 3.3mA. If you want to reduce this unnecessary power draw you could simply desolder R2 and R6.

To guarantee that no current can be fed back to the RPi we use a diode, and additionally we add a voltage divider that on one hand allows us to safely measure any voltage for which we choose the right resistors, and on the other hand guarantees that the ATTiny won't be powered parasitically through its protection diodes.

An LED with a current-limiting resistor and a decoupling capacitor round the whole thing off.

One thing that might look a tad strange is the Reset pin on the header H2. Even though it might be nice to reset the ATTiny every now and then it doesn‘t really provide additional functionality. But: We can program the fuses of the ATTiny in a way that allows us to use the RESET pin as a normal input/output pin. The disadvantage is that if you do that, you need a high-voltage programmer to program it anew (i.e., to reset its fuses). This is no real problem because you can build such a programmer without problems on a breadboard, but it is cumbersome to develop for. Still, it is nice to have this as a possible extension on the hardware level.

Assembly on a Breadboard

Building the circuit on a breadboard is dead simple. Normally you do not need the capacitor, you do not need the headers, and thus you only have the ATTiny, a button, a resistor and the LED (ignoring the voltage divider). An example breadboard assembly is shown below (in fact this is the one that I used for most tests).

You can see the black and red wires for GND and V_Bat, respectively, the orange wire is the wire that switches the Geekworm UPS on and off, and the green and yellow wire are used for I2C (SDA and SCL).

The PCB

The basic idea here was to only use through-hole components so that beginners or persons with "not too steady" hands would be able to build it without problems. You can still have a surface-mounted LED if you want to, but you are not forced to (with the additional benefit of reduced height).

Two different versions of the PCB exist, one that covers only the four pins we need, the other covering the additional two power pins on the side of the RPi connector and offering a mounting hole for securing the PCB on top of the RPi.

The following top view of the two variants shows an overlap of the LED and P1 (the header used for the jumper), but the LED will be soldered on the bottom of the PCB, so there is no collision between the two. You can see that generally the components are packed tightly, even going so far as to place the capacitor inside the IC socket. But, if you want to solder your ATTiny directly (which I would strongly advise against), then simply solder the capacitor first from the bottom side.

The header H2 is also supposed to be soldered from the bottom side. If you examine the following bottom view on either of the variants you can see the the contacts are formed in a way that allow you to solder the header lying flat on the PCB, thus reducing the height.

The picture of the naked and the populated PCB (this is the old version v1.7) show the result (and yes, the header is a little bit lopsided, but it works fine):

And finally we have a view of the PCB (v1.7) installed on top of the Geekworm UPS HAT on a Raspberry Pi Zero W.