Been a while since I posted here, but being home a few days with a not so serious cold does wonders for maintenance around the house.

So the time had come to assemble the ebike kit. Since I already had an older working set I decided I would evaluate this kit before switching over.

As some of you ebike freaks may know, legal requirements in most of Europe requires you to have a so called pedelec sensor which only allows the motor to run when the bike is being pedaled, thus amplifying the force provided by the legs.

Weirdly enough this is not the case for those pesky rentable electric scooters. Would it suffice if I removed my pedals? What is the original idea here? That dead people are not allowed to cruise on electrical vehicles unless they are mopeds? How often do people actually die on bikes provided they don’t have a proper accident? Is all this an EU conspiracy to protect the inner market? Oh well.

Anyway this kit came with a wheel that I nicely replaced the old one with, nothing a clumsy idiot couldn’t handle with a fat adjustable wrench . The household pluming one went admirably. The nuts where upgraded from 18mm to 20mm and my fixed wrench set went up to 19 only.

After some messing around with the wiring, this kit was actually quite Poka-Joke no connectors would fit in the wrong place. So with the handlebar installed I could make a few turns back and forth in the garden and now came the time for … The Pedelec!

Ok, I know some bike freaks probably stop every two miles or so to change their pedals for less air friction with respect to terrain or so, but growing up in the 70s they where somewhat like the axis of the earth, not to be removed. On the other hand they where made to last forever, I finally managed to break a pedal on one of those 40+ yo contraptions and out of curiosity got a vintage spare and managed to get it on for another 40 years of enjoyment, but the obviously inferior construction of the cheap pedelec I got with the kit made me wonder how long till the next pedal arm pull since I would obviously wreck that little plastic ring of magnets quite easily just by kicking around some.

To add to this heap of trouble there seems to be a few different pedal solutions. The simplest one would be where you’d remove the pedal arm and then lock this little metal ring glass jar lid style.

Mine however was not of that type so the ring for the sensor could not be screwed on just like that.

Youtube, however was not lacking for solutions:

“And then you take a plastic cup from some hair product on your moms bathroom shelf and use some rubbing alcohol leftover from covid, sandpaper and a clamp plus metal epoxy, oh and you’d have to remove the pedal stuff on the gear side as well, glue takes 24 hours to set…”

or:

“First you take two hose clamps and wrap the sensor like this and bla bla then you can either buy this dividable magnet ring or use a hack saw and some more glue to glue it on and more bla bla”

Seeing as this kind of bicycle gear is the type that breaks all the time but what the heck you just smack on a new 10 euro thingy in 10 minutes this seems like a little to much trouble to go through every time crap brakes, turning me into a glue head in no time.

Some fast googling also confirmed this, the net was full of broken ebike dreams and broken pedelecs complete with “my mom with disabilities” sob stories.

My mind went wandering as I though, “In this day of sensors, glory and bluetooth, would it not be possible to make a wireless sensor that neither weights a ton nor costs a ton of money?”

So this is where the hack began, first I wanted to evaluate the signal coming out of the sensor. Meet the drill contraption. Sensor was screwed to some wood and then the hex to half-inch adapter would fit perfectly into the plastic magnet ring, just some more wood to hold the drill down and since it had reverse I would not have to worry about direction. Now just hookup the whole thing: wheel, sink and bait and turn the drill. The magnet ring even came with some arrows to indicate direction. So nothing happened and I tried going against the arrows and voila the wheel spun! Later I realized both that the sensor was rotation direction sensitive and that mounting the ring on the side made me get the signal up-side-down. (Stranger Things have happened :-D )

Now came to the stage of learning what signal this thing was delivering. At this stage in time I thought it would be some DC signal telling the controller that “the lazy ol’ bastard is still pedaling and has not suffered cardiac arrest”, but to my surprise the “DC” signal measured from the green wire to earth (black!) would change from about 1.7 volts to about 3 volts depending on direction. Turning the wheel slowly and watching the multimeter made it kind of obvious. The magnet passing the sensor would make the signal go high, somewhere at 4.3 volts. What was not so obvious was that the duty cycle would go at about 66% when pedaling forward and only 33% going backwards. I later learned that some controllers came with a brake light so this might be the reason. How this duty cycle change is detected is still a magic mystery but I left it at that. So having a spec of the signal it was time to scavenge the toy box. Had been playing with low energy bluetooth (BLE) before so I had some NRF52 Adafruit thingy floating around, simple to hookup to an arduino capable computer. I also had a bunch of so called “cadence sensors”. If you are a training freak you might recognize this as a small pill you can either duct tape on to the pedal arm or simply stuff down your sock. I got two kinds. the “Wahoo” available at a lot of geek stores and also the cheaper “Magene” type. An example sketch came with the NRF52 (this is the receiver) and making some silly waiving with the Magene in thin air I got the NRF52 to register the amount of turns done outputting some geeky hex code.

