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)

OOOH HEY, these reclaimed cells are GOOD. 2700mAh capacity is more than I expected! This will give me an eight hundred watt-hour battery pack with a theoretical three hours ride time at full power.

Junkyard eBike build Part 7: Pack Assembly.

In our last build session we turned our recycled lithium cells into 10 banks each of eight cells in parallel. Today I've wired those 10 banks in series to achieve 40-odd volts of sparky goodness.

If you have the kind¹ of battery spot-welder with handheld electrodes, you can lay out the battery on your bench and weld the whole thing together in one pass (well two passes, you'll need to flip it over).

I don't have that, I have a benchtop² welder, which is a plus because it is very powerful and will weld all day without pause, but it means you have to bring the battery to it, which gets harder the bigger the battery gets.

So my build process is to make sub-assemblies and then join them together. I begin by joining three of my 8-cell banks together, making three 24-cell units, plus one 8-cell remainder, then joining those.

I wrap the components I want to weld in fibreglass tape, then take them to the welder. I pre-cut some double-row nickel strip to make the joins between banks, overlapping one row onto each adjacent bank.

The power will snake through the battery in a S-shape so remember to make your second bank the other way around.

¹ Handheld welder, commission link: https://s.click.aliexpress.com/e/_c3vBdXIl direct link https://www.aliexpress.com/item/1005008220521401.html

² Benchtop welder, commision link: https://s.click.aliexpress.com/e/_c4mTcxvx Direct link: https://www.aliexpress.com/item/1005009066552677.html

Junkyard ebike build part 7.2:

With all 10 banks placed side by side, I make sure that the junction between each bank has a tab where I can attach the "balancing wire" which the battery management system uses to shuffle charge around to make sure that each bank holds the same voltage (minor discrepancies are inevitable due to individual cells having minor differences in practical capacity).

At this point I number the contact points, starting with Zero at the negative terminal and ending with 10 at the positive terminal.

When I'm triply sure that all the cells are in the right place, I encircle the whole battery with a loop of tape, to allow me to pick it up and hold it under the welder.

To join the 24-cell modules I again use a 4-cell strip of 2-row nickel, meaning that four points from each bank participate in the joint.

With all 10 banks joined together I can measure the voltage across the whole battery. A shade under 42 volts (it's partially discharged).

Junkyard eBike build part 7.3:

With the electrons lined up into a big snake, and all the junction points identified, we want to protect the ends of the cells and the exposed nickel strip from being involved in a short circuit. Adhesive paper tape is used to cover over the cell ends leaving only the marked junction points visible.

In the next session we'll wire up the battery management system and build a sturdy box to hold the completed battery.

A reminder: you probably do not want to do this yourself, it is much more convenient and econommical to buy a pre-assembled battery, but now you know what's inside the box!

Junkyard e-bike build part 7.4 (coda): Remember to clean the bloodstains off the battery or you may get rust. Freshly cut nickel strip is heckin' sharp.

Junkyard e-bike part 8. Wiring up the battery. I'm a sick of this battery as you are, I'm sure.

The user manual for the battery management system¹ that I'm using tells me the order in which to connect the wires. It says connect the big wires first, then the balancing wires from the negative end up. This BMS can handle anywhere from 7 to 14 series banks, I'm using 10 banks, so the "top" 4 balance wires all go to the positive terminal.

¹ Affiliate link that will earn me a dollar on any sales: https://s.click.aliexpress.com/e/_c4EyWLed. Direct link https://www.aliexpress.com/item/1005006071626722.html

Junkyard e-bike part 8.2: Charging

I used a bluetooth scanner to confirm that the battery management system was online. Yay!

I connected a charger and observed its current display. Nothing. Not charging.

Hmmmn, let's get an app.

App thinks the battery is flat. Probably needs to be configured for number of cells. No obvious way to do that.

Try a different App "Xaio Xian Electrical" (name of manufacturer). Not as pretty, but it has a setting for cell count (10 cell-banks). Yay, now it says 100% full.

Connect charger and it says "temperature error". Hmmmn, this BMS has an internal temperature sensor and a socket for a second external one. Didn't come with one though. Fortunately, I buy one of everything from China so that you don't have to, and I have a packet of 10kΩ thermistors to hand.

After fitting the "optional" second temperature sensor, the battery now says "charging" when I connect the charger, and it pulls 8 amps (for about 30 seconds beforer reporting full and dropping to zero amps).

I connected a "dummy load" and the app reported that the battery was now discharging.

YAY, everything works!

Junkyard eBike part 8.3: The Box.

Bicycles (trust me on this one!) sometimes crash. So you want a sturdy box for your battery. Looking around the workshop I have a shitton of acrylic, and aluminium faced ABS, but no plain ABS or PVC sheet. Darnit. Acrylic is too brittle, and I'd rather not use a metal box (it *can* be done with care). I could make a plywood box, but hey, waitaminnit, there's some PVC pipe.

PVC has a "softening" temperature of 97℃, so a heat gun, or a pot of boiling water will soften a section of pipe so that you can roll it out flat. I cut some 90mm downpipe, and some 140mm pressure pipe, giving me some "thin" PVC sheet and some "heckin' thick" PVC sheet.

I'm going to use the thick stuff for the bottom and ends, and the thin stuff for the sides. But I'm out of time for today¹ so we'll resume in part nine.

Why didn't I 3D print a box? That'd take ages (and it would ruin the junkyard aesthetic) even though I do have a 400x400x400 printer.

¹ customer jobs, and all, doncha know. Today I made a drive shaft for an electric tractor, prototyped a solar e-bike charger, and added swipe-gestures to the firmware for a wifi Geiger counter.

@Unixbigot Soundtrack suggestion for when you continue

https://www.youtube.com/watch?v=qddG0iUSax4

Orbital The Box Full Official Video with Credits

YouTube
@Unixbigot
Remember to wear a mask when working with hot PVC, it can release some extremely noxious fumes.
@Unixbigot I have to admit my first thought was 3DP in ABS, but my braincell is obsessed with printing
@minxdragon I tend to think that "huge areas of flat panels" are not the forté of 3D printers especially in that thrice-damned curly ABS, however one thing that I *do* like to do is print the *corners* into which sheet materials can slot. Mayhap I will do a demo of that today.

@minxdragon Ah, I found my scad program for generating corner pieces that attach to flat sheet sides:

ETA: this is a much faster way to make a rectilinear box than printing the whole thing (assuming you have sheet metal, plastic or wood to make the sides)

Junkyard #ebike build Part 9: BOX RETHINK

Three things:
* I can't find my fine-tip heat gun that I use for plastic welding
* This recycled PVC is way too wavey to be used without welding it immobile
* Since writing "why I don't just 3D print?" in last part, I remembered that I ALREADY SOLVED THIS for a client prototype, by designing 3D printed box-corners that print fast, combinning with sheet material for the panels.

Here are my abandoned #solarpunk box ideas:

Junkyard #ebike build 9.2:

I found some manky plastic panel (some kind of acrylic, but thick enough that I 'm not concerned over brittleness) in the attic. It's so old that the paper coating won't come off (soaking in hot water as I type). The 3D printed brackets are intended to interface with side panels that have a rebate cut on them, which I did with a router table. Notched on a bandsaw, the box fits together snugly (and will have foam padding on the inside).

This #solarpunk box made from ugly recycled plastic will next get the brown paper coating removed painted a nice coat of paint.

Junkyard #ebike build 9.3: box is together.

It turns out that the battery *just* fits into the box via the top, if I wedge the big end in first and skew the circuit end a bit as I insert.

I pre-drilled and countersunk the top and bottom panels, then used them as a template to drill holes in the corner posts.

I used screws and nuts to secure the bottom of the box, and heat-set inserts on the top side. I wish I had made the part I'm screwing into quite. a bit thicker.

I'm going to make a gasket for top and bottom to seal the box, but I rounded the corners on the linisher and the box fits the bike just about perfectly. I'll use webbing straps to hold it on the cargo rack, I think.

Junkyard #eBike build part 10: IT'S RIDEABLE

Test ride done and I lived.

I happened to have an electric brake lever to hand so I fitted that in place of the stock one, but the stock ones can be hooked up as a switch on this bike by attaching the wires to two screws that make contact when the brake is released and disconnect when the brake lever is pulled.

I painted the battery box, added padding inside and on the carrier rack, ziptied up some wiring and used elastic straps to secure the box. I'll need to add another strap as the battery shifted in use.

I'll also add a weatherproof cover over the control box and plugs (you can buy zip-up-covers off the shelf, or just get jiggy with a PET bottle.

Junkyard #eBike Part 10.2: (coda) you don't technically need to fit a brake switch but if your throttle sticks or your lizard brain panics and retains a death grip on the handlebars, then activating the brake lever disables the motor. I will probably also connect the high/low speed selector, even though "medium" speed is perfect for me on this bike. The low speed mode is handy when passing through 10km/h zones like parts of the Brisbane city center. Oh, and I might add a key switch to the "anti theft" wires just to tempt you locksporters. The true anti-theft system is the pink handlebar basket (not yet fitted).

Junkyard #eBike Part 10.3: (appendix) This is the bracket I made for the motor controller.

The $15 motor controller is the only part of this whole build for which I paid money.

@Unixbigot hooray you didn’t die!
@jpm I should have used white Thermal Bandanges, uh, occy straps, to secure the battery box.

@Unixbigot

Will the rack manage the battery weight?

Back in the day, my rack eventually popped all its welds—I was regularly carrying a 7Ah SLA battery (almost 3kg 😱) on bumpy firetrails.

@thefathippy 4.7kg here. I'd hope the rack can handle that; shan't be riding down any mountains!
@Unixbigot I am a big fan of this enclosure idea (seeing folk 3d print panels and the like makes me twitch)
@Unixbigot this series of posts is kinda giving me the courage to learn how to work on batteries 
@felipe yay! punk all the solars!
@Unixbigot
Belated advice to wear gloves and eye protection.
@Unixbigot 1 and 3 being so close is giving me the heebie jeebies
@jpm “safety guard removed for photographic clarity” as the Americans lie.
@Unixbigot This is all incredibly informative. Thanks for posting this.
@Unixbigot That tester is really nice, where did you get it?

@astraleureka This¹² is the gadget I use to bulk charge/discharge/test lithium cells. It has sockets for 18650 cells plus screw terminals for other kinds of cell.

¹ referral link that will earn me a few bucks if you buy https://s.click.aliexpress.com/e/_mqpPQTP

² direct link: https://www.aliexpress.com/item/1005006756029574.html

18650 Lithium-Batterie-Kapazitätstester, DC-Anschluss, 2,4-Zoll-Farbbildschirm, digitales Batterieleistungsdetektormodul, DC5 V, 10 A, automatisch, C - AliExpress 1420

Smarter Shopping, Better Living! Aliexpress.com

aliexpress.

@Unixbigot @astraleureka Ah, hm, interesting. We're looking for something to safely discharge honking big cells (like 150 Ah or even larger), while not taking forever. Do you know the maximum discharge current of that thing? The technical specs on AliExpress are AI translated to German and just don't make sense.

(Safely discharge means discharge until lower cutoff voltage, which needs to be configurable.)

@HolgerPieta @astraleureka i’ll check, but what i think you want for your needs is a digital load. i have one model that is nominally 150w but has a variant firmware that, if you fit an improved heatsink, can dissipate 1kw. the one i’ll recommend has bluetooth and can be remote controlled/monitored.
DIY 1000 W 25 A 4-Draht DC Elektronische Last Kit Lithium 18650 Batterie Kapazität Analysator Tester mit Entladung Monitor PCB Board - AliExpress 1420

Smarter Shopping, Better Living! Aliexpress.com

aliexpress.
@Unixbigot Oh, thanks, that looks interesting. 150 W would be about 40 A at 4 V. That's more than we need. No need for additional hackery.
@HolgerPieta that device maxes out at 20A it’s not perfectly fungible
@Unixbigot Oh, right, it actually says so on the can. But that's still enough, discharge overnight is fine.
@HolgerPieta here’s one thats rated to 25A with the cooling already fitted https://s.click.aliexpress.com/e/_mqnda0v
150 W 25 A Batteriekapazität 4-Draht-Tester DC USB-Tester Elektronische Last Lithium-Entladung Monitor Netzteil Checker mit PC APP - AliExpress 1420

Smarter Shopping, Better Living! Aliexpress.com

aliexpress.

@Unixbigot there's something about lithium cells that I'm really curious about; what does the full capacity curve look like? Does it flatten out over time or does it just drop to zero?

I tried asking the search engines but only got corpo slop trying to sell me a battery system.

@beaumains i’m not sure i understand your question. If you mean “how does the measured capacity of a lithium battery change as it ages across many cycles”, by my measurements it’s a gradual decline, i have cells that now only measure half their original capacity but still deliver useful cycles
@Unixbigot so like, with PVs my understanding is that their output decreases significantly after a short period of use, however after a little while the rate of decrease slows and almost flattens out.
@beaumains I’m still not sure if you mean the discharge curve during a single discharge session, or the change in the curve across multiple sessions over hundreds of cycles. I can show you a real chart of the former easily. I don’t have data for the latter.
@Unixbigot the former, over the lifetime of the cell.
@Unixbigot you can also purchase ceramic-bladed cutters for a few dollars
@jpm oshit i have some. changing.
@Unixbigot there are no cutters, only Zuul

@Unixbigot it isn't crazy to setup to do the dissassembly somewhere that if a cell goes POOF it is less disasterous.

Even if that means you do it in a park with a metal bucket of sand (maybe from the sand pit) next to you.

If that is the plan, do remember to think of how the seperate cells will be transported home for reassembly (which has less but no zero chance of POOF, so still think about doing it somewhere flames and smoke matter less)

@Unixbigot should one cell going POOF burn your house down? No.

But it can if you do enough things wrong.