Ebike derestrictor

Jun 29, 2016
43
7
34
Bristol
#1
As most of you are quite aware theres a speed limit in the UK of 15.5mph for electric bikes, which makes sense for public roads etc (not really). But what about when you're on your own private land and you want to get more out of the bike...

Yeah theres lots of different dongles you could buy... but why not make your own?

I used an arduino micro and a hall effect sensor to sense the magnet along the wheel and then activate an electromagnet every 2 rotations thus fooling the bike into thinking im going half the speed.

Here is the schematic:



And here's the code:

//**********************************************************
// Ebike_Jellyhack firmware v0.1
// Author: Nicholas John
// Date: August 2016
// Device: Arduino/Genuino Micro
// Hall Sensor: LinkSprite Hall sensor module
// RPM to Speed resource: https://endless-sphere.com/forums/viewtopic.php?f=28&t=16114
// 29 inch tire 11.6 RPM per one-MPH
// 27.5 inch tire: 12.2 RPM per one-MPH
// 26-inch tire: 12.93RPM per one-MPH
//**********************************************************
int digitalPin = 2; //D0 attach to pin2
boolean digitalValue; //variable to store the value coming from pin2
const int magnetOutPin = 12; //Pin that will be switched on to turn on transistor

volatile byte revolutions;
volatile byte half_revolutions;
unsigned int rpm;
unsigned long timeold;
const double rpmPerMph = 12.2;
double mphSpeed =0;

void setup()
{
Serial.begin(9600);
pinMode(digitalPin, INPUT);
pinMode(magnetOutPin, OUTPUT);
attachInterrupt(digitalPinToInterrupt(digitalPin),magnet_detect,RISING);
revolutions = 0;
half_revolutions = 0;
rpm = 0;
timeold = 0;
}

//Runs over and over
void loop()
{


if (half_revolutions >= 20) {
rpm = 30*1000/(millis() - timeold)*half_revolutions;
timeold = millis();
half_revolutions = 0;
mphSpeed = rpm/rpmPerMph;
Serial.print(mphSpeed,DEC);
Serial.println(" mph");
}

if (revolutions >= 2)
{
revolutions = 0;
digitalWrite(magnetOutPin,HIGH);
Serial.println("magnet engaged");
delay(20);
digitalWrite(magnetOutPin,LOW);
}

}

void magnet_detect()//This function is called whenever a magnet/interrupt is detected by the arduino
{
revolutions++;
half_revolutions++;
Serial.println("detect");
}

its pretty basic so far and has room for improvements, and it looks quite ugly, but it cost me around 20 quid to make... and it works a charm.

I'm thinking about adding a wireless LCD to the handlebar to read out the REAL speed.

Here's a pic of it on the bike:


pretty bulky and ugly I know, but I was quite pleased I got it working :)

If anyone has any questions ask away!
 
D

Deleted member 4366

Guest
#2
Excellent work. That's basically what a Badass dongle is. Is there a pull-up/down resister on the Arduino's pcb? If not, you should add one to get more reliable sensing,

You could make a simplified version for any bike that has a hall sensor in the hub to give a speed signal. The controller is reading a 5v pulse from the hall sensor each revolution, so instead of reading the magnet pulse from your hall sensor, you read the 5v pulse directly from the motor's hall sensor and ouput it at half the frequency or at a fixed frequency. Instead of sending the output to your transister, it would go directly to the controller. You wouldn't even need a battery because you can use the hall's 5v supply. The code would be identical.
 

mike killay

Esteemed Pedelecer
Feb 17, 2011
2,507
123
#3
If it is sensing a magnet attached to the wheel, why not just take the magnet off?
 

chris_n

Esteemed Pedelecer
Apr 29, 2016
560
43
57
Austria , Niederau or NE England
#4
If it is sensing a magnet attached to the wheel, why not just take the magnet off?
If you do that you get an error. On Yamaha mid drives you can reposition the sensor and fit a magnet to the cranks to activate the sensor. Speedo doesn't work correctly but I don't have a problem with that. Bosch motored bikes will not work by sensing cranks I am told but the above should work OK. The OP doesn't tell us which motor he has.
 
