What would be really nice: reprogram a $6 ESC!

Talking about my scifi fiction essay or bldc board?

lol, it really is impossible to tell sarcasm from sincerity in text form. I was referring to the Lepton board.
Although on second thought, I don’t actually know how to compile SimpleFOC for it or upload to it either, and I don’t want to be too much of a nuisance.

What current/voltage/functionality are you looking for?

I’m making some fancy 3-axis shoulder joints, which need position control with current limiting. Outrunner sizes 2814, 2208, 2204. Probably around 15A average 25A peak on the big one and 5-10A on the smaller ones. Powered by 3S lipo. Lepton would be great because it’s so small and can handle all 3 sizes.

I understand. A few things.

  1. The Lepton board power stage is at a paper design, which means, the board works only in my head. It’s never been made or tested.

  2. The I/O stage with the pins exposed – SPI and I2C – may need extra pull-up and down resistors, as well as the SPI pins for connecting an external sensor require some extra coding that may confuse Arduino. The SPI comms need to be proven to work and if they don’t work, I cannot expose different SPI pins due to the MCU having very few pins available, and you are stuck with open loop.

  3. There is no current sensor. There is also no back-emf feedback to the MCU, though I may add it later, but someone needs to write extra code for SimpleFOC to use it.

  4. The MCU is really tricky to program, you need an SWD debugger and extra steps to program from Arduino IDE. The reason is that the pins share functionality with the SWD signals and you need to do something called “connect under reset”, or use the external STM Cube to load the hex directly which some people find intimidating.

  5. This is a SimpleFOC board, and this means you need to write your own ESC code on top of the SimpleFOC code loop. In other words, you get a blank “clean slate” piece of hardware.

  6. Based on what you are telling me, you don’t need an ESC board but a full-blown SimpleFOC board to do the servo joints. You may want to revisit your use cases. Lepton will definitely work for you in a sensored closed loop with no current sensing if the I2C and SPI comms work.

If you are still interested I could post the Gerber files and BOM/PnP centroids, you can order from JLCPCB and test/code the firmware yourself. Again, this is a paper plane design. It’s an awesome, really nice project to get it to work and if you find any issues I could fix them in the hardware and re-post the Gerber for you to reorder a new version, etc. until we make it work.

Please let me know if you are brave enough to commit.


This is the BOM and full cost for 10 PCBs. If you order a batch of 10 or more, it will get at $7.27 per board.

Dang, I thought those three things next to the TSSOP20 were sense resistors, but it looks like they’re probably diodes. Nevermind then. Without current limiting I’ll just stick with my plan of writing hall sensor firmware for cheap drone ESC hardware until B-G431B-ESC1 is back in stock, because that’s small and cheap enough and has all the hardware I need.

You can still do current limiting in SimpleFOC using voltage control. I can add current sensing but it will make the board about $1.50 more expensive. Which is not a lot. But it will be a bit bigger, it adds to size.

1 Like

You make it look so easy! Yes, that ought to do the trick. I’ll be using hall sensors, so no conflict over the SPI pins. The three labeled A4, A5, A6 are free to use as digital inputs, right?

I know proper FOC uses a high resolution encoder, but I plan to upgrade the hall code to predict the exact rotor position by using the last few sensor change intervals to extrapolate the motor speed/acceleration. Won’t work at low speed, but it would be possible to do open loop microstepping between hall states for that. Though I don’t need precise positioning so I probably won’t bother.

If I’m reading your previous post correctly, the Arduino IDE can compile for STM32G03, but can’t do the uploading? And STM Cube is an IDE that can upload, but can’t compile SimpleFOC due to lack of Arduino libraries? I have a cheap Chinese ST-Link which I’ve never actually used, but I have used a similar tool with Atmel Studio for working with non-Arduino AVR chips.

Can the Arduino IDE connect via the ST-Link for the serial monitor? In a pinch I could connect a little LCD screen via I2C for debug output, but it certainly is nicer to have it on the computer.

Correct. Any of the exposed pins on the side are digital and some are analog (all the As are analog).

It could do uploading but you need manually put the MCU under reset and it’s really tricky. Better use the external Cube which you must install for Arduino to work anyway.

Never tried compiling any Arduino project with Cube so no comment. You need to ask someone experienced with this. Arduino IDE works just fine with G031.

I was never able to make the cheap chinese stlink to work, but I’m using a nucleo board’s stlink2 to upload, and also have official stlink3. Can’t comment on chinese stuff.

Not sure what you mean by that. Could you please be more specific?

Usually with Arduino you can use the Serial library to print out text for debugging over the USB cable, which shows up in the IDE’s Serial Monitor window. I’m wondering if that will work with this processor connected to USB via the ST-Link.

Hmm… Well, STLink does have a virtual USB port but I’ve never used it, probably because Arduino doesn’t know how. I have my own design Serial debugging probe with an LCD screen that attach to TX/RX uart pins for that purpose. It takes Serial, SPI and I2C inputs and displays on the LCD screen, a lot easier than using an entire computer as a dumb terminal, and if you have multiple motors you can use one per motor to see what’s going on, else debugging a complex system is impossible.


Alrighty, I’ll use the LCD then. I have a couple SSD1306 I’ve used before, one configured for I2C and the other for SPI. I may be able to use the Arduino serial monitor as well, because according to a tutorial I read, the same FTDI adapter I use for Arduino Pro Mini can connect to the TX and RX pins on the STM32. That also means I may not need the ST-Link or Nucleo and STMCube setup.

Send me the files! I watched the SimpleFOCPowerShield ordering tutorial, so I think I can navigate the JLCPCB order system now. I’ll be happy to send you one of the boards after I get them. And one for Anthony_Douglas, if you want to try it out as well. Sorry for taking over your thread :slight_smile:

Correct. But you need to be careful because STM is 3.3V and FTDI for Arduino may be 5V so you have to use the correct voltage level.

I like your gung-ho attitude, it’s the right stuff. Bud hold on, not so fast. I’ve ordered the one without current sensing for myself to test. If it is successful, I will add the current sensing then I will send you the files, unless you want to jump the gun and really pull a Dirty Harry. Please let me know?


No worries, my Pro Mini thing uses the 8MHz 3.3V model so it can run from 1S lipo. The FTDI has a voltage switch.

And while I do gots to know if Lepton works, I’ll wait until you find out. I was hoping to spare you the expense, but if you’ve already ordered then there’s no sense buying more just yet.

I’d like to at least prove the power stage combination that I selected works. I know the MCU and current sensing work, that picture above is another much more powerful driver board I designed for another project where I’ve tested everything quite thoroughly (unfortunately, very expensive and quite big board). However the driver and integrated dual-mosfet combo is untested. According to JLC it will be done in 5 days.

Production of core design completed, and shipped. Will post test results once received, then add current sensing and open the two designs: without current sensing and with current sensing.


I’m still waiting for delivery. They got hit with a serious two week lockdown.

Meanwhile I got a little time and added current sense. We are at exactly $10 for 10 batch.

I will not do anything until I get the non-current sense and test then you may order the current sense to check it, a lot less risky.

Below is the price for 10 batch with current sense.

I put current sense only on two phases due to size and cost and complexity restrictions. It will work fine. Also I scaled to 30A.


Any updates? Really looking forward to seeing where this board goes.

Nope. Still waiting for the shipment, more than a month. China is mostly shut down due to COVID zero tolerance policy. My orders have been frozen for 4 weeks already.