Control model railroad with Wifi and Mqtt

  • Beginning to develop some pcb in Kicad, easier to solder and looks a lot better.

    First one is a card that can control 8 servos for turnouts or other things.


    Next one is a more flexible card that can control signals, lights and servos too. Mix as you please.


    And the rescent one that I just finished in Kicad is a card for 4 block occupancy detectors.

    It is a quite simple and cheap type based on a bridge rectifier, ac optocoupler, led and a couple of resistors.


    Picture borrowed from:


    "S" from this card goes to "S" on the flexible card above, and when f.ex. a locomotive is on a detected piece of track

    then a message is sent to those that are interested, signals, track plan, what ever.

    And as a final for this year a made a video on a 3D-printed, wireless, modular track plan that we use:


    That's all for now.

    Happy New Year! :)

  • Goodmorning,

    Do you have already some code for the handheld and MQTT for the Basic Station and maybe some schematics about this all?

    with regards,


  • God evening, Johan.

    Code and schematics are just prototype versions. The code for the handheld control is quite large and not well commented,

    and it is still growing. The schematic is not so complicated.

    I´m going to make a new version for the base station this autumn with the new DCC++EX and a more powerful motor driver (IBT_2).

    Maybe I can share that if someone is interested, and go from there.


  • I have become quite familiar with Kicad (for making PCB) and tried to make some cards with the more efficient microcontroller ESP32.

    It has a lot more I/O pins so I don't need as many cards to control everything.

    There is an ESP32 in my handheld control but there I only use a few pins.

    So my first ESP32 card looks like this


    Made some minor flaws on the design that doesn't make any difference, will fix it for the next version.

    It has 24 pins (4 are just inputs) and can control leds, servos, buttons, whatever.

    Just solder the components needed, not all of them.

    An extra bonus is that ALLPCB sent me these cards for free, no charge, not even for freight.

    I have soldered two of these cards and will install the firs one next week.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!