Märklin model trains, traffic automation and control

Strange you should menton that, as I'm collecting my thoughts on using MQTT to control a model railway.

Before I retired I worked as a computer science and microelectronics lecturer. One of my tasks was thinking-up and running projects for the students. Over a period of time I got a series of students to build a model railway based on CAN bus (as CAN was used by the major employer who supported the college).
The speed of the train was controlled by PWM as applied to track's voltage.

I use Wemos D1 Mini (ESP8266) modules around my house for reporting temperature/humidity and for controlling relays and operating LEDs - all via MQTT mesages and Node-RED.

My idea is to modify the train's motor connection...

  • disconnect it from the track's pickup
  • install an ESP-01S (tiny microcontroller) in the body of the train or the tender
  • install an H-bridge chip and attached the motor to it

So the ESP-01S is powered from the track via an on-board voltage regulator. The (full) track's voltage is applied to the H-bridge with is driven by some pins on the ESP-01S (e.g. PWM and Dir).

I'm planning on working on this as a Winter-2022 project with a couple of my grandsons. I've done a few simple tests with a length of track and have got promising results. I implemented a similar PWM control system for a couple of slot racing cars way back in 2019 - which was just pure fun.

I should add that my projects are 'trivial' compared with @Mrb32 magnificent layout/system.

Here a photo of an ESP-01S (25mm by 15mm)
ESP-01s