ATtiny85 (Part 4)

Neil Haddley • October 23, 2026

Moving the ATtiny85 speed limiter from a breadboard to a soldered ElectroCookie mini prototype board, with screw terminal blocks for the bike's wires and a two-piece 3D printed case that snaps shut inside the bike frame, then building it and testing it on the bike

IOT3D printingattiny85e-bikeprototype-boardterminal-blocksopenscad

In Part 3 the ATtiny85 cuts the motor above 25 km/h by pulling the brake line LOW, and the circuit lives on a solderless breadboard in the frame bag. A breadboard was the right tool for trying ideas. I would rather have a soldered board for the bike, so in this post I make the move, and I print a case that squeezes into the bike frame.

I moved the circuit to an ElectroCookie Mini PCB Prototype Board, a solderable board with gold-plated holes, and I used Aribrnten 2.54 mm PCB mount terminal blocks for the bike's wires. They come in a pack of 50, in 2, 3 and 4 poles, and the listing rates them at 150 V and 6 A.

What has to move

The final circuit from Part 3 has only five parts:

  • The ATtiny85, which I plug into an 8-pin socket. I used a socket adapter from a 66-piece kit of soldering-type DIP IC sockets with a 2.54 mm grid, in sizes from 6 to 28 pins. The socket makes the chip easy to remove and replace, and it means that I never heat the chip itself when I solder to the board
  • A 1 kΩ resistor between the speed wire and pin 7 (PB2)
  • A 220 Ω resistor between the brake wire and pin 3 (PB4)
  • A 100 nF capacitor and a 10 µF capacitor, marked 104 and 106, that decouple the supply between pin 8 (Vcc) and ground
  • Optionally, a second 100 nF capacitor between pin 7 and ground, which filters short spikes on the speed wire. The breadboard circuit in Part 3 worked without it, so I leave it off the board in this build.

Six wires from the bike connect to it: the hub connector's red wire (+5 V) and black wire (ground), the two halves of the white speed wire, and the two brake wires, one that reads 5 V and one that reads 0 V.

The board

The board is a quarter-size breadboard that is meant for soldering. It is double-sided and gold plated to prevent oxidation, and the product drawing gives these sizes:

Size
Board1.5 × 2 inches (38.1 × 50.8 mm)
Holes17 rows, in two blocks of five columns (A to E and F to J), with a channel between them
Hole size1.2 mm through holes, on a 0.1 inch (2.54 mm) pitch
M2 mounting holes (Ø2.2 mm)Four, in the corners, 31.8 mm apart across and 44.5 mm apart along the board
M3 mounting holes (Ø3.2 mm)Two, in the channel between the columns, 40.6 mm apart

The view of the underside shows that the five holes of each half-row are joined by a strip, as they are on a breadboard. I checked the strips by eye before I soldered, and they were all good.

The gap between column E and column F is the same as the gap on a breadboard, so an ATtiny85 can straddle the channel: pins 1 to 4 go in column E, and pins 8 to 5 go in column F. Every pin then has four free holes on its own strip, as it would on a breadboard.

No separate + and − rails

A breadboard usually has a pair of power rails along its edges. I connect 5 V and ground to them once, and then I can take either one from any hole beside them. This board does not have separate + and − rails, so I have to make the 5 V and ground connections myself, with solder and short wires.

Ground matters most here, because several things share it. Pin 4 sits on a strip with four other holes, and four more things need ground.

Terminal blocks for the bike's wires

Each terminal block has pins on a 2.54 mm (0.1 inch) pitch, the same spacing as the holes on the board, and the pack is a mixture of green blocks with 2, 3 and 4 poles. I used one 2-pole block and one 4-pole block to attach the bike's wires to the board:

BlockPoleConnects to
2P, power1+5 V, from the hub connector's red wire
2P, power2Ground, from the hub connector's black wire
4P, speed and brake1Red brake wire, which reads 5 V
4P, speed and brake2Yellow speed wire, motor side
4P, speed and brake3Green speed wire, controller side
4P, speed and brake4Black brake wire, which reads 0 V, to ground