Jun 29, 2016
43
7
34
Bristol
#5
Hi, i'm using a yamaha motor.

The reason i dont put it on the cranks is that using this method all I have to do is just double the read out speed and I know how fast im going.
Also it means im not modifying my bike in any way other than moving the magnet up the spoke slightly

I'm going to refine the design a bit so that the whole thing is powered by 2 18650 lipo cells in series (rechargeable batteries).

9v batteries are wasteful with arduinos. The 2 lipos should keep the whole thing running for months.
 
Jun 29, 2016
43
7
34
Bristol
#6
I tested it on a flat piece of "private" land today and I got up to 27mph quite easily before running out of room. I think on a road with some decent hybrid tyres you could get up to 30 and sustain it.
 
Jun 29, 2016
43
7
34
Bristol
#7
Excellent work. That's basically what a Badass dongle is. Is there a pull-up/down resister on the Arduino's pcb? If not, you should add one to get more reliable sensing,

You could make a simplified version for any bike that has a hall sensor in the hub to give a speed signal. The controller is reading a 5v pulse from the hall sensor each revolution, so instead of reading the magnet pulse from your hall sensor, you read the 5v pulse directly from the motor's hall sensor and ouput it at half the frequency or at a fixed frequency. Instead of sending the output to your transistor, it would go directly to the controller. You wouldn't even need a battery because you can use the hall's 5v supply. The code would be identical.
These are built into the Arduino board which is pretty handy. You can buy the boards from anything from £5 up to £15 for the micro version. The great thing is its open hardware so you could even make them yourself.

I cant really test the hub sensor sadly as I no longer have a hub driven motor. Plus for those ones you can generally change the wheel size down to 16 inches in the setup options and itle let you go a bit faster :)

My goal was to search for an unobtrusive way of de restricting the bike and I think I've found the best solution here. As i said it needs some refinement, but everything is open source. I'm going to design an enclosure soon that will be 3d printable i'll update my post here with the file so anyone can print it.
 

trex

Esteemed Pedelecer
May 15, 2011
7,703
83
#8
you could modify your program a little bit to keep the magnet pulse at 1:1 up to 15mph. When your speed exceeds 15mph, you keep pulsing it at 15mph to fool the data logging.
 

D8ve

Esteemed Pedelecer
Jan 30, 2013
2,141
74
Bristol
#9
A sutlble reed switch and it could have a legal standard mode and an overdrive. But that would be naughty .... Naughty D8ve don't suggest such things
 

IR772

Esteemed Pedelecer
Jun 5, 2016
931
37
Leominster
#10
Clever boy, very well done, looks great as you have actually made it.

This was a winter evening project for me as it seemed achievable.

As my C is weak I am going to use a Picaxe which I know well and power it with 3.3 volts from a CR123.

For the magnet did you wind one or use a solenoid as the drawing.

The coil must be small in a badass dongle as they are compact, so thought it quite easy to wind a coil with small iron core, nail?

Coil active time 20ms was that a researched delay or a good guess that worked.

Any way well done again.
 

Trevormonty

Esteemed Pedelecer
Jul 18, 2016
1,135
59
12
NZ
#11
If you do that you get an error. On Yamaha mid drives you can reposition the sensor and fit a magnet to the cranks to activate the sensor. Speedo doesn't work correctly but I don't have a problem with that. Bosch motored bikes will not work by sensing cranks I am told but the above should work OK. The OP doesn't tell us which motor he has.
Tried using magnet on crank on Shimano STEPs bike. Works treat for a few minutes before controller decides you are trying to fool it. To clear error 14 put bike back to normal and ride with E014 displayed.

The dongle is still best bet.
 

nemesis

