Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PKGS += lib_ws2812 logui lib_code_server lib_midi lib_disp_ui
PKGS += vdisp lib_tca9535 vbms_harmony32 vbms_harmony16
PKGS += dash35b vl_bike_39p lib_bq27441 boosted_doctor dash16
PKGS += lib_tca9534 UnleashedCreativityLights wheelie_limiter
PKGS += mt6701_config
PKGS += mt6701_config mqttcan4vesc

TEST_PKGS = blacktip_dpv

Expand Down
13 changes: 13 additions & 0 deletions mqttcan4vesc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Requires a VESC Tool binary. Point VESC_TOOL at it if it is not on PATH, e.g.
# make VESC_TOOL="/Applications/VESC Tool.app/Contents/MacOS/VESC Tool"
VESC_TOOL ?= vesc_tool

all: mqttcan4vesc.vescpkg

mqttcan4vesc.vescpkg: pkgdesc.qml mqttcan4vesc.lisp ui.qml README.md
"$(VESC_TOOL)" --buildPkgFromDesc pkgdesc.qml

clean:
rm -f mqttcan4vesc.vescpkg

.PHONY: all clean
54 changes: 54 additions & 0 deletions mqttcan4vesc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# MQTTCAN4VESC

Turns a **VESC Express** into a CAN → MQTT telemetry bridge, configurable from
this panel — no Lisp scripting needed.

The Express listens to the motor controller's CAN status messages (statuses
1–6), decodes them into engineering units, and publishes them over WiFi to an
MQTT broker, either as one JSON document or as one topic per signal. It is
read-only with respect to the vehicle: it never commands the controller.

Published every interval, whatever the controller has enabled (undecoded fields
carry `0`): `erpm`, `current_motor`, `motor_speed`, `motor_torque`, `duty`,
`amp_hours`, `amp_hours_charged`, `watt_hours`, `watt_hours_charged`,
`temp_fet`, `temp_motor`, `current_in`, `pid_pos`, `tachometer`, `v_in`,
`adc1`, `adc2`, `adc3`, `ppm`. Both the raw signals (`erpm`, `current_motor`)
and the values derived from them are sent, so a wrong pole-pair or torque
constant can be corrected downstream instead of re-flashing.

## Before you start: WiFi

WiFi is **not** configured from this panel. Set it once on the device itself:
VESC Tool → **VESC Express** → **WiFi** tab → WiFi Mode = `Station`, then fill
in **Station Mode SSID** and **Station Mode Key**, write the config and reboot.
The firmware connects and reconnects on its own; this package just uses the
link. (The ESP32-C3 is 2.4 GHz only — a 5 GHz network will never connect.)

## Using the panel

Open this package's panel in VESC Tool (connected to the Express over BLE or
USB) and set:

- **MQTT Broker** — host, port, and optional username/password.
- **Publishing** — topic prefix, mode (json / topics / both), publish interval, and MQTT keepalive.
- **Motor** — the controller's VESC ID, the speed divisor (pole pairs) and the torque constant used to convert raw CAN values.

Press **Save & Apply** to store the settings on the device and reconnect (no
reboot needed). **Test Connection** shows the current WiFi/MQTT state,
**Restore Defaults** resets everything, and **Reboot** restarts the device.

The **Status** box updates about once a second: WiFi/MQTT state, live speed,
torque, voltage, temperatures, and a CAN-frame counter so you can tell at a
glance whether CAN data is arriving.

## CAN mode

- **vesc** (default) — decodes status 1–6 and leaves the VESC protocol enabled, so VESC Tool can still reach the controller over CAN. Falls back to `canget-*` polling if no status frames arrive.
- **raw** — same decode, but disables the VESC protocol on CAN.
- **sim** — publishes simulated telemetry with no controller attached, for bench-testing the MQTT chain. Never ship a vehicle in this mode.

## Notes

- Requires VESC Express firmware 6.05+.
- Uses plain (non-TLS) MQTT. Prefer a private broker with a username and password; the credentials and the telemetry both cross the network in the clear.
- Settings are stored in the device's EEPROM and survive reboots and package updates.
Loading