Close
0%
0%

ES-200 Electric Scooter Unlocker

Our streets are becoming litter with high technology joy. These forgotten scooter must be reverse engineer and given the love they deserve.

Similar projects worth following
This project is intended to share all that has been discovered from the ES-200b scooter that was found in the river by my house. Their high tech trash, becoming a tool for the everyone.The most current versions of my firmware are available on Github @ https://github.com/chappy1978/ES200-Scooter-Unlocker
There is two versions Master and Final. Master is a working version that is not being currently updated and Final is a production version that I am working to create extra features like flashing lights But it looks so much prettier. At this time I would us the Final version it has a speed increase not available on the master.

https://github.com/chappy1978/ES200-Scooter-Unlocker

    The system that the Electisan F350 e-scooter is built on a basic STM32 platform. The motor controller is based on a the venerable STM32F103C and the display controller is a STM8. Sadly the manufacture in china locked up the firmware. The GPS tracker is based on the nRF52840 and was not locked. So the firmware is included below. The tracker is manufatured by Comodule and the FCC was so kind to include some great photos. 

https://fccid.io/2AQHSF0010003/Internal-Photos/Internal-Photos-4348312 

Once the potting is removed there is pads exposed for the SWD nRF52 (six pins) and the SPI flash chip. (four tiny pins) ISSI IS25WP064A Pinout to be included later. On the GPS tracker there is a SARA-R412M cellular modem. That I have been told is a real pain to use.

Diagnostic Codes
01E ~ High current protect
02E ~ Low voltage protect (battery or cHigh current protect)
03E ~ High voltage protect (controller problem)
04E ~ Locked motor protect
05E ~ Controller problem (MOS burned)
06E ~ Controller problem
07E ~ Motor problem
08E ~ Motor OT
09E ~ Throttle problem
10E ~ Brake problem (Usually broken brake lever)
11E ~ Signal transmission problem (controller problem)
12E ~ Signal transmission problem (controller problem)
13E ~ Cannot communicate with BMS

ES200_ESP32_Mod.zip

Updated version based on C++

Zip Archive - 35.52 MB - 12/10/2021 at 10:59

Download

Adobe Portable Document Format - 379.27 kB - 12/01/2019 at 22:27

Preview
Download

JPEG Image - 1.90 MB - 12/01/2019 at 22:26

Preview
Download

JPEG Image - 296.43 kB - 12/01/2019 at 22:26

Preview
Download

Scooter_Starter.ino

This is the Basic Arduino Nano project to start the ES200 scooter

ino - 575.00 bytes - 12/01/2019 at 22:03

Download

