Let's make an #ebike out of garbage. You will need.

* One dumpster bike (free)
* One cargo rack (free)
* One hub motor (dumpster dived, but about $200 new)
* One motor controller (about $20-$50 new)
* A battery (recycled, but about $100 new)

I'm going to rewire some used 12v lithium batteries to make a 36v battery with a smart battery management system (monitor charge from your phone).

I started by installing the front wheel, installing the cargo rack, mocking up where I'll mount the battery, controller and throttle.

Next I'll wire the key components, get the wheel turning, then look at which of the other wires need to be connected. (Some brake cutoffs, pedal sensor, maybe a key lock to see if a wild @alice appears).

This happens to be a folding bike, because that's what was at the front of the bike pile.

Ookay, part 2 of "dumpster e-bike", getting the motor running.

First, make sure you have the wheel the right way around. That's probably power cable on the right hand side. A hub motor has a clutch inside and only motorises one way.

Invert the bike, then hook up the three motor wires to the motor, connect the 5-wire hall sensor plug if you have one, and then join the "self learning" wire. Connect the battery and the wheel should turn slowly. Give it ten seconds or so, then power down.

Disconnect the "self learn" wires, and add a throttle. Reconnect the battery. Give the throttle a gentle turn (I've used a potentiometer for initial testing as then I don't have to fight against a spring). The motor should turn.

Spin your pedals and observe the back wheel. If the front wheel is turning the wrong way, swap any two of the motor wires and it should go the other way. Try another two wires if not.

Arguably, your bike is now rideable. But don't.

Things left to do are

* Mount the battery securely
* Mount the motor controller securely in a weatherproof cover (you can buy zip-up pouches for this purpose)
* Fit some brake cut-out switches
* Look through all the other wires on the motor controller and see if any of them look like fun.
* Maybe fit a speedometer.

Here's the motor running. Super quiet, the ventilation fan in the roof is louder.

This is my "daily driver" e-bike. Purchased for $200 as "battery does not charge", the battery was fine, but the controller was blown. The bike is so old it was clearly designed for lead batteries, the the lithium battery only fills one third of the otherwise empty battery. box. I ripped off all the plastic fairings, and sourced a new controller and throttle as a set. I fitted an anti-theft handlebar basket (should be a pink one for maximum effectiveness) and it just goes.

Electronics: https://s.click.aliexpress.com/e/_c2QulvH3 or https://www.aliexpress.com/item/1005008500641642.html
Waterproof cover for electronics: https://www.aliexpress.com/item/1005005475025309.html

Junkyard e-bike build part three: I have dozens of these 12-volt lithium batteries which were previously lightly used in solar lighting installations. I used three of them to test-run the 36 volt e-bike motor yesterday. Two of them fit nicely on the cargo rack, but that would only be 24 volt. So I am going to cut up two of these 12v 50Ah¹ 3S15P batteries (three banks of cells, each bank 15 cells in parallel), and use the 90 individual cells to make a 10S8P battery (36 volt, 25 Ah) that fits the rack space neatly and also has a modern smart battery management system with bluetooth connectivity.

The existing battery management boards in these batteries appear to be simple "overcurrent protection and rebalancing" modules, I'll be discarding those.

¹ All labeled battery capacity figures are lies unless proven otherwise.

Junkyard e-Bike build part 4: Reconfiguring a salvaged battery. Lithium batteries can be scary. The "negative" terminal is the flat end, and the entire outside of the case. The positive terminal is the small circle on the top. DO NOT USE METAL PRY TOOLS. It is easy to pierce the thin shrink-wrap coating of the cells and connect positive to negative. Do this and you will get sparks and/or fire. Explosion is unlikely due to the nature of cylindrical cells. Use a plastic or wooden spudger to open up space between the battery and any nickel bus-strips you need to cut.

Here I am using bamboo tweezers to allow me to safely (ish) cut the nickel strip.

The shrink wrap cracked during separation (again done with a non-conductive spudger) so these cells will need to be re-wrapped. At this point I am thinking that recycling these batteries is too much work for someone who doesn't already have all the safety wrapping materials to hand.

You can buy new or refurbished cells with intact safety coatings; for example from recyclers like Substation 33 in brisbane, and various local e-bay sellers.

For recycled cells, the welded nickel strip can be removed by grasping the loose end with some needle-nose jewelers pliers and winding the strip around the pliers.

Junkyard e-bike build part 5: switched to ceramic scissors for cutting the nickel. Used a heat gun to soften the adhesive on the barley paper to remove it. Inspected the cells, removed strip from any that are not well attached, started replacing missing insulation.

Junkyard e-bike build part 6 (this one will be across several smaller posts)

Now that our donor batteries have been cut up, lets re-wrap the cells and group them into 10 banks of eight cells each.

The donor battery was three banks of 15, so I preserved groups of eight, six and two
where I could, and ended up with over a dozen single cells where the wrapping or nickel strip was too degraded.

I pre-cut a number of 70mm lengths of single-cell shrinkwrap, to renew the naked cells. The entire metal case is the negative (cathode) terminal, except for the anode nipple on top. The critical thing to remember is to prevent any contact between the positive and negative wiring.

(Junkyard ebike part six, post two)

The key thing to avoid with lithium cells is shorting the anode (the nipple on top) to any part of the rest of the cell casing (which is all the cathode). A plastic cover and a paper washer are part of the protection regime.

(Junkyard ebike part six, post three)

For shrink-wrapping lithium-ion cells, I use a variable-temperature and variable-speed heat gun. You want the air JUST hot enough to shrink the wrap, and you want to minimise time in the air flow. It's not such a problem with single cells, but when wrapping large items the wrap can split if overheated.

(Junkyard ebike, part six, post four)

The knack to heat-shrinking batteries is to get the item nicely centered in the wrap and then briefly wave it into a stream of hot air. You want the air just hot enough to shrink the plastic, and avoid over-heating as the wrap may split.

(Junkyard e-bike, part six post five)

Once your cells are wrapped, a thick paper washer is added to the positive end. The goal of all this covering is to avoid the positive "nipple" being short circuited to the negative casing.

(Junkyard e-bike part six post five)

With all the cells re-wrapped we can start thinking about how to put the battery together.

Our battery will consist of ten banks in series, each of eight cells in parallel (10S8P).

Why are there ten banks? Well a lithium-ion cell is "nominally" 3.7 volts, so the usual "12 volt" arrangement of three banks is actually only 11.1 volts. Using ten banks gives us a nominal voltage of 37 volts, which will actually be 42 volts when fully charged, and around 33 volts when flat.

One complication of working with lithium batteries is that they have a wider gap between "full voltage" and "minimum voltage" than many other kinds of batteries.

Since I had ten single cells left over, I loaded 8 of them into my capacity tester to see what actual capacity these cells have. Around 2000mAh per cell is typical, but budget batteries can often be low-capacity factory-seconds being sold with ludicrously inflated capacity labeling.

(end of part six)

@Unixbigot 2000 mAh? That's very nearly 2Ah. Indeed, so close that you might as well call it 2Ah.
@MikeH ah but more zeroes means bigger number!
@Unixbigot Heavier, certainly.