Please read the general section first!
The MattzoLayoutController is designed to receive input signals from digital sensors like reed switches and pass the information on to the Rocrail via the MQTT broker.
The MattzoLayoutController connects to MQTT as described in the “General” section.
When a connected sensor has contact with a vehicle, the controller instantly sends a sensor event to the MQTT broker.
When a sensor looses contact for more than 0,1 seconds (configurable), the controller sends the “sensor disconnected” event to the MQTT broker.
Up to nine reed sensors (or other digital sensors) can be connected directly to the controller. With port extenders, even hundreds of sensors can be connected to the controller.
For more information about reed sensors refer to the sensor section.
The following wiring diagrams shows two options to attach sensors to the controller.
The first diagram shows an example wiring of eight sensors and a status LED:
The status LED indicates to WiFi connection status, the MQTT connection status and lights up when one or more sensors are triggered. The status LED is very handy in practice. Therefore, this wiring option is recommended.
The next diagram displays the option of the MattzoSensorController with 9 sensors and no status LED.
Instead of using pin D0 for the status LED, it is used for connection a ninth reed sensor. The option should only be used if you want to connect all of the nine connectible sensors to the controller. As the ESP-8266 has no internal pull-up resistors for pin D0, a strong resistor (10 or 100 kOhm) is required to pull up the port when the reed sensor is released. All other ports are pulled up internally by the MattzoController-Firmware.
Please note for both options, that the reed sensor on pin D8 must be connected to 3V3, not to GND on the other end. This is because D8 is actually pulled down, not pulled up.
One more thing: it is important to understand, that pins D3 and D4 must not be pulled down when you power the controller up, and that pin D8 must not be pulled up during boot. If you do that, the controller will not boot. That means, that the controller can not be successfully powered on when a train is on the sensors. The solution is easy: move the train a little bit away and reboot the controller. Or, even better, do not use D3, D4 and D8 for sensors if you don’t have to.
- I/O board with micro controller. We have used a NodeMCU Amica Modul V2 ESP8266 ESP-12F. Similar modules should work as well.
- Up to 9 reed sensors (details: see sensor page).
- A pull-up resistor (10, 47 or 100 kΩ) for pin D0 (if sensor is installed on this pin).
- A LED (if status LED is installed). Make sure that the LED cope with the power supply. Depending on the type of LED, they each might need one additional resistor wired in series.
- Basic stuff like bread board, wires etc.
The controller can be powered up with a simple USB charger over USB or some other power supply of similar voltage that is connected to the VIN and GND pins of the controller.
Please read the MLC general page first.
To configure the firmware configuration, you need to edit the controller configuration file (controller_config.h).
In this file, the following sections are relevant:
- SERVO WIRING CONFIGURATION
The section is clearly marked in the standard configuration file, and the different parameters are explained with code comments, so you shouldn’t have too many problems to understand what you need to do.
For a start, you should set the pinType to LOCAL_SENSOR_PIN_TYPE, as this is the setting for normal, local sensors. For an explanation of the other sensor types, please refer to the Sensors page.
For general setup instructions please refer to the “General” section.
To setup the sensor in Rocrail, navigate to the interface tab of the sensor definition. The MattzoControllerID must be used as “Bus” parameter, and the port of the sensor as “Address”.
The first port has the number “1” (not “0”).
For using the sensor as a wheel counter see next section.
ALL OTHER INFORMATION ON THIS PAGE CAN BE NEGLECTED AND HAS NO MEANING!
Wheel Counting / free@enter
Rocrail has a very nice feature called “Wheel counter”. The idea is that the wheels (i.e. magnets) that pass a sensor are counted. By comparing the number of wheels that have passed the last sensor, Rocrail is able to notice that a train has completely passed a specific sensor on the layout. Rocrail is using that information particularly on “Enter”-Sensors of a block, and frees the block ahead after all “wheels” have passed the sensor. This speeds up train operations on your layout significantly, as the last block is available for other trains a lot earlier compared to waiting until a train has reached the “In”-Sensor of the subsequent block.
To use this feature safely, please make sure that not only your loco, but also the last waggon of your train has a magnet installed. Commuter trains need magnets in the front and in the end.
More details can be found in the Rocrail documentation.