View all 7 files

  • 1 × ESP32 Adafruit Huzzah32 but any one would do.
  • 1 × DC/DC Buck Convertor LM2596 Module
  • 1 × Julet Plug Aliexpress

  • Modified Version

    Mr. Spriggs12/10/2021 at 11:13 1 comment

    I added a modified version that has a lot of extra things going. Its written in C++.

  • New Speed increase

    Mr. Spriggs01/09/2020 at 14:26 1 comment

    A new speed increase has been finally uncovered for the ES-200. This command has been applied to the Final version of the Scooter Unlocker for the ESP32. https://github.com/chappy1978/ES200-Scooter-Unlocker/tree/Final Happy hunting

    And a Big Thanks to Wileok for doing the hard work and finding the command.

  • Production Version

    Mr. Spriggs01/06/2020 at 13:56 0 comments

    I have branched of the GitHub library to two versions. The master branch is a stable version not being updated and Final is going to be the production version with all the extra options to make it as simple to use a possible. Hope everyone enjoys.

  • Github Repository

    Mr. Spriggs01/01/2020 at 13:44 2 comments

    So this project has been migrated to a Github repository. Hope everyone will enjoy.

  • Going to Github

    Mr. Spriggs12/30/2019 at 22:39 0 comments

    The project is getting difficult to maintain with just using Hackaday.io Im going to migrate the project to Github. So I can share the newest versions.

  • Low Power Mode Here we come.

    Mr. Spriggs12/30/2019 at 01:35 0 comments

    Ok The Holidays are suck. Oh ya Im not here to bitch. So Ive got an updated ESP32 with bluetooth that can code select any and all known codes. So you can ride along on the fly and switch from granny mode to a whooping 13 mph with flashing headlights and all.  Just need to type in a decimal number from 0-255 on the smartphone of your choosing and test to you hearts content. Im going to put it on Hackaday. For all the cool kids in the know. If you don't read the ten thousand time I put the link in the forum. Still no luck on the speed. I think a more complex solution will be required.  Something along the lines of reprogramming the STM8 in the headstock and adding bluetooth which is cool and a pain in the ass.
       So nexts is a couple of lessons learn. The ESP32 sucks the mA hard. 100 ma running full power. So when compiling use the 80 mhz setting, set the flash to 40 mhz. And if there is a tech savvy soul to be found, kill one of the cores. Ive gotten mine down to about 50-60mA with a low power of 20mA. That not including the draw on the buck convertor. 
      My next goal is to have a low power mode. But that it won't be a problem much longer. The low power needs a way to wake it up to turn on the bluetooth radio. Im trying to decide if it will be a touch pad to wake it up like all the new kids toys or have it wake up every so often and look for a BLE connection. Or even a little mix of the two.
        Also for the nano diehards that want to build something similar to my code. You can use a HM-05 Bluetooth module and the RemoteXY website to make your own forked version. It can work I just don't have the time to do it. It will need a SoftSerial setup for the bluetooth. It should not be much more than a cut and paste job.

  • Testing on a moving scooter today.

    Mr. Spriggs12/20/2019 at 22:53 0 comments

    Now that I have the bluetooth working and Im pretty sure that this code won't break the scooter. I got to tested out the controls in motion. Which it is lots of fun running around with a iPhone in my brake hand. Trying to get a scooter going as fast as I can. It starting to seem like the top speed for this motor controller is 13 mph. I found out I can make the headlight turn on/off and even flash. Make the scooter go slow as dirt. And some even make the MPH on the LCD turn on and off. Not sure what the point of that is, maybe something to do with MPH/ KPH. What the best news is that 0xFF is the fastest accelerating setting. The little wheel even squeaked off the line. 

  • Command Structure Testing

    Mr. Spriggs12/20/2019 at 13:53 0 comments

    Today I got the code working to send test commands to the scooter motor controller. This is some of the rules the command system seem to follow.

    - It looks like the commands need to be sent twice for them to take effect.

    - The keep alive command/ Kill will over write all other commands. 

    - The commands you want to keep working need to be sent repeatedly to keep working, every 10 sec is OK. 

    None of this has been tested on a running scooter. (i.e. don't want to kill my ride) So I can't  tell you if the motor is operational.

    As for the commands Ive gotten something to happen
    0x02 Causes headlight to flash and a loss of the LCD
    0x03 Causes headlight to flash and LCD is still working
    0x04 None
    0x05 Turns on Scooter 
    0x06 Causes headlight to flash and a loss of the LCD
    0x07 Causes headlight to flash, LCD is still working, MPH is lit.
    0x08 None
    0x09 Causes headlight to turn off, LCD is still working, MPH is lit.
    0x0A Causes headlight to flash and a loss of the LCD
    0x0B Causes headlight to flash and a loss of the LCD
    0x0C None
    0x0D Causes headlight to turn off, LCD is still working, MPH is lit.
    0x0E Causes headlight to flash and a loss of the LCD
    0x0F Causes headlight to flash, LCD is still working, MPH is lit.

  • Interesting Data Output

    Mr. Spriggs12/19/2019 at 17:20 0 comments

    So when I type in commands into my remote for ESP32 the motor controller spits back hex data. It easier on the eyes in decimal so here a little to look at

    Keep alive command

    19 38 20 0 44 213 0 82 0 0 80 0 0 7 0 0 255 1 153 186 0 158 0 0 0 0 0 0 32 0 2 100 17 16 16 18 255 255 255 148 127

    Turn off

    19 38 20 0 44 213 0 82 0 0 80 0 0 16 0 0 255 1 153 186 0 158 0 0 0 0 0 0 32 0 2 100 17 16 16 18 255 255 255 148 1

    Notice the highlighted numbers is on and off. Other commands seem to change the last third fourth and fifth digits. Also adds a bunch more data to the response.

    19 38 20 0 44 213 0 82 0 0 80 0 0 16 0 0 255 1 153 186 0 158 0 0 0 0 0 0 32 0 2 100 17 16 16 18 255 255 255 202 197 255 255 255 255 255 255 3 255 0 154 36 255 20 162 51 255

    The last digit in the string is the checksum Im guessing.

  • BLE Remote Commands

    Mr. Spriggs12/18/2019 at 20:47 0 comments

    The remote commands software is working. I can send commands to the motor controller from my iPhone which is pretty cool. I haven't yet figured out any interesting commands that I can figure. The keep alive command keeps stepping on the commands I send. For example I send a command to the motor controller the LCD flashes the response. But as soon a the keep alive timer send a command the last command is over written. I really need a working GPS to monitor and see how commands are sent over a long period of time. Ahh a project for another day.

View all 18 project logs

  • 1
    How to connect an Arduino Nano to the ES-200B

    To get the ES-200b working you need to cut the exposed wires from the GPS tracker. Warning these wires have different color codes depending if you are going to cut it before or after the waterproof plug. For my scooter I cut it on the GPS tracker side. On the other side the Black and Red wires are still the same. the BTN wire is yellow and the TX is blue I believe.

       The Black is ground (GND) The red wire is the VIN 42 volt from the battery. The Blue is called the BTN and this is just to turn on the motor controller. It requires a constant 3.3v. The yellow is TX and will need to be connected to the RX of the Nano. The green is the RX line and is not required but I hooked it up anyways just in case you want some input from the motor controller.

       So the first step is to hook up a Buck convertor to the Red (VIN) and black wires (GND) this will step down the relatively high voltage from the battery to something the Arduino can use. Because the battery is 42v you will need a special Buck Convertor that can handle all that voltage. I used an LM2596 based convertor board from amazon. A XL7015 type break out might be a better choice. Make sure to adjust the voltage below 5v.  Now connect the Arduino ground to the buck convertor and the buck's + to the Arduino's VIN

       Next connect the yellow TX of the tracker to the Arduino's RX pin. Now connect the Blue (BTN) wire to pin number 5 on the arduino or more simply to the Arduino 3.3v out. Last upload the included arduino .ino file to the nano and away you go. 

      If you cant get a hold of buck convertor right away its OK to connect the arduino to a USB battery. That will do the trick. 

View all instructions

Enjoy this project?

Share

Discussions

Steven wrote 5 hours ago point

So I have a es200B and i have gotten the ardunio nano script to work and successfully turn on the scooter.  I went ahead and tried the esp32 route and got the script to load and remote xy to work but i am stuck there. The scooter will not turn on when given the unlock command.  When i plug it into the charger and send the unlock command, i get error code 10e and 12e. Any ideas as to what i am doing wrong?

  Are you sure? yes | no

holec.g wrote 06/10/2022 at 09:06 point

Hello, very nice job.

I have a quesion, i have Buck convertor to the Red (VIN) and black wires (GND)

https://fr.aliexpress.com/item/33025917509.html?spm=a2g0s.9042311.0.0.27426c372oO2Zs

I connect it on an ESP32 whithin RemoteXY code. All done ! The ES200 D is running very well. 

The problem appear after 3 weeks. The red wire dont have any voltage between black and red...

I have a second scooter for spare, the same issue on some weeks... 2 controllers KO whith

this connection. I suspect the Buck conertor. But i don't know why?? Have tou an idea? when i charge the scooter,

the display shows the load and no error but whatever I communicate with the RX pin of the controller like before nothing happens, the scooter don't turn on.  :-(

thx for reading and may be helping.

  Are you sure? yes | no

Mr. Spriggs wrote 06/10/2022 at 13:25 point

Hmm, Send me some photos of the wiring job and I will look at it. If there is no voltage from the Juliet plug on the VIN & GND then there is a real problem. Maybe the Buck Convertor is damaging the scooters motor controller. 

  Are you sure? yes | no

holec.g wrote 06/22/2022 at 21:41 point

Hello,

Thx for your reply.

I posted my wiring job as a profile picture.

In the meantime I found on a forum a person who reprogrammed the STM32 of the controller. so I disked the box and removed the silicon and flashed the microcontroller without error (https://www.scooterhacking.org/forum/viewtopic.php?f=10&t=655). the red wire on the box don't have 38v ;-(

Mains charging still works without errors on the screen but no ignition of the scooter

  Are you sure? yes | no

Datacorp Technology wrote 06/04/2022 at 20:08 point

Good evening everyone my name is Patrick and I have been looking for the speed mod for the Augment es210 scooter for a long time, could you help me? kind enough to send me the instructions, thank you very much everyone, wish everyone a good evening.

  Are you sure? yes | no

fzudema wrote 05/25/2022 at 08:24 point

Anyone know where to access the battery on an ES-200G?

  Are you sure? yes | no

Mr. Spriggs wrote 05/25/2022 at 12:59 point

Getting to the battery is a really b$#@. You have the take the scooter completely apart to get at it. Are you trying to remove it? Because the best way to control it is thru the GPS box wires.

  Are you sure? yes | no

fzudema wrote 05/25/2022 at 13:19 point

Thanks for your response my man. I am trying to "reset" the scooter as I am getting errors 09 and 10 as you can see in my first post a few comments down..No idea if this would work but I thought unplugging and reconnecting the battery might be worth a try. I managed to wake the scooter and the wheel unlocked, but then the lights went out after 2 minutes or so and these errors appeared for the first time and are now staying. Do you have another idea? The history of the scooter is that its my personal MyTier which stopped working suddenly (probably bluetooth issue since I can't connect my phone to unlock it) even though it is mechanically in perfect shape. Tier, the shitty company that it is, is giving me the finger saying they don't repair nor send out replacement parts, so I have a 650€ piece of high tech junk that has a tiny bluetooth error thus ready for the trash..

  Are you sure? yes | no

fzudema wrote 05/28/2022 at 14:23 point

I am actually trying to do what you recommended this guy on here: https://scootertalk.org/forum/viewtopic.php?t=6284&start=470 ("pull the battery to the ESC"

  Are you sure? yes | no

fzudema wrote 06/15/2022 at 07:35 point

I could really use your input..

  Are you sure? yes | no

lupindawulf wrote 05/21/2022 at 01:12 point

Anyone here on discord working on one of these scooters projects? Add me LupinWulf#4719

  Are you sure? yes | no

Denis73d wrote 05/21/2022 at 05:33 point

the theme is dead

  Are you sure? yes | no

Denis73d wrote 05/19/2022 at 04:42 point

Remove the digit 1 after Serial in all lines

  Are you sure? yes | no

tommicek69 wrote 05/18/2022 at 13:00 point

Hello gentlemen,
I have a problem loading the Scooter_Starter.ino code into Arduino nano. Unfortunately, the original records are not available with us and I only have a clone of Arduino nano. The PC finds my Arduino, but writes me an error when compiling the code: Serial1.write (0xA6); Serial1 'was not declared in this scope
Does anyone know where the buried dog is?

Thank you

  Are you sure? yes | no

fzudema wrote 05/16/2022 at 20:57 point

OK so I just almost popped some champagne after trying out the "simple Arduino Starter" script on my ES-200G and my scooter actually turned on! This was the first script that did it (I have no idea what I'm doing). Anyway after a minute or so the lights on my scooter turned off and won't turn on again. Plugging in the power supply it first showed error code 09E, now it shows 10E. Any idea how I can proceed? This is greatly appreciated!

  Are you sure? yes | no

Denis73d wrote 05/16/2022 at 08:51 point

how to overcome error 05E

  Are you sure? yes | no

lupindawulf wrote 05/11/2022 at 05:38 point

If there is anyone willing to help me out with this, I would appreciate it, I am not the most tech savy but I am a quick learner.  We can do discord Voice chat and screen share, message me if you would be willing to help

  Are you sure? yes | no

lupindawulf wrote 05/06/2022 at 04:01 point

where is a good place to start converting an ES-200b step by step?

  Are you sure? yes | no

0lav wrote 12/22/2021 at 20:41 point

Thanks for the updated 2021 version. I use the ESP-01 wifi chip and have webserver so people can change settings from cell phone, no app. You can't get much cheaper and low power than the ESP-01. 

  Are you sure? yes | no

Migu5499 wrote 11/11/2021 at 02:48 point

HI ALL!, do you know if will work for ES100? some people make the es100 work with the Arduino stuff, but this with esp32 it is veryy good!

  Are you sure? yes | no

Bwbailey1 wrote 09/15/2021 at 17:14 point

can someone send me the code for the esp32

  Are you sure? yes | no

kubik wrote 12/11/2021 at 11:09 point

/*

   -- ESP32-Scooter controller V3.1 --

  
   This source code of graphical user interface
   has been generated automatically by RemoteXY editor.

   To compile this code using RemoteXY library 3.1.6 or later version
   download by link http://remotexy.com/en/library/

   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/                  
     - for ANDROID 4.8.01 or later version;

     - for iOS 1.5.1 or later version;

   
   This source code is free software; you can redistribute it and/or

   modify it under the terms of the GNU Lesser General Public

   License as published by the Free Software Foundation; either

   version 2.1 of the License, or (at your option) any later version.   
*/

//////////////////////////////////////////////

//        RemoteXY include library          //

//////////////////////////////////////////////

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP32CORE_BLUETOOTH

#include <BluetoothSerial.h>

#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_BLUETOOTH_NAME "Scooter controller V3.1"

#define REMOTEXY_ACCESS_PASSWORD ""

// RemoteXY configurate 
#pragma pack(push, 1)

uint8_t RemoteXY_CONF[] =

  { 255,3,0,0,0,181,0,13,13,1,

  2,1,3,38,22,11,2,26,31,31,

  83,119,105,116,99,104,45,79,78,0,

  83,119,105,116,99,104,45,79,70,70,

  0,2,1,3,52,22,11,2,26,31,

  31,72,105,103,104,45,83,112,101,101,

  100,0,76,111,119,45,83,112,101,101,

  100,0,2,1,3,66,22,11,2,26,

  31,31,76,105,103,104,116,45,79,78,

  0,76,105,103,104,116,45,79,70,70,

  0,130,1,1,13,61,12,17,129,0,

  5,17,52,5,24,83,99,111,111,116,

  101,114,32,99,111,110,116,114,111,108,

  108,101,114,32,86,51,46,49,0,129,

  0,29,41,22,5,24,80,111,119,101,

  114,32,79,110,0,129,0,29,55,32,

  5,24,83,112,101,101,100,32,99,104,

  97,110,103,101,0,129,0,30,69,11,

  5,24,76,105,103,104,116,0 };

 
// this structure defines all the variables and events of your control interface
struct {

    // input variables

  uint8_t switch_power; // =1 if switch ON and =0 if OFF
  uint8_t switch_fastspeed; // =1 if switch ON and =0 if OFF
  uint8_t switch_light; // =1 if switch ON and =0 if OFF

    // other variable

  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;

#pragma pack(pop)

////////////////////////////////////////////

//         Scooter Command include        //

///////////////////////////////////////////

byte slowvoi[] = {0xA6, 0x12, 0x02, 0x65, 0x14, 0x86}; // REPLACE BY YOURS

byte slow1[] = {0xA6, 0x12, 0x02, 0XF1, 0x14, 0x7E}; // REPLACE BY YOURS

byte slow2[] = {0xA6, 0x12, 0x02, 0XF5, 0x14, 0x45}; // REPLACE BY YOURS

byte fastvoi[] = {0xA6, 0x12, 0x02, 0x03, 0xFF, 0xBF}; // REPLACE BY YOURS

byte fast1[] = {0xA6, 0x12, 0x02, 0XF1, 0xE4, 0x0A}; // REPLACE BY YOURS

byte fast2[] = {0xA6, 0x00, 0x00, 0xF5, 0xFF, 0xFC}; // REPLACE BY YOURS

byte off[] = {0xA6, 0x12, 0x02, 0x00, 0xFF, 0xEA}; //Off

void setup()

{

  RemoteXY_Init ();

  Serial.begin(9600);

}

void loop()

{

  RemoteXY_Handler ();

  if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed == 0) && (RemoteXY.switch_light == 0)) //light off + slow

  {

      Serial.write(slow1, sizeof(slow1));   
  }

  else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 0 && (RemoteXY.switch_light == 1)) //light on + slow

  {

      Serial.write(slow2, sizeof(slow2));   
  }

  else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 1 && (RemoteXY.switch_light == 0)) //light off + fast

  {

      Serial.write(fast1, sizeof(fast1));

  }

  else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 1 && (RemoteXY.switch_light == 1)) //light on + fast

  {

      Serial.write(fast2, sizeof(fast2));

  }

      else

  {

      Serial.write(off, sizeof(off));    
  }

  delay(200);

}

  Are you sure? yes | no

