Skip to content

Latest commit

 

History

History
81 lines (50 loc) · 3.67 KB

README.en.md

File metadata and controls

81 lines (50 loc) · 3.67 KB

Lire cette page en français English, page shown

Smoke Machine, the smoke module

A smoke module for MicroCoaster layouts. An ESP32 switches a miniature smoke machine through a MOSFET, heater and fan both built in, for a set duration, then goes back to rest.

Version 0.1.0-alpha

01 How it works

The logic fits in two states. The module is ready, it is asked to smoke for N seconds, it smokes, it goes back to ready. Nothing else.

READY: at rest, heater unpowered, ready for an order. The SMOKE command moves it to SMOKING: smoking for the requested duration, then straight back to rest once the time is up. HEATER_MAX_ON_MS cuts out at 15 seconds whatever happens.

No timing is handled locally. If a minimum interval between two puffs is needed, it is for the controller to impose it. The module obeys.

That choice is deliberate: two components each deciding on their own when smoke may start again always end up contradicting each other. One authority, the controller.

02 Safety

HEATER_MAX_ON_MS bounds a cycle at 15 seconds. It is the only local protection, and it is essential: a heater left powered by a lost order or a dropped link heats without limit.

The MOSFET has to be sized for the machine's actual current, and its heat dissipation checked.

03 Hardware

The ESP32 DevKit decides the duration and supplies no power at all. Its GPIO 18 pin drives the gate of an N-channel MOSFET, which switches the machine's actual current. The MOSFET drain goes to the negative terminal of the smoke machine, which has its heating element and fan built in. All three share a common ground, without which the gate drive has no reference.

The smoke machine already has its heater and its fan, so the module drives a single line. In include/config.h: PIN_HEATER sets the control pin, HEATER_MAX_ON_MS the maximum duration of a cycle.

04 Protocol

Serial console, at 115200 baud:

status          current state, time remaining, maximum duration
setdur 10       sets the duration of a cycle, in seconds
smoke           triggers a cycle if the state is READY

WebSocket, in JSON:

{ "cmd": "STATUS" }
{ "cmd": "SET_DURATION", "s": 10 }
{ "cmd": "SMOKE" }

Replies:

{ "ok": true, "state": "READY",   "duration_s": 10 }
{ "ok": true, "state": "SMOKING", "remaining_ms": 9800 }

05 Bringing it up

Requires PlatformIO inside Visual Studio Code.

pio run                  # build
pio run -t upload        # upload the firmware
pio device monitor       # serial console, 115200 baud

06 Ecosystem

The specification, the wiring and the protocol are settled. The firmware is still to be written: today the repository holds only this documentation, the changelog and the licence.

The common base for every module is the WiFi Manager, and the driving is done from the WebApp.


MicroCoaster · Author: Cybertrist