VESC controller & dashboard

By request I’m starting a thread on how to build a controller and dashboard like mine. It is very DIY. If you see mechanical, electrical, or software fails that make it look like it was built by a monkey - there’s a reason for that. I’m sure folks will have some good suggestions for improvements.

My plan is to use the first five posts in the thread for:

  1. Description and bill of materials (this post)
  2. Modifying the controller to accommodate the electronics
  3. Building the dashboard that bolts on top
  4. Wiring
  5. Software

These posts will start as stubs, and I plan to come back and edit them to flesh them out.

What this is…

This is a 2.4 Ghz controller from Ebay used to control my DIY electric skateboards that use VESC controllers. One of my boards has been updated to a CFOC2 controller, and the other will be soon. These work with both.

On top of the controller I have an LCD display that I use to monitor my speed, amps I’m currently drawing, Capacity remaining in remote battery, and capacity remaining in skateboard battery. I sometimes change the program to display other things of interest as I poke around at the controller and do experiments.

The dashboard also houses a MicroSD card logger which will log a lifetime’s worth of data.

The control of the skateboard comes from the 2.4 Ghz controller in the normal way. The LCD display is essentially a separate unit that talks to the VESC or CFOC2 via bluetooth. On the controller side the bluetooth capability is built in to the ESP32 dev card that’s sort of the heart of the thing. On the skateboard end I use an HC-05 card plugged into the VESC UART port.

This is what it looks like…

And these are the two boards I use them for…

BILL OF MATERIALS:

https://www.ebay.com/itm/2-4Ghz-Mini-Remote-Controller-Receiver-For-Electric-Longboard-Skateboard/264517977932?hash=item3d9680074c:g:lbgAAOSw-dldu9h~

  • A 16x2 LCD display with I2C interface. These can also be had for under $10 on Ebay. I strongly prefer the ones with black letters on a green or yellow background. I think they have the best contrast. The good news is that they’re super easy to see in bright sunlight (like an LCD watch). Make sure to get one with the I2C interface.

https://www.ebay.com/itm/1602-LCD-Green-16x2-HD44780-with-IIC-I2C-Serial-Interface-Adapter-Module-Display/222035177760?hash=item33b253f120:g:7BAAAOSwcapc7K6Z

  • An ESP32 NodeMCU Dev board. These can also be had on Ebay for under $10.
    This is very much like an Arduino and is programmed through the Arduino Dev Environment. But it has built in Bluetooth (LTE and classic) and WiFi.

  • An 18650 rechargeable LiIon battery (with solder tabs if at all possible). These are available on Ebay and elsewhere for about $7.00 each, shipped.

  • A DC-DC boost converter to bring the 18650 output up to 5V for the display, ESP32, and logger.

pic3

These can be had on Ebay for just over $1.00 each in quantities of 10. Probably $2 for singles…

  • An HC-05 Bluetooth card for the skateboard end

  • Pin headers: Straight, 90-degree, and female crimp Dupont connectors (optional)

straight pin headers

90-deg pin headers

pin header female Dupont crimp connectors

  • Two resistors to make a voltage divider (4.7K and 10K)

  • ABS plastic to make the display housing. 1/8" to 3/16" thick.

  • 2 small sheet metal screws to mount the dashboard to the top of the controller.

  • A 10uF electrolytic capacitor

  • Heat shrink tubing

  • Some 3mm screws and tubing or nylon standoffs to assemble the display housing (more here soon)

22 Likes

Modifying the controller

The ESP32 draws a good bit more current than the 2.4Ghz transmitter, and I want the remote to be rechargeable so I don’t have to replace batteries all the time. Prior to the ESP32, I used an Arduino. The Arduino is easier on the battery, but as the project expanded, the Arduino became too limited for what I wanted it to do. When I had the Arduino in there I was powering the unit with a “9V” rechargeable (it was actually 2 Li-Ion cells in a 9V style case, so it hit a max of about 8.4V). At that time I used a couple of linear voltage regulators to get 5V for the dashboard and 3.3V for the transmitter.

But with the ESP32, the 9V didn’t last as long as I wanted it to. So I changed to a single 18650 Li-Ion cell. This has a capacity of 3400 mAh (vs 600 mAh in the 9V). So the primary objective here is to modify the controller to use a rechargeable 18650 and a switching DC-DC boost circuit to produce the 5V needed for the dashboard. There are a few other things going on, but that’s the thrust of it.