Bwbailey1 wrote 09/14/2021 at 14:50 point

is there a ino code for the esp32, also what wires connect to what on the esp32, I found out the power wires obviously but I’m not sure about the green yellow and blue wires

  Are you sure? yes | no

crabcakes wrote 09/09/2021 at 21:40 point

Any tips for removing all that potting?

  Are you sure? yes | no

crabcakes wrote 09/09/2021 at 21:45 point

Or maybe I'm not following. Is it necessary to remove the potting first?

  Are you sure? yes | no

Jan wrote 08/02/2021 at 00:43 point

hi there,
I success unlock the scooter, lights is on, display is on, but the throttle nothing do....

display don't say any error code. When I disconnect throttle, say error. The cable is maybe ok. any ideas? Please help Mans..

Thanks for reply.

  Are you sure? yes | no

Roger wrote 05/22/2021 at 03:51 point

Hi there, am trying to open this link to the Nano Version. Is it still available? https://cdn.hackaday.io/files/1686677216248928/Scooter_Controller_RemoteXY_ESP32.ino

  Are you sure? yes | no

spamaval8r wrote 05/24/2021 at 16:09 point

Hey man, did u manage to access the code or get it somehow?

  Are you sure? yes | no

Roger wrote 05/24/2021 at 17:34 point