As in Part 3, I mark the motor half of the white speed wire yellow and the controller half green, and I leave the two brake wires red and black.

On the board, the same connections give these nets:

NetWhat is on it
5 VPower pole 1, chip pin 8, and one side of each supply capacitor
GroundPower pole 2, speed and brake pole 4, chip pin 4, and the other side of each capacitor
SpeedThe yellow and green poles (2 and 3) joined together, and the 1 kΩ resistor to chip pin 7
BrakeThe red brake pole (1), and the 220 Ω resistor to chip pin 3
Under the hood: Why the yellow and green poles are joined

In Part 3 I simplified the design so that the two halves of the white wire join again, and the chip only listens to the speed. On the board, that join is a short wire or a solder bridge between the strips of the yellow and green poles of the 4P block. The controller and the display get the speed straight from the motor, as they did before I touched the bike, and the 1 kΩ resistor takes a copy of the signal to the chip's input.

Under the hood: What the product drawing says about the blocks

The seller's drawing gives the sizes that the board and the case depend on. The listing also says 150 V and 6 A.

Size
Length of a block with P polesP × 2.54 + 0.4 mm, so 10.56 mm for 4P and 5.48 mm for 2P
Height above the board8.80 mm
Depth6.30 mm in all: the pins are 3.0 mm from the back face and 3.3 mm from the wire entry face
Pins0.8 × 0.5 mm, 3.5 mm long below the body, with a 1.3 mm hole recommended

My board's holes are 1.2 mm, and the diagonal of a 0.8 × 0.5 mm pin is about 0.94 mm, so the pins should go in. With a 1.6 mm board, about 1.9 mm of each pin comes out of the underside, and the 3 mm of space under the board in the case is enough for it and its solder. The screws are on top, and the wire goes in from the side, which is why the lid has slots and the long walls have notches.

The component layout

Here is the circuit laid out on the board. The white board, its gold holes, and the letters and numbers match the ElectroCookie board, and the green blocks are the Aribrnten terminal blocks.

The component layout on the ElectroCookie mini prototype board, seen from above, with the 4P terminal block in column A and the 2P block in column JScroll sideways, or tap the diagram to open it full size

The component layout on the ElectroCookie mini prototype board, seen from above, with the 4P terminal block in column A and the 2P block in column J

Here is the same board seen from below, where I solder. Column A is now on the right, and the gold bars are the strips that join each half-row of five holes. The only wire on this side is the yellow bridge between D15 and C16. I put it there, and not at the poles, so that each pad has room around it.

The same layout seen from below, with each soldered joint marked and the bridge under the boardScroll sideways, or tap the diagram to open it full size

The same layout seen from below, with each soldered joint marked and the bridge under the board

I spread the parts out on purpose, so that I can solder each joint without touching the next one. The chip sits in rows 7 to 10, the brake resistor runs down the left side, and the two supply capacitors stand at the top right with a ground rail of their own in row 5. Rows 1 to 4 are empty, and no wire goes near either M3 hole. No two wires cross, and no wire passes over another joint. Almost every pair of joints on different strips is at least 3.6 mm apart, which is one hole diagonally. The one exception is the lower lead of the 100 nF capacitor at J7 and the end of the speed wire at J8, which sit in neighbouring holes, 2.54 mm apart, so I soldered those two with care. Joints on the same strip can sit side by side, because they are the same connection. I used the solid 22 AWG wires from my TUOFENG kit for the short links, in red for 5 V, black for ground and yellow for the speed signal. The number 22 is the American Wire Gauge size, and it means a copper conductor about 0.64 mm across, with a cross-section of about 0.33 mm². The PVC insulation takes the whole wire to 1.55 mm, so the bare conductor fits the board's 1.2 mm holes, and the insulation does not. The kit is TUOFENG hook-up wire, 22 gauge solid-core tinned copper with PVC insulation, in six colours with 9 m (30 ft) of each. Solid core suits the board, because the board is held still in the case and vibration will not be an issue. All of my capacitors are ceramic, so they have no polarity and can go in either way round. I left the optional 100 nF filter on the speed wire off the board, because the breadboard circuit in Part 3 worked without it.