The first thing to do is to take the controller apart.

Ignore the dashboard on top in this view. Obviously your controller won’t come with one. To take it apart, unscrew the 5 screws marked with red arrows from the left hand side (LHS) of the controller. The remaining (silver) screw lets you remove the battery cover. You can remove that or leave it at this point. With the screws removed you can just lift that left half of the shell off the right half.

At the top of the controller there are a couple of knobs. Those knobs, and the On-Off switch are mounted on a little PC board that fits into notches on both halves of the shell. I usually like to try and hold that assembly in place on the right half of the shell while lifting off the left half of the shell.

Be aware, the trigger uses a little lever and spring mechanism to make it center. Both the trigger and the lever also fit into accommodating holes on both halves of the shell. I like to try and keep them in the right half of the shell as well when lifting the left half off.

NOTE: at some point (or maybe many points) during this modification, that spring is going to go flying. You probably should pick a spot where you have a good chance of finding it when it does.

With the left half of the shell removed, we need to remove the battery case from the left half to accommodate the 18650 and the boost circuit. I did this with a Dremel cut-off wheel. This will all be hidden inside when the project is done, so you don’t have to be terribly clean about it.

Next we have to remove a bit of material from the right side of the shell. This is a little cross bracing. This has to be ground down with a Dremel or similar to make room for the 18650 cell.

You can see another hole below the cross bracing in the RHS of the shell. That was for the charging port when I had a 9V battery in there. You can ignore it.

Next we have to make some minor modifications to the control board. Basically, we need to tap into the On-Off switch to power the DC-DC boost circuit.

This shows where the leads from the 18650 will connect to the board.

The wire marked “ignore” is from a previous mod. It can be ignored. Note that it’s attached to one pad of a little set of three. Those pads originally attach to the steering wheel pot. I removed the steering wheel and pot because it’s not needed and it doesn’t hurt to have a bit more room in there.

On the top of the control board we need to solder a wire onto the switch output terminal. This wire will power the DC-DC boost circuit when the switch is on.

I routed that wire around the aft end of the control board and tacked it down with a bit of hot-melt glue.

With the controller apart, and the control board hanging out, we can remove the steering wheel and pot.



Unscrew the knob from the steering mechanism from the outside, then unscrew the mechanism from the inside. Unsolder the three wires from the board and set this assembly aside (or even discard it). At this point I removed the raised portion of the outside of the RHS of the shell with a Dremel cut-off wheel and covered the steering wheel hole with a piece of black duct tape. No pic - but trust me, I really did.

Installing the charge port

The next order of business is installing the charge port for the 18650 battery. I use a female servo connector for this. You could also use the female version of standard 0.1" pin headers. I like to use 3 pins. I make the center pin (+) and the outer pins (-). This way I can plug it in either way.

To install this connector we need to cut a slot in the bottom of the RHS of the shell. I use a Dremel cutoff wheel to cut the slot, and clean it up a bit with an X-acto. We then use a healthy glob of hot-melt glue to hold it in place. Be careful not to get the hot-melt glue in areas that will keep you from putting the two shell halves back together.

Sorry for the poor focus on this pic:

Installing battery and boost circuit

Now we need to install the 18650 battery and boost circuit. I strongly recommend getting an 18650 battery with solder tabs if possible. If you can’t find one, we can solder wires to the battery terminals, but we have to be pretty careful since heat can destroy the battery.

If you’re going to solder wires to the battery terminals, you’ll first need to sand the terminal surfaces, clean them with a cloth and alcohol, apply some paste flux to them and then solder the wires on with a very hot iron. I set my iron to 450 deg-C and use a relatively broad tip. The ticket is to tin the tip first and make the solder joint as fast as possible. But of course it’s imperative that the solder flows on the battery terminal. After tinning the end of the wires, you can quickly reflow the solder on the battery terminals and introduce the wires. You don’t want the iron on the battery terminals for more than about 3 seconds.

Next I cut out a piece of cardboard to go between the battery and the boost circuit. I learned the hard way that the solder joints on the bottom of the boost circuit can cut through the heat-shrink insulation on the 18650 otherwise. Don’t do that.