Yes, got it off Github in the end, have you got it working? 

  Are you sure? yes | no

nateclapp wrote 04/21/2021 at 19:13 point

So in my case the Green wire on GPS side of Juliet plug was RX to scooter (connect to TX of Nano) and Yellow was TX from scooter which is not needed.  For those following along, essentially what is going on is nano is sending a 6 group hex code down the RX line every half second to keep the scooter awake and control parameters.  Depending on what that hex code is, it controls top speed, acceleration, headlight on/off, waking up controller, mph/kph display etc.   I use A6 12 02 E5 FF 60.   Not sure what the first 3 blocks do, so just leave them alone.  4th block does a bunch of stuff for headlight on/off, acceleration, etc, The FF is for max rolling speed.  Initially I was using E4 there but regenerative braking starts at 24.3mph.  at FF it never kicks in and you can freewheel pretty fast down hills.  the last block is crcc or error checking on the other five, so change any of those and you will have to recalculate that.  if you use E5 for max speed, use DD as last block.

  Are you sure? yes | no

spamaval8r wrote 05/24/2021 at 16:09 point

Hey man, can you send me the code? Maybe post it on Pastebin or something because the link to the code isnt available anymore. Please man🤙🏼

  Are you sure? yes | no

nateclapp wrote 07/01/2022 at 23:47 point

