Download

Please press the following button to download the MattzoController firmware:

Download
MattzoController Firmware V0.4.1

Code Structure

The firmware is contained in a zip file. Unzip the zip file into a folder of your choice, e.g. C:\Users\Mattze\Documents\MattzoController.

Then you need to MOVE (NOT COPY!) the files in the “library” folder to the Arduino library folder. On Microsoft Windows, do something similar like:

  • Navigate to C:\Users\Mattze\Documents\MattzoController\libraries
  • Move the “MattzoBricks” folder to C:\Users\Mattze\Documents\Arduino\libraries

The exact directory names will vary on your computer system.

The following table contains a list of files and their purpose as of firmware version 0.4:

FilePurposeTo Dos
MattzoController_Library.hShared code library for all MattzoControllersMove to library folder.
MattzoController_Network_Configuration.hNetwork configuration shared by all MattzoControllersEdit and move to library folder.
MattzoPowerFunctions.cppLibrary required for IR supportMove to library folder.
MattzoPowerFunctions.hLibrary required for IR supportMove to library folder.
MTC4PF.inoFirmware for MTC4PF
MTC4PF_Configuration.hConfiguration for your MTC4PFs*Edit if required
MTC4PU.inoFirmware for MTC4PU
MTC4PU_Configuration.hConfiguration for your MTC4PUs*Edit
MattzoSwitchController.inoFirmware for MattzoSwitchController
MattzoSwitchController_Configuration.hConfiguration for your MattzoSwitchController*Edit if required
MattzoSignalController.inoFirmware for MattzoSignalController
MattzoSignalController_Configuration.hConfiguration for your MattzoSignalController*Edit if required
MattzoSensorController.inoFirmware for MattzoSensorController
MattzoSensorController_Configuration.hConfiguration for your MattzoSensorController*Edit if required
MattzoLayoutController.inoFirmware for MattzoLayoutController
MattzoLayoutController_Configuration.hConfiguration for your MattzoLayoutController*Edit if required
Firmware files and their purpose

* If you have multiple Controllers of the same type, but with a different configuration, you may copy these files and change the #include directive in the corresponding firmware code file before compiling / uploading. This can faciliate the management and maintenance of your MattzoControllers significantly, because you can have the specific configuration and the firmware itself in different files.

History

  • V0.4.1 of April 3rd, 2021
    • MattzoLayoutController
      • Delayed primary boom barriers for enhanced realism.
      • Virtual sensors for switches, level crossing and bascule bridge to make sure that the controllers have received a command and to prevent trains to enter critical track sections before switches, boom barriers or bascule bridges are safely set or closed.
  • V0.4 of March 20th, 2021
    • Unification of MattzoSwitchController, MattzoSignalController and MattzoSensorController into a single MattzoLayoutController.
    • Support for port extenders PCA9685 and MCF23017 to control hundreds of signals, switches and sensors with a single controller.
    • MattzoLevelCrossingController for level crossings (integrated in MattzoLayoutController).
    • MattzoBridgeController for bascule bridges (integrated in MattzoLayoutController).
    • Bug fix for MTC4PU, improving stability of WiFi connection and controller operations.
    • Several other bug fixes and improvements.
    • Additional example configuration files for various MattzoControllers.
  • V0.3 of January 3rd, 2021
    • MattzoTrainController for Powered Up (MTC4PU): initial release.
    • MattzoTrainController for Power Functions (MTC4PF):
      • Complete code refactoring.
      • Separation of configuration from firmware code.
      • Support for LEGO Infrared Receiver 8884.
      • Support for 4DBrix WiFi Train Receivers.
      • Multi-train-support.
    • Automatic train lights for all MattzoTrainControllers.
    • Boot problem fix for all ESP8266 based MattzoControllers.
    • Emergency stop for all trains if signal or sensor controller disconnect from MQTT.
    • Optional status LEDs for all MattzoControllers.
    • Network logging (syslog) and over-the-air (wireless) firmware updates.
    • MattzoController have now correct hostnames on the intranet.
    • Safety feature for MattzoSwitchController to prevent breaking switch servos on obvious misconfigurations.
    • A large variety of other new features and improvements.
  • V0.2.1 of November 19th, 2020
    • Changes in firmware for MattzoTrainController for Power Functions:
      1. Bugfix.
      2. Power range optimized (introduction of MIN_ARDUINO_POWER parameter).
  • V0.2 of October 25th, 2020
    • First release of the MattzoTrainController for Power Functions.
    • Central network configuration file to configure SSID, WiFi passphrase and MQTT broker IP address.
    • Various code improvements.
  • V0.1 of June 6th, 2020
    • First publically released firmware for MattzoSensorController, MattzoSignalController and MattzoSwitchController.

