August 23, 20169 yr 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: http://i.imgur.com/JIifwEx.png 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: http://i.imgur.com/fUPcCUJ.jpg pretty bulky and ugly I know, but I was quite pleased I got it working If anyone has any questions ask away!
August 23, 20169 yr 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.
August 24, 20169 yr If it is sensing a magnet attached to the wheel, why not just take the magnet off?
August 24, 20169 yr 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.
August 24, 20169 yr Author 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.
August 24, 20169 yr Author 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.
August 24, 20169 yr Author 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.
August 24, 20169 yr 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.
August 24, 20169 yr 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
August 24, 20169 yr 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.
August 25, 20169 yr 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.
August 29, 20169 yr Author 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. [mention=14442]IR772[/mention] 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.
August 29, 20169 yr 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. [mention=14442]IR772[/mention] 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?
August 29, 20169 yr Author 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
September 1, 20169 yr Author 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.
September 5, 20169 yr 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....
September 6, 20169 yr Author 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.
September 6, 20169 yr 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.
September 6, 20169 yr Author 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.
September 6, 20169 yr We all started somewhere, so no shame to be beginner! No the idea was to use the coil of the relay as it is only driving 20mA and then remove the transistor. But all that is just optimization, just make it work the way you like and have fun in the process
September 6, 20169 yr 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 This thread is fascinating but way beyond my ken The reed switch worked well for me a couple of years ago when connected to a controller that has one of those loops for speed limiting. Magnet on a retracting belt clip and Bob's yet uncle. A bike that goes like clappers until you get off. Then the restriction comes back on I blew that controller up sadly
September 22, 20169 yr Would someone tell me what to do for my Oxygen CB city Bike? 2015 version. You have to press buttons on the control panel in the right sequence.
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.