//nano version
// changedv Serial1.write to Serial.write
// blue  to 3.3v on board
//green from TX on board //power from buck converter from 42 v to 6-10v v+ and Gnd
// put switch between buck converter and board so no hot stab power draws
//that shut down bms
int firstBlock = 0xA6;
int secondBlock= 0x00; //initial code had this as 12
int thirdBlock = 0x00; //inital code had this as 02
int fourthBlock = 0x80; // 100000 or bit 1 on, mph on, esc off
////PATTERN: turbo?/?/FAST ACC/KPH/?/LIGHT/BLINK/ESC ON

int fifthBlock = 0xFF; //max speed no KERS
  //MAX SPEED HEX E4 BRAKING AT 24MPH but you would need new crc
  //Serial.write(0xE4);
  //CRC-8  GO TO WWW.CRCCALC.COM AND USE CRC-8/MAXIM
int crcBlock = 0xB5;
void setup() {

    //Option button to set headlight to flash or solid
  pinMode(5, INPUT_PULLUP);
    //ignition button
  pinMode(7, INPUT_PULLUP);//ignition position
  int lightMode = digitalRead(7);
  int ignition = digitalRead(5);
    // initialize Serial:
  Serial.begin(9600);
  Serial.print(firstBlock, HEX);
  Serial.print(secondBlock, HEX);
 Serial.print(thirdBlock, HEX);
 Serial.print(fourthBlock, HEX);
 Serial.print(fifthBlock, HEX);
 Serial.println(crcBlock, HEX);
 delay (500);
  //Serial.write(0xE5); //light on full power, esc on 11100101
  //Serial.write(0xFF); //max speed no KERS
  //Serial.write(  the crc code)

  //Serial.write(0x80); //100000 or bit 1 on, mph on, esc off
 // Serial.write(0xff); //max speed no KERS
  //Serial.write(0xB5); //crc-8 maxim
    //Serial.write(0x10); //?(turbo?),?(off),fast acc off,kph, ?, light off, blink off,, esc off
  //Serial.write(0x14); //14KPH
  //Serial.write(0xCF); //CRC
  //delay(500);
  //Serial.write(0xA6);   //Serial.write(0x12);
  //Serial.write(0x02);
    //Serial.write(0x11); //turbo on?, ?off, fast acc off, kph, light off blink off, esc on
  //Serial.write(0x14); // 14KPH
  //Serial.write(0x0B); //CRC
}