Esteemed Pedelecer
Mar 14, 2011
511
57
#12
It looks like the magnet on the crank arm trick only works on the Yamaha motors.
 
Jun 29, 2016
43
7
34
Bristol
#13
So I upgraded this a bit. Its now powered by 2 18650 lithium polymer cells, which means the battery wont run out for a LONG time. I've also added an RF transciever in the unit so that I can transmit the speed to my own LCD screen located on the handle bar. This is also powered by an arduino micro.

@IR772 You dont even need to know C :) I dont know C, I know Java and some C#.

Infact arduino uses its own language inspired by the likes of the above, but you can code in C as well.

Ill take a new pic soon.
 

IR772

Esteemed Pedelecer
Jun 5, 2016
931
37
Leominster
#14
So I upgraded this a bit. Its now powered by 2 18650 lithium polymer cells, which means the battery wont run out for a LONG time. I've also added an RF transciever in the unit so that I can transmit the speed to my own LCD screen located on the handle bar. This is also powered by an arduino micro.

@IR772 You dont even need to know C :) I dont know C, I know Java and some C#.

Infact arduino uses its own language inspired by the likes of the above, but you can code in C as well.

Ill take a new pic soon.
Did you use an off the shelf solenoid or make one?

The power to the magnet of 20 ms?
 
Jun 29, 2016
43
7
34
Bristol
#15
Did you use an off the shelf solenoid or make one?

The power to the magnet of 20 ms?
I made one using and inch long steel bolt wrapped around with 0.3mm of enameled copper wire.
It seems like the magnet sensor is quite sensitive so a solenoid could work fine.
I just found it cheaper to make my own magnets. I experimented with different numbers of coils but in the end I just eyeballed it and wrapped it from bottom to top then when reaching the top going back to the bottom and coiling it back up again.

The strength then depends on the current you pass through it. So if you need it a bit stronger chuck a hight value resistor in. But ofc you dont want it too high else itle drain your battery faster or even worse the thing could melt.

Mot sure what your last question meant but the code turns the magnet on for 20 ms which is drawing around 400 ma
 
Jun 29, 2016
43
7
34
Bristol
#16
The strength then depends on the current you pass through it. So if you need it a bit stronger chuck a hight value resistor in.
Correction the lower the value the resistor the higher the current. I actually dont have a resistor between my AA and my electromagnet. Ill upload a video soon with a parts list. I had fun building it, seems reliable too.
 

roscop

Finding my (electric) wheels
Apr 30, 2016
18
2
40
#17
Fun project! Maybe as a source for electromagnet you could use a 5v relay for arduino to fool the stock sensor, this will probably be less energy consuming than your homemade coil and smaller.

What I don't like is the fact that it requires external batteries, maybe there is a way to do it differently by intercepting the genuine signal but it is true it is more intrusive as it means connectors that will be different form one brand to another....
 
Jun 29, 2016
43
7
34
Bristol
#18
True the batteries can be a pain but since its now running from 2x18650s it lasts a loooong time.
Im going to experiment how much current I need to pass through the coil before the bike sensor doesnt pick it up anymore. At least then I can put in some resistors and save some power.
 

roscop

Finding my (electric) wheels
Apr 30, 2016
18
2
40
#19
you probably don't need the all transistor stage, instead drive directly the electromagnet from a 5v relay with the output of your arduino, that should be enough to trick the original hall sensor.
 
Jun 29, 2016
43
7
34
Bristol
#20
you probably don't need the all transistor stage, instead drive directly the electromagnet from a 5v relay with the output of your arduino, that should be enough to trick the original hall sensor.
True but an npn2222 is cheap!
Its essentially doing the same thing as a 5v relay would do is it not?
(Ive recently returned to electronics btw so im nowhere near a pro, my background is programming)

Im doing some experiments and I think I could even power the arduino with a single 18650 esp if I desolder the LEDs but I welcome any ideas.
 

Advertisers