This project started forming when I got my hands on a broken hoverboard that had been snapped in half. I had plans to put it on something unexpected. That idea became what it is now through some interesting circumstances, such as the battery on my electric scooter becoming unresponsive, and my friend's workplace having a collection of broken shopping carts that they were allowed to help clear. This project looked easy initially, but I ran into a lot of issues that taught me a lot about how STM32 microcontrollers and BLDC motors work.
This mainboard is based around the STM32 microcontroller, and thanks to some very smart people who reverse-engineered the schematic of this board and wrote some very customizable replacement firmware, I was able to use an ST-Link to reflash the onboard controller and use a joystick to control the motors instead of the 2 accelerometer sideboards.
https://github.com/EFeru/hoverboard-firmware-hack-FOC
The more difficult part of this project was securing the motors properly to the shopping cart. These motors produce incredible torque, and need to be held tight enough to keep the shaft of the motor from twisting. I began by widening the holes that were there for the old wheels until they could fit the shaft of the hoverboard wheels. Once they both could fit, I cut a small support bar that interfaces with the flat part of the hoverboard wheel shaft, locking it in place. This has held up so far, but it is not precise and can loosen over time. If I'm ever doing this again, I would machine a proper holder that sandwiches the shaft entirely and bolt that to the bottom of the cart much more securely.
I accidentally drilled one of the holes too big, and I needed to 3D print a spacer. This spacer has broken a few times, and is a bit of a sore point in this project. I wish I had access to a stronger print material, or a welder to fill and redrill the hole. For its thickness, this print holds up quite well. It is about half a millimeter thick, and can hold the weight of me and the cart, which could be about 60 pounds or so for each wheel.
The battery I use is from my electric scooter. The BMS on this battery suddenly went unresponsive and killed my scooter, but I wasn't about to let this 10S 36V li-ion battery go to waste! I bought a new and simpler BMS and wired it up for use with the mainboard. This BMS works well and keeps the battery safe from over-discharge and over-current. It is rated for 15 amps, which these hoverboard mainboards can pull easily.
After getting the cart functional, I moved to figuring out how I can use the sideboard to add lights. These sideboards originally were used for balancing the hoverboard using an accelerometer and gyro. I no longer need that function, but the sideboards also handled the lights on the hoverboard. The writer of the firmware for the mainboard also wrote firmware for the sideboard, albeit quite minimal. Looking into it however, I realized that my sideboards are different than the ones shown in the documentation. because of this, the firmware did not work correctly and I had to modify it after I figured out exactly how different these boards were.
I have some little OLED screens that I hoped would work with the STM32 to display diagnostics (so I can calibrate the battery voltage and temperature). To my surprise, the modifications worked! However, the library I used to interface with the OLED screen may not be well optimized, as every time the screen is updated the firmware hangs and would crash. I was able to use this code to calibrate the battery ADC though! I learned a ton in doing this modification, and even if it didn't work as intended, I still enjoyed the process. I tried this same modification on the sideboard as well, but the sideboard uses a different processor that doesn't play nicely with my code.
https://github.com/eroboticdude/hoverboard-firmware-hack-FOC
https://github.com/eroboticdude/hoverboard-sideboard-hack-GD