void loop() {
  int lightMode = digitalRead(7);
  int ignition = digitalRead(5);
    // (ignition off)
  if (ignition == HIGH) {

    fourthBlock = 0x80; // turn off scooter ESC
    crcBlock = 0xB5; //CRC
  }
    else{
    
    //if headlight switch off:
    if (lightMode == HIGH) {
      //4TH BLOCK
      //PATTERN: turbo?/?/FAST ACC/KPH/?/LIGHT/BLINK/ESC ON
      //SO: E5 = 11100101 OR ??FAST MPH LIGHT No BLINK ESC ON
      fourthBlock = 0xE5;
      crcBlock = 0x10;
      }
      
    //else headlight switch on blink headlight
    else {
      fourthBlock = 0xE7;
      crcBlock = 0x81;
      }
  }
//Serial.println (firstBlock, HEX);
//delay (100);
Serial.write(firstBlock);

//Serial.println (secondBlock, HEX);
//delay (100);
Serial.write(secondBlock);// initial code had this as 12
 
//Serial.println(thirdBlock, HEX);

//delay (100);
Serial.write(thirdBlock); //inital code had this as 02
 
//Serial.println(fourthBlock, HEX);
//delay (100);
Serial.write(fourthBlock);
 
 
 //Serial.println (fifthBlock, HEX);
 //delay (100);
 Serial.write(fifthBlock);

//delay(100);
 
 //Serial.println (crcBlock, HEX);
 //delay (100);

 Serial.write(crcBlock);
 

delay (500);
}    

  Are you sure? yes | no