Every part sits in the holes in this table, and each hole belongs to a strip, so the strips make the connections that a breadboard would make:

PartHoles
8-pin socket, with the ATtiny85 plugged inpins 1 to 4 in E7 to E10, and pins 8 to 5 in F7 to F10
4P terminal blockA14 red (brake wire that reads 5 V), A15 yellow (to the motor), A16 green (to the controller), A17 black (brake wire that reads 0 V)
2P terminal blockJ16 +5 V (red wire), J17 ground (black wire)
220 Ω resistorA9 to C14
1 kΩ resistorE15 to F15
10 µF ceramic capacitor, marked 106H7 to H5
100 nF ceramic capacitor, marked 104, for the supplyJ7 to J5
Ground wiresA5 to C10, D10 to D17, C5 to F5, and G17 to G5
5 V wireH16 to I7
Speed wireI15 to J8
Solder bridge under the boardD15 to C16, which joins the strips of the yellow and green poles

The markings on the two capacitors are three-digit codes. The first two digits are the value in picofarads, and the third is the number of zeros that follow. So 104 is 10 followed by four zeros, which is 100,000 pF or 100 nF, and 106 is 10 followed by six zeros, which is 10,000,000 pF or 10 µF.

Under the hood: Why the chip is in rows 7 to 10

The terminal block poles take rows 14 to 17 in column A. If the chip's left-hand pins were in any of those rows, they would share a strip with a pole and join the bike's wire to the chip by accident. Putting the chip in rows 7 to 10 keeps the chip's strips and the poles' strips apart. Each of the six nets also has its own strips, and the chip's unused pins, 1, 2, 5 and 6, sit on strips that nothing else uses.

Soldering order, because I am not good at soldering

I am not good at soldering, so I have chosen the order and the habits that give me the most room for mistakes. The ElectroCookie pack has six boards, so I could have practised on a spare one first. I did not need to, because the first board worked.

For each joint, I followed the same steps:

  1. Tin the tip of the iron, at about 330 to 350 °C.
  2. Touch the pad and the lead together for about two seconds.
  3. Feed in a little solder for about two seconds, so that it flows into the hole.
  4. Take away the solder first, and then the iron, and keep still for three seconds.
  5. Look for a small, shiny cone. A dull, lumpy joint gets reheated.
  6. Snip the lead flush once the joint has cooled.

I followed this order, and starting with the small components first was genius.

A 3D printed case

The board also needs a case, and the finished, printed box goes into the bike frame. The case has to do four things:

  • hold the board and its two terminal blocks;
  • have holes so that I can reach the terminal screws and feed the wires in;
  • come in two pieces that snap together once the wires are secured;
  • be small enough for the gap in the frame.

I model it in OpenSCAD with named parameters, in the same way as the parts in my 3D printing post, so that I can change the size to suit the space. Here is the first version:

The first version of the case, drawn in OpenSCAD: the base on the left and the lid on the right, upside down as it would print

The first version of the case, drawn in OpenSCAD: the base on the left and the lid on the right, upside down as it would print

The same case closed, with the lid in place

The same case closed, with the lid in place

Here is a preview of the finished item, with the lid beside the base. This picture is drawn from the same list of holes as the layout diagram above, so the parts are where the table puts them.

A preview of the finished item with the lid beside the base: the board in the base, the chip in the middle, the terminal blocks at the left and right edges, and the bike's wires leaving through the notches in the long walls

A preview of the finished item with the lid beside the base: the board in the base, the chip in the middle, the terminal blocks at the left and right edges, and the bike's wires leaving through the notches in the long walls

