Files
butterfly-edfa-rack-firmware/Makefile
T
James Bateman (hp-laptop) 58475386ba Butterfly EDFA Rack bridge: seed + EDFA over WiFi/MQTT to Home Assistant
ESP32 firmware bridging the 1550 nm MOPA (Koheron CTL200 seed + Agiltron
M511 two-stage EDFA) to MQTT/HA as a single device. Telemetry and control
for both instruments verified end-to-end: MQTT command -> seed lasing ->
booster ramp to 27 dBm (~515 mW) at the documented 2500 mA operating point.

- PlatformIO/Arduino project, project-local venv, Makefile upload flow
- Koheron ASCII driver on UART2; Agiltron binary 0x55AA driver on UART1
- HA discovery (sensors, binary_sensors, switches, numbers); LWT availability
- Static IP, firmware current clamps on seed and booster pump
2026-06-19 10:16:50 +01:00

42 lines
1.3 KiB
Makefile

# Koheron CTL200 -> WiFi/MQTT bridge on ESP32.
#
# All commands run PlatformIO from the project-local venv, so you never need
# `pio` on your PATH. Just `make`, `make upload`, `make monitor`.
VENV := .venv
PIO := $(VENV)/bin/pio
PORT ?= /dev/ttyUSB0
ENV := esp32dev
.PHONY: help build upload monitor flash clean detect erase venv
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-10s\033[0m %s\n", $$1, $$2}'
build: $(PIO) ## Compile firmware
$(PIO) run -e $(ENV)
upload: $(PIO) ## Compile + flash to the ESP32
$(PIO) run -e $(ENV) -t upload --upload-port $(PORT)
monitor: $(PIO) ## Open serial monitor (Ctrl-C to exit)
$(PIO) device monitor --port $(PORT) -b 115200
flash: upload monitor ## Upload then immediately open the monitor
detect: $(PIO) ## Identify the chip on $(PORT)
$(VENV)/bin/python -m esptool --port $(PORT) chip_id
erase: $(PIO) ## Erase entire flash (factory reset)
$(VENV)/bin/python -m esptool --port $(PORT) erase_flash
clean: $(PIO) ## Remove build artifacts
$(PIO) run -e $(ENV) -t clean
# Recreate the venv if it is missing (e.g. fresh checkout).
venv $(PIO):
python3 -m venv $(VENV)
$(VENV)/bin/pip install --upgrade pip
$(VENV)/bin/pip install platformio esptool