Baumann Works logo
Baumann Works Tools, code, and hardware
Baumann Works

Selsyn Gauge MQTT Controller

Apr 2026 ·Active ·source

Selsyn Gauge MQTT Controller

MQTT-based gauge controller for ESP32 / MicroPython. Drives a VID28/BKA30D/X25 stepper gauge and integrates with Home Assistant via MQTT.

Files

FileDescription
boot.pyWiFi connect + OTA trigger
ota.pyGitea API poller for OTA updates
ota_config.jsonOTA config (create from ota_config.example.json)
ota_config.example.jsonOTA config template
gaugemqttcontinuous.pyMain MQTT controller
gauge_vid6008.pyStepper driver for VID28/BKA30D/X25 gauges
main.pyEntry point, calls ota.mark_ok() on success
config.jsonApplication config (create from config.example.json)
config.example.jsonTemplate with all options

Deployment

# First time: upload via USB
ampy --port /dev/ttyUSB0 put boot.py
ampy --port /dev/ttyUSB0 put ota.py
ampy --port /dev/ttyUSB0 put ota_config.json
ampy --port /dev/ttyUSB0 put main.py
ampy --port /dev/ttyUSB0 put gaugemqttcontinuous.py
ampy --port /dev/ttyUSB0 put gauge_vid6008.py
ampy --port /dev/ttyUSB0 put config.json

# Monitor serial output
minicom -D /dev/ttyUSB0 -b 115200

MQTT Topics

All topics are prefixed with mqtt_prefix:

TopicDirectionDescription
/setTarget value from HA
/stateCurrent value
/statusonline/offline
/zeroTrigger zero calibration
/led/red/setON/OFF
/led/red/stateON/OFF
/led/green/setON/OFF
/led/green/stateON/OFF
/led/backlight/set{"state": "ON"/"OFF", "color": {"r","g","b"}, "brightness": 0-255}
/led/backlight/stateCurrent backlight state

Configuration

Copy config.example.json to config.json and ota_config.example.json to ota_config.json and edit:

WiFi

WiFi credentials are in ota_config.json (shared with OTA settings), not config.json.

MQTT

KeyDefaultDescription
mqtt_brokerBroker IP/hostname
mqtt_port1883Broker port
mqtt_userMQTT username
mqtt_passwordMQTT password
mqtt_client_idUnique client ID
mqtt_prefixTopic prefix for all MQTT messages

Gauge

KeyDefaultDescription
gauge_pins[12, 13]GPIO pins (4phase: IN1-4, stepdir: DIR, STEP)
gauge_modestepdirDriver mode: stepdir (DIR+STEP) or 4phase (full-wave)
gauge_min0Minimum value
gauge_max7300Maximum value
gauge_pulse4Pulse width in milliseconds
gauge_half_stepfalseUse 8-phase half-step mode (1200 steps, smoother)
smooth_step_ms50Smooth movement interval
idle_release_ms3000Release coils after idle (ms)
rezero_interval_ms3600000Auto-rezero interval (ms, default 1hr)

OTA

KeyDefaultDescription
gitea_baseGitea server URL (no trailing slash)
repo_ownerRepository owner
repo_nameRepository name
repo_folderFolder inside repo to sync
repo_branchmainBranch to track
api_tokenAPI token for private repos
wifi_ssidWiFi network name
wifi_passwordWiFi password

LEDs

KeyDefaultDescription
led_red_pin33Red LED GPIO pin
led_green_pin32Green LED GPIO pin
led_bl_pin23RGB backlight (WS2812/NeoPixel) GPIO pin

Home Assistant Discovery

KeyDefaultDescription
device_name“Selsyn 1”Device name in HA
device_model“Chernobyl Selsyn-inspired gauge”Device model
device_manufacturer“AdeBaumann”Device manufacturer
device_area“Control Panels”Suggested area in HA
gauge_entity_name“Selsyn 1 Power”Gauge entity name
gauge_unit“W”Unit of measurement for gauge
red_led_entity_name“Selsyn 1 Red LED”Red LED entity name
green_led_entity_name“Selsyn 1 Green LED”Green LED entity name
backlight_entity_name“Selsyn 1 Backlight”Backlight entity name
backlight_unit“%”Unit for backlight

Timing

KeyDefaultDescription
heartbeat_ms10000State publish interval (ms)

OTA Updates

On each boot, boot.py connects WiFi and runs ota.update(). The updater:

  1. If last boot was good and commit unchanged → skip file check entirely
  2. Otherwise, compares file SHA1 hashes with local manifest
  3. Downloads changed/missing files to .tmp, then renames into place
  4. On success, saves manifest with commit SHA; main.py writes OK flag

Manifest

Create ota_manifest.txt in your repo root to specify which files to sync:

boot.py           # specific file
main.py           # another file
*.py              # wildcard (matches anywhere)
selsyn/           # entire directory (trailing slash)
← M1730-ESP32 Shorefront →