Roadmap

  • V0.4.2 (~May 2021)
    • MattzoTrainController for Power Functions (MTC4PF)
      • Multi-train support
    • MattzoSpeedController
      • Measure the speed of your LEGO trains and show it on a display!
  • V0.5 (~ July 2021)
    • MattzoTrainController for Bluetooth (MTC4BT)
      • ESP-32 based
      • Supports LEGO Powered Up and SBrick
      • Enhanced and replaces MTC4PU
  • V1.0
    • Unification of all train controllers into a unified MattzeTrainController (MTC) based on ESP-32.
    • MattzoBlink (very flexible and powerful train light system).
    • MattzoCentralController
    • MattzoDisplayController
    • MattzoSpeedController
    • MattzoRemoteController

The roadmap may change any time without notice.

25 thoughts on “Firmware

  1. Hi Mattzo,

    I’ve been using your firmware with great success sofar, so first: thank you for that! My first success was with the reed sensors. I have those working now and I’m very pleased with the results sofar. I have other parts and pieces on the way for the next steps I’m planning for my layout.

    I’m very excited about the path you’re taking and the content you’re sharing on the subject. As a 20+ year software developer and a Lego train enthusiast, I can’t wait to be able to contribute to the project.

    I have seen a couple of simple improvements sofar. Because I found a lot of the same code in all controllers, the first most obvious improvement for me would be to move some general setup logic (code and variables) to separate libraries for reuse. This could significantly simplify the actual code in each controller and make the hole project more maintainable in the process.

    I’m no expert on micro controllers, but it seems you have that part covered. I’d like to try and integrate the SBrick into Rocrail as an alternate train controller. I’m planning on doing that anyway and I’d love to donate the code to the project, if you’d like. This existing project seems like a good start: https://github.com/BensonHsu/SBrick-Framework

    Please let me know if there is any way I can currently contribute to the project. I’d be more than happy to help!

    Cheers,
    Raymond

  2. Hi Ray,
    substantial code unification is one of the key issues of Firmware 0.3 and leads us out of the prototype phase to a more mature approach of developing and maintaining the firmware. Regarding contribution: check your mail. 🙂

    Cheers,
    Mattze

  3. Hello Mattze,

    Just downloaded V0.3 for my PU trains, and after some fiddling around, succes!
    It works perfectly, now to configure Rocrail and built some sensors and switches.
    (and the garden layout)
    Thank you for all your effort for making this, I’m a very happy man.

    Keep up the good work, can’t wait voor de levelcrossingcontoller….

    Greetings from the Netherlands,

    Paul

    1. Hi Paul,
      thank you very much for your feedback! I am glad that it works on your end as well!

      We will publish some more very interesting stuff for you in the near future, so stay tuned!

      Cheers,
      Mattze

    1. sorry i forgot to install this Legoino library.

      i use Amica V2 Nodemcu
      ESP8266MOD 12-F
      but now i got this:
      In file included from C:\Users\WORK\Documents\Arduino\MTC4PU\MTC4PU.ino:64:0:
      C:\Users\WORK\Documents\Arduino\libraries\MattzoBricks/MattzoController_Library.h:31:26: fatal error: PubSubClient.h: No such file or directory
      #include
      ^
      compilation terminated.
      exit status 1
      Error compiling for board NodeMCU 1.0 (ESP-12E Module).

      is there an other thing to install?

  4. Hi, ich habe gerade angefangen mit der Firmware herumzuspielen und versuche gerade die Software für die Sensoren auf meinen NodeMCU Lua Lolin V3 Modul, d.h. auf den ESP8266 12E zu spielen, nachdem ich mir nach herumsuchen im Web die Bibliothek für dieses Board heruntergeladen und installiert hatte, jedoch meckert nun Arduino IDE und behauptet “Fehler beim Kompilieren für das Board NodeMCU 1.0 (ESP-12E Module)”. Habe ich das falschle Board ausgewählt, oder die falsche Bibliothek heruntergeladen? Denn das V3 Board steht dort nicht zur Auswahl, obwohl auf diversen Seiten zu diesem Board diese eine Bibliothek angesprochen wurde.
    Würde mich über Hilfe sehr freuen!
    VG
    Flec

      1. Ich habe den Fehler gefunden und PubSub ebenfalls installiert. Jetzt habe ich noch eine letzte Frage: Wo findet man die Syslog.h Datei? Denn diese ist das einzige Problem worüber Arduino IDE gerade meckert.
        LG
        Flec

  5. Arduino: 1.8.13 (Windows 8.1), Board: “Arduino Uno”

    MTC4PU:31:10: fatal error: Lpf2Hub.h: No such file or directory

    #include “Lpf2Hub.h”

    ^~~~~~~~~~~

    compilation terminated.

    exit status 1

    Lpf2Hub.h: No such file or directory

    I’m struggling to find the problem with this.

  6. Hi I’m trying to upload the firmware for a switchcontroller to my NodeMCU V2 WiFi Amica ESP8266 ESP-12E. But when compiling i get this error:
    “”
    Meerdere bibliotheken gevonden voor “Servo.h”
    In file included from C:\Users\henk\Documents\Arduino\MattzoController_Switch\MattzoController_Switch.ino:13:0:
    Gebruikt: C:\Users\henk\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\Servo
    C:\Users\henk\Documents\Arduino\libraries\MattzoBricks/MattzoController_Library.h:44:22: fatal error: tinyxml2.h: No such file or directory
    Niet gebruikt: C:\Program Files (x86)\Arduino\libraries\Servo
    #include
    “”

    can anyone help with this one? I allready tried to install the TinyXML library without luck…

    1. Hello Henk,
      we have now set-up a support forum. You can find in the navigation bar under “My MattzoBricks”. Please post your question there, as it will be relevant for other people as well!

      I will close the commenting function on the documentation pages shortly.

      Thanks + good luck,
      Mattze

  7. Many Thanks Mattze! I started developing my own code for automating my LEGO trains, was a great experience, but your work has taking it to a whole different level. I started w/ the signal crossing and then moved to the switches. I was saving the train automation for last. Your code covers everything; Rocrail has been the hardest part to get going, but it’s awesome. I’ve connected MQTT into Node-Red for monitoring, and working on some control w/ it. That’s where I started with the automation, having found internetoflego.com prior to your work.

    1. Hi Dan,
      happy to hear that. Love to hear further success reports. I am also collecting pictures and videos of people having built their layout with MattzoBricks train automation. The best ones are being published on mattzobricks.com, section “projects”.

      Cheers,
      Mattze

  8. Hi Mattze,
    thanks for the great work. What are your thoughts on publishing this on github or any similar service so that people can contribute more easily?
    Cheers,
    Sebastian

    1. Hi Sebastian,
      we are planning to do that. Haven’t decided on the right point in time, though. If you are interested to contribute, send me an e-mail.

      Cheers,
      Mattze

  9. Hi Matthias,
    Great work!
    I have looked through your code, but why haven’t you added OTA updates and a simple webpage for configuring the controller (Acces point and normal wifi mode)? All “soft” items can be stored in de nvs of an ESP32, basicly making it a compile once use many times firmware.
    I have done the STA and AP mode, nvs stuff and OTA stuff, so if you need a hand?
    Regards,
    Hilbert

    1. > … why haven’t you added…

      There are many things we could do, and sometimes we have to focus on the things we actually do (in our sparetime). 🙂

      By the way, OTA is indeed already integrated. Check the file MattzoController_Library.h and search for “OTA”.

      We have thought about web configuration feature since quite a time, and maybe we are going to add this at a later point.

      1. Hi Matthias

        considered hosting on github? i just implemented sta+ap and mattzo_network_configuration with configmanager.

        Grüße
        Georg

        1. Hi Georg,
          as you can see in the discussion thread above, we are planning to release the repository to the public one day, likely with version 1.0. At the moment it would be too much work for me and the other members of the core development team. We wouldn’t be able to check all the pull requests that we’d get, and therefore it would be too frustrating for people who would like to contribute. If we believe you are qualified to contribute, it’s better to get in touch with me directly and check if there are other ways of cooperation.

          Thanks for your patience.

          Cheers,
          Mattze

Leave a Reply to Sebastian Cancel reply

Your email address will not be published. Required fields are marked *