Then I tape the boost circuit to the battery with the cardboard in between.

This is probably as good a place as any to talk about the connections. The (-) input on the boost circuit will go directly to the battery negative. The (+) input on the boost circuit goes to the wire we soldered onto the switch output on the control board. We also build our voltage divider with our two resistors across these two inputs (sorry I don’t have a proper pic of that).

Three wires are going to go from the controller to the dashboard. They will be the (+) and (-) outputs of the boost circuit and the junction of the voltage divider (which will be used to monitor the battery voltage). These three wires should be routed behind the control board and come out through a small hole we’ll make in the seam between the two shell halves at the top of the controller.

I like to gather all the wires that will go to each end of the battery and solder them to the battery wires at the same time. This makes it easy to protect the solder joint with a piece of heat shrink tubing. The negative battery terminal will connect to the control board (-) input, the two outer pins on the charge port, and the (-) input of the DC-DC boost circuit. The (+) terminal of the battery will go to the center pin of the charge port and the (+) input of the control board.

Before installing the battery into the shell is probably a good time to adjust the output of the DC-DC boost circuit to 5V. We do this by turning the control board switch On and turning the trim-pot on the DC-DC boost circuit while monitoring the voltage at the DC-DC boost circuit output. But you must have a load on the boost circuit to do this. You could use the ESP32 as a load or a beefy 50-ohm resistor, but beware that the resistor is going to get hot. We’re going to be dissipating 1/2 watt through it while we do this.

Then we can put the battery into the shell. You could secure the battery with hot-melt glue, but I didn’t bother. It’s going to be pretty tight in there.

Once the battery is installed, you can fit the shell halves back together. At this point you should make sure ALL the wires are tucked inside the shell - including the three that will later go to the dashboard. Also make sure you have your trigger and spring mechanism in place. This part can get a little fiddly - particularly getting the control board to seat properly into the notches in both shell halves. I found it useful to reach in through the switch opening on the LHS shell with an X-acto to guide the board into place while closing the shell halves.

With the shell halves back together (make sure it all fits nicely with no interference from the battery, wires, boost circuit, or hot-melt glue) you can drill a small hole in the seam between the shell halves where the three wires will exit. Note the location of that hole so it comes up through the dashboard mount (which is not there yet).

After this hole is drilled you will open the halves back up, run the three wires through that hole and reassemble the shell halves. At this point you can screw the shell halves back together.

5 Likes

Building the dashboard

The frame or bezel of the dashboard is made of ABS plastic. The plastic I used was 3/16" thick, but that’s just because I had that laying around. I’d probably recommend 1/8" thick ABS.

There are two parts to the frame. The front (user facing) portion which the LCD mounts to, and which mounts directly to the controller, and the back.

This PDF is a scale diagram of my front portion. You can take measurements from it or you can print it out, stick it to your ABS with some 3M-77 spray adhesive, and use it as a cutting guideline. The mounting holes are 3mm. The way I cut out the hole for the LCD display is to just drill a big hole right in the middle and then use a power jigsaw to cut out the rectangle. You might want to cut slightly small and then use a file to bring the opening to size cleanly.

dashboard bezel.pdf (380.6 KB)

The same template can be used for the back as well. You’ll want the mounting holes, but not the LCD hole or the mounting tab on the bottom. You may also want to round the corners. I did that with a belt sander.

When the front portion has been cut out I clamp it between a couple blocks of wood with only the mounting tab hanging out. I heat up the mounting tab with a heat gun (both sides) until it’s quite flexible. At this point I quickly unclamp it, and form it to the top of the controller.

Once the mounting tab has been formed to the top of the controller, you’ll need to drill three holes in the mounting tab. The center hole will line up with the hole you already made in the top of the controller to bring the wires from the controller into the dashboard. Then you’ll drill two holes (to either side of the first one) to mount it to the top of the controller. You’ll want to find some small sheet-metal screws to go through the tab and into the top of the controller. Drill the holes in the tab big enough for the sheet metal screws to slide right in. While holding the bezel in place on the top of the controller, use those holes as a template to drill two smaller pilot holes for the sheet metal screws in the top of the controller.