Steven wrote 06/26/2022 at 22:05 point

having trouble with this code, as it repeats 3x.  I don't fully understand what you mean by blocks?

  Are you sure? yes | no

nateclapp wrote 07/01/2022 at 23:51 point

a "block" in this case (for me anyway) means two digits in hexidecimal that do a specific thing to the scooter.  so the fifth "block (group of 2 heciecimal) of FF will control max speed,in this case max speed of scooter. "4th block" controls headlight on/off for example. 

  Are you sure? yes | no

Steven wrote 07/02/2022 at 05:08 point

Right, i understand that, but if i change the first set of code, do i do the exact same thing to the seccond and third set?  Im so confused.  I tried changing the first set of code and nothing worked, i changed them all and still nothing worked.  Could you copy and paste me the best full code for max speed?

  Are you sure? yes | no

nateclapp wrote 08/12/2022 at 14:56 point

Sorry for delayed response, apparntly I don't get notified when things get posted here.  Anyway, a few notes,  change "if (ignition == HIGH)" to "if (ignition == LOW)" as that will default to NOT attempting to turn off  scooter unless that pin is grounded.  That way, if you choose not to put a switch in or your switch fails, your scooter will default "on". 
Also, my code has a lot of notes to myself and is all commented out so that can confuse people.
initially, before the loop, the code tells the scooter to turn on and sets some parameters.  I suppose you could reconfigure code not to do that, but that's how the code initially evolved when I did it, and it's not hurting anything.