I also saved the same model as lid-off.glb and scene.gltf, which open in most 3D viewers.

The design has these parts:

  • Feet: the board rests on feet in the base, so that the solder tails have room underneath. The two feet under the M3 holes are solid, with a hole that I can tap.
  • Wire notches: a notch in each long wall, level with each block, is open at the top. I can tighten the wires first, and then the lid closes the notch over them.
  • Screwdriver slots: the lid has a slot above each block, along its poles.
  • Snap tabs: two flexible tabs on the lid click into pockets in the long walls of the base.

With the sizes in the file today, the closed case is 44.9 × 55 × 17.6 mm. The height comes from the 8.8 mm terminal blocks, plus the space under the board and the lid. I have assumed that the 10 µF capacitor is no taller than the blocks, or that it lies flat, and that the board is 1.6 mm thick, which its drawing does not give.

Download the case files

These are the files that I printed, on a Bambu Lab P1S printer with Bambu PLA in black and red, and the first version worked. The case fits my bike frame easily, and the lid closes over the real board. Your frame is not the same as mine, so measure the gap in your frame, and the thickness of your board, before you print. The terminal block and board sizes come from the product drawings. The STL files are in printing orientation, with the base standing in its tray and the lid on its back.

PartFileNotes
Basecase_base.stlFeet for the board, tapped M3 posts, wire notches, and pockets for the snap tabs.
Lidcase_lid.stlScrewdriver slots over the terminal blocks, and two snap tabs. Print it flat on its plate.
Sourcecase.scadThe OpenSCAD model. Change the values marked CHECK, such as the board thickness, and export again.

The size of the case follows from those values, so a change to a block or board size changes the outside size.

The assembled board

Here is the board assembled, in its red case with the lid off.

I soldered the parts to the board and fitted it in the case: the chip in the middle, the 4-pole terminal block at the bottom left, the 2-pole block at the bottom right, and the red and yellow wires standing on the right-hand side

I soldered the parts to the board and fitted it in the case: the chip in the middle, the 4-pole terminal block at the bottom left, the 2-pole block at the bottom right, and the red and yellow wires standing on the right-hand side

It follows the layout above, with one small change. I mounted the yellow bridge wire on top of the board, where the layout has it underneath, because I found that easier. The terminal blocks stand along the two long edges, the chip sits in the middle rows, and the black wires carry ground between the strips. The two resistors lie close to the board, and the two capacitors stand at the top.

The case fits the frame easily. It goes in the space at the top of the frame, above the battery.

To connect it to the bike, I opened up the cable between the controller and the hub motor. I tapped a red wire into the 5 V wire and a black wire into the ground wire, and I cut the white speed wire in half and joined a white wire to each cut end. The other ends of these four wires go into the terminal blocks on the board. They are 24 AWG stranded silicone wire from a hook-up wire kit with six colours, 30 ft spools, and a 300 V rating. A 24 AWG conductor is about 0.51 mm across, a little thinner than the 22 gauge solid core on the board. The stranded wire is flexible, so it suits the run from the bike's cable to the board, and the solid core stays on the board.

I also bought two cables on eBay to make the connections:

  • a waterproof 6 mm M6 e-bike splitter cable with one female connector and two male connectors, which the listing sells in 2, 3 and 5 pin versions. I plugged it into the join in the bike's brake cable;
  • a 1 m waterproof brake cable with a 6 mm M6 2-pin female Julet connector at one end and bare wires at the other. It plugs into the splitter. Its two bare wires, one red and one black, go into the red and black poles of the 4-pole terminal block, exactly as planned.

The bike's brake cable comes apart at a connector, so I did not have to cut it. The splitter keeps the brake lever and the controller connected, and the extra connector carries the brake signal to the board.

I programmed the ATtiny85 before I plugged it into the socket on the board.

I have tested it on the bike. The motor cuts out at 25 km/h, as it did in Part 3, and it works great.