Then, instead of powering the NRF52 from the usb of my laptop I connected its “3v” and “gnd” to a volt cube (3.3v) and measured its current draw at under 10 mA. I then did some ohms-lawing and decided that this corresponded to a resistor of about 330 ohms. I needed to find out if the controller would be able to power the NRF52 directly so taking volt measures from the sensor at idle (between red and black) then I simply stuffed the 330 resistor in the holes and watched the voltage sink from 4.3 to about 4.25. This would probably work.

NRF52 is NOT 5v tolerant!

So the proper solution would be to at least have a 3.3 volt zener and some resistor (using a voltage regulator seemed like overkill at 10 milliamps) but lacking zen I went for a diode in series reducing voltage to about 3.6v. If you have more close to 5 volts at your sensor, two diodes in series might be a good idea.

So there would be inalles three wires going from the NRF52, the “3v” going (via diode) to the red (middle!) pin of the connector, the “gnd” going to black and finally I decided to take the green signal as an output called “7” on the NRF52.

Adding some code to the sketch that would generate a pattern of “1”, “1”, “0” repeatedly as soon as a “spin” was detected on the Magene and then if no spin was detected for 3 seconds end the pattern generation it was time for another test.

At the time I did not have the proper male connector for the pedelec sensor, but a simple 0.1” pin header of three would do the trick. If the control box has some other connector one could of course use toothpicks, chopsticks, direct soldering, vampires or something. Anything goes.

Much to my surprise this worked almost instantly, ok I did send the signal to the LED and sat comfortably at my desk waiving the Magene and debugging the code first. Its amazing how Zen it can feel to wave your hand at the computer and having it respond. Hiding the pill box in your hand also makes for a funny party trick, seemingly the computer only listens to your hand waving…

So now duct taping the Magene to the pedal arm and connecting this NRF52 thing I took a test ride. It worked quite well even though the bike was a little slow to respond to pedaling. I think this is by design since we want to avoid false triggers and sudden bike-jumps in intersections and such. I tried to set the timeout lower than 3 seconds but found it hard to keep the pedaling and thus the motor alive with lower timeouts. Before you get accustomed to it, motor driving for some extra seconds after pedaling stops can be a bit nerve wrecking until you learn to use the switches coming with the kits break handles.

If I where to send a message to legislators and manufacturers I would suggest that the throttle handle bar be used for the motor control and the pedelec only has an on/off function detecting the sudden death of the rider or for whatever other reason this idea came to fruition in the mist of the EU. Also it would be nice to clarify why the scooter riders have the privilege of riding dead on their scooters until the battery wears off, whilst ebike:ists are not. Manufacturers could probably also make a wireless sensor which will give more than one impulse per revolution. Another possibility would be to allow for a speed of, say, 7 km/h from a handle bar without deploying the pedelec since this would increase traffic security when starting from a stand still. Also especially senior citizens seem to appreciate this start push, extending their life as bicyclists.

The informed reader might also notice that the Board depicted is in fact not the NRF52 from Adafruit. Yes, I also tried a more “raw” board available from a few suppliers at lower price. The cons would be you need to solder in more wires and also that board does not come with a pre-installed boot loader such as the Adafruit board and thus you also need a J-link device or similar.

If you like this idea and have a dead ebike in the shed you might want to try this, but please note that the 66% duty cycle is probably not a universal signal for all ebikes so software mods might be needed. The obvious problem here being that in order to take measurements one would need a working ebike...

Future enhancements:

I was thinking of making some software “pedal with inertia” so slowdown would be more gradual, also a “start boost” might be useful to get the motor running more quickly (in fact some twelve magnet rings are marketed as giving you a “quicker start”).

Support for several ebikes, one might even program a cheaper Arduino Nano “test box” with a full set of signals to evaluate if this solves your problem before buying everything else.