then in the loop, it checks whether the ignition switch (pin5) is grounded.  If it is (if you change code above) then it assigns a new value for 4th block which is command to shut down scooter.  It also has to calculate new crc, because that is error correction, and any time you change any value in any of the blocks, you have to recalculate your crc value. 
if the scooter is not being commanded to power down, it then determines whether pin 7 (headlight) is grounded, and depending, either commands it to blink or be solid on, and then assigns a crc value for either the state of  "scooter on, solid light" or "scooter on, blinking light."

4th block determines a bunch of stuff, including some stuff I don't know.  but includes light control, turning the scooter on, fast acceleration.   5th block sets top speed and KERS.   values I use seem to give me fast settings.  Change any of the blocks, you have to recalculate crc value. 
and lastly, I blew up a ESC due to bad buck converter.  plus even if buck converter doesn't break your scooter, it can temporarily break scooter by putting battery BMS in shock, and you have to physically unplug battery to reset.  this is a drag.  This is why I have changed my design, and just power the nano off a separate mobile usb power source isolated from the scooter power.  That way I can even use the usb power source as a key of sorts.

  Are you sure? yes | no

Terrance wrote 03/17/2021 at 23:17 point

Newbie here, having an issue with the code. When I run the code on the arduino app, it says no serial 1 not declared. . Thoughts? Thank you

  Are you sure? yes | no

mmy26 wrote 05/21/2021 at 20:33 point

удалить Serial (1) везде

  Are you sure? yes | no

spamaval8r wrote 05/24/2021 at 16:09 point

Hey man, can you send me the code? Maybe post it on Pastebin or something because the link to the code isnt available anymore. Please man🤙🏼

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates