Skip to content

arozhkov2001/SmartESC_STM32_v2

 
 

Repository files navigation

SmartESC

SmartESC (aka SESC) is an alternative firmware for Xiaomi M365 and Ninebot G30 controller.

image

Overview

Avantage over other Xiaomi custom firmwares :

  • you can put any motor since it can detect all motor parameters and optimize them
  • you can use any battery, even 20s (with hardware modifications), change the voltage divider and set the new value in the controller
  • you can change the shunts values and set the new value in the controller
  • you can setup the controller very easily with VESCTool and make a lot of performance/stability tests
  • you can use the controller with any other device, event without any display
  • soon, we hope to support multiple linked controller

Cons :

  • you loose the ability to monitor M365 BMS for now (work in progress), but don't worry, you still have the voltage ;)
  • you loose the ability to update firmwares through bluetooth
  • for now, it needs hall sensors (no sensorless mode). [work in progress]

It can interface :

  • the stock M365/G30 display
  • VESCTool through VESC interface on the BMS UART (full duplex UART).

Nota : this firmware is in beta.

You'll be able to setup and control the controller/motor from VESCTool interface with a simple USB/Serial adapter. With any small arduino, use analog acceleration/brake throttles to control any electic moving device like escooter, gokart, electric skateboard without using the stock display.

Download

Download the latest build for M365 : Package Control total downloads

Build

Last automatic build status : Build on commit

If you want to build it manually, for an easier build, you need git and docker.

Clone the project

git clone https://github.com/Koxx3/SmartESC_STM32_v2.git

Build on Linux

Launch from terminal:

chmod +x docker_build*; ./docker_build_m365.sh

chmod +x docker_build*; ./docker_build_g30.sh

Build on Windows

Double click :

docker_build_m365.sh

docker_build_g30.sh

Programming

You need a ST-Link device to reprogram the M365/G3O controller. It costs 3/4€ on Aliexpress.

Plug the st-link following this schematic : image

With STM32 ST-Link Utility, disable Re&d out protection.

Menu "Target" => "Option bytes" image

VescTool

Use VescTool to setup the motor and input properties.

Use a serial USB adapter to connect the Xiaomi controller as an USB VESC : image

Launch VESCTool and connect with COM port. image

Launcher Motor setup wizzard. image

Enter all your settings in the different windows.

Enable the keyboard control :

image

You're ready to test your M365 controller with your keyboard !

ESP32 test module

M365 connections : image

Use ESP32 prototype board with and ESP32-devkit-c module : image

Use the code provided in the serial-trottle-brake-esp32 folder with Platform.io

Error Code SESC (Smart ESC) in VESC Tool

Can read it in "VESC Terminal" (or others Serial Terminal)

  • 0 = MC_NO_ERROR (No error)
  • 0= MC_NO_FAULTS (No error)
  • 1 = MC_FOC_DURATION (FOC rate to high)
  • 2 = MC_OVER_VOLT (Software over voltage)
  • 4 = MC_UNDER_VOLT (Software under voltage)
  • 8 = MC_OVER_TEMP (Software over temperature)
  • 16 = MC_START_UP (Startup failed)
  • 32 = MC_SPEED_FDBK (Speed feedback)
  • 64 = MC_BREAK_IN (Emergency input (Over current))
  • 128 = MC_SW_ERROR

Command available in VESCTool terminal

  • help (see all available commands)
  • foc_openloop [current] [erpm] (Exemple : foc_openloop 10 500)
  • ... (lot of other commands)

Packages

No packages published

Languages

  • C 98.1%
  • Assembly 1.8%
  • Other 0.1%