NOTE: make sure and drill all the holes far enough back from the face of the bezel that you’ll be able to access them once the LCD and other hardware is mounted to this piece.

Next we mount the LCD to the bezel with some 3mm machine screws. The screws that go through the front of the bezel are 15mm long, and the ones on back are 11mm long (but these lengths aren’t terribly critical).

As you can see from the picture above, I use some plastic (vinyl?) tubing to make the mounting standoffs and spacers. Just cut 4 little spacers from this tubing to go between the bezel and the LCD display. Stick the screws through the bezel, thread them through the spacers, and slide the LCD over the screws. The spacers should be long enough to roughly align the front of the LCD display with the front of the bezel.

Next cut 4 pieces of tubing as standoffs to mount the back of the frame. The LCD mounting screws will thread into these pieces of tube as well - securing the LCD display in place. In my case these standoffs are 16mm long. You don’t want to mount the back just yet, but when the time comes you’ll just screw the back onto these tube/standoffs with the other 3mm screws.

Mounting the logger

Solder 3 short pieces of wire into the GND, VCC, and RX holes on the logger. Next mount the logger to the back of the LCD with hot-melt glue. I put the chip side of the logger against the back of the LCD, and I position it so the MicroSD card can easily be accessed through the right side of the dashboard frame.

Mounting the ESP32 Dev Board

Next I solder the capacitor to the ESP32 board and solder some 90-degree pins in some of the ESP32 board holes. The (-) side of the capacitor goes to the GND hole, and the (+) side of the capacitor goes to the EN hole.

I then solder 90-degree pins into Vin, the other GND pin, GPIO-17, GPIO-21, GPIO-22, and GPIO-34.

With that done, I mount the ESP32 board to the back of the LCD with hot melt glue. I put a piece of cardboard between the ESP32 board and the logger to insulate them. I line up the ESP32 board so the USB connector can also be easily accessed through the right hand side of the dashboard frame.

Wiring info in next section.

2 Likes

Wiring

For wiring the dashboard portion I used two methods. One is to make straight inline connections using a single header pin and a single mating female Dupont connector, with heat-shrink over each. I used this when connecting wires to wires. This makes it easy to undo connections for testing, taking things apart, etc. But it’s definitely optional. It’s perfectly fine to simply use solder and heat-shrink connections if you prefer.

The other method is for connecting wires to boards (specifically the ESP32 board and the LCD display). For this I like the 90 degree header pins and a female Dupont connector soldered on in reverse. This again gives me a removable connection without wires sticking way out of the dashboard frame. I hope the following sequence is self explanatory…

DSCF5672

Dashboard Connections

There are three wires coming from the controller to the dashboard: +5V, GND, and a voltage signal from the voltage divider.

What I did was to take the wires from Vin on the ESP32, Vcc on the LCD, and Vcc on the logger and solder them all together onto a single straight header pin. I then cover the solder joint with heat shrink and plug that into the female Dupont connector I put on the end of the 5V wire.

I do exactly the same with the GND wire and each of these components.

With the voltage signal wire I put a reverse Dupont connector on it (as shown in the pics above) and slide it onto a 90-degree pin header I put on the GPIO34 pin of the ESP32 board.

In addition to those, we have to get data to the LCD display. For this I made a couple of patch cables with reverse Dupont connectors on each end. The first one connects GPIO21 of the ESP32 board to the SDA input on the LCD display. The second one connects GPIO22 of the ESP32 board to the SCL input on LCD display.

Next we have to send data to the logger. For this I put a reverse Dupont female connector on the wire coming from the RX pin of the logger, and plug that into a 90-degree header pin on GPIO17 of the ESP32 board.

Finally, the 10uF cap gets soldered directly to the ESP32 board with the (+) lead going to the “EN” pin and the (-) lead going to the GND pin.

4 Likes

The source code is contained in the attached .zip file. Please review the README.TXT file for relevant info.

code.zip (20.9 KB)

2 Likes

Very cool, I’m impressed.

4 Likes

Great work mate looking forward to this thread.

3 Likes

Remote makers HATE him! See how this 1 guy added telemetry to his remote in 4 complicated steps!

This is going to be interesting; having a nice guide for making hardware that interfaces with vescs is super valuable :slight_smile:

7 Likes

Nice, looking forward to this, have an esp32 to spare for something like this.

2 Likes

I’ll have to take this on if I can ever get my board to a workable state

3 Likes

Looking great so far!

I love how accessible all the off the shelf components make this.

2 Likes

I wasn’t seeing much engagement on this thread, so I never got around to adding the source code. Someone did PM me asking about it, so I just now put the source code (in a zip file) in the above source code entry. Please don’t hesitate to ask questions.

3 Likes

I’d completely missed the last couple edits to the walkthrough, so I’d put this one on the back burner while parts trickled in.

Very thorough! I think I can keep my fumbling through to a minimum with your instructions.

Finally, I have different functions to model the battery draw-down based on voltage (and in one
case current draw as well). You should choose the one appropriate to your packs. The one I wrote for
the SPIM08HP batteries accounts for voltage sag based on current draw. This has the very nice feature that the dashboard shows a nice linear draw-down. It doesn’t show my capacity remaining dropping near zero when I’m climbing a steep hill.

Interesting! As a coder-inept, the commenting is much appreciated.

1 Like

That’s very cool that someone is taking this on. Not sure if my comments will do on their own since I originally just did this for myself - and not with a ton of thought to its architecture. But I’ll try to use any questions I get to improve the documentation in this thread and in the code. You’ll have to post progress and pics as you go.

1 Like

Definitely!

I can mostly convince myself that I’m reasoning through it. :crazy_face:

Once I get to a functional baseline, modifying becomes easier to mess things up see cause and effect, so that’s the first goal.

Getting ahead of myself…

  // Log "Initializing..." to the SD card
    Serial2.print("Initializing..."); 
    Serial2.write(13);
    
    delay(500);
    }        

// Log the header to the SD card
Serial2.print("mSecs  voltage  current   Speed   Battery_Remaining"); 
Serial2.write(13);
}

void log_data()
{
Serial2.print(millis());
Serial2.print(" “);
Serial2.print(voltage);
Serial2.print(” “);
Serial2.print(current);
Serial2.print(” “);
Serial2.print(c_speed);
Serial2.print(” ");
Serial2.print(battery_remaining);
Serial2.write(13);
}

I’m guessing the log file is a space separated file, and if I want a csv, I should change the " "to “,”?

Or are you using another tool to view logs? 500ms(?) seems like a pretty reasonable logging clip

1 Like

That’s right. I would probably change it to ", " (with a space after the comma; but that’s your call).

I tend to look at logs with an analytical graphing program I wrote. But the logs are just ASCII files, so you could use any editor, Excel…

The 500ms in that particular clip of code is just the rate of retries to make the connection between the speed-controller and dashboard. As soon as the connection is made, it breaks out of that loop, exits the “setup” routine and goes into the “loop” routine. As it happens, I’m also using a 500ms delay in the loop routine, so it should add a log entry approximately twice/second.

1 Like

I’m so glad to have found your project! I’ve been craving telemetry to go with my Hoyt Puck, wanted to port the Davega code to ESP32, was too lazy. I’ve got a few M5Stick-C devices I bought to prototype something else, they incorporate most of what you built into this: Color TFT display, BLE4.0, Wifi (no need for it here) battery + USB charging thereof, and an SD card slot if needed. The larger M5Stack would probably be a better fit (larger 2in screen) so I’ll try that as well. Mainly, I was wanting to see someone else’s code that interpreted the blluetooth data stream from the VESC and here it is! I’ll post progress when there’s some to see.

3 Likes

Quick question about the blutooth module, where do you plug that in and how do you read vesc data from it. I’m looking at making a smart watch app which has telemetry on it from the vesc via blutooth. Doing some research on connections for vesc but I don’t see a second arsuino board used for this in your case. Is the tx/rx pins connected directly to the vesc and all telemetry data is automatically sent through the BT module?

1 Like

Wow - I’m sorry I haven’t seen this. Yeah - on the VESC side, the bluetooth module is connected directly to the VESC UART port.

Update…

I recently added a BN-220 GPS module to this controller so I can log my location and speed along with my voltage, current draw, etc. The GPS unit only costs about $15 from Amazon. I may also add a “back to my car” feature so that it tells me distance and direction back to the car. If anyone’s interested let me know.

3 Likes