Documentation > Instruction Manuals
Train Controller - 2.01.006
Introduction



Brick 2.01.006 is a WiFi enabled controller for LEGO® PF trains. The controller supports bidirectional communication by means of MQTT messages.
Specifications
  • Input voltage: 9V
  • PF motor ports: x1
  • Auxiliary device ports: x1 3pin, 3.3V
  • WiFi: 2.4GHz, 802.11 b/g/n
  • Integrated battery sensor
Installation
Configuring the Controller
The first step of the installation process is the configuration of the control to be able to connect to your WiFi network and MQTT broker. This step only has to be done once as long as you don't change the WiFi network of MQTT broker settings. The controller has to be configured with our nControl™ software; this guide explains step-by-step how to do that.
Controlling the Train
Train Control Tiles on a Computer
This getting started guide explains how to control your train with a control tile from a computer running nControl™.
Train Control Tiles on a Mobile Device
You can control the trains with a phone or tablet by exporting the nControl™ project to a web interface and opening that on your mobile device. This guide explains how to do that.
nControl™ Python™ Scripts
You can also control the train using Python™ scripts. This course will help you getting started. You can find all the available commands in our API Reference.
MQTT Commands
The following MQTT commands can be used to pilot the train controller with a DIY software application.
Note that, before you can communicate with the controller, you have to configure it: WiFi network, password, MQTT broker, etc. This has to be done with our nControl™ software, this page explains how to do that.
Once the controller is configured, you can communicate with it using MQTT messages. When the controller is powered up, it will immeditaly try to connect to the specified WiFi network and MQTT broker; it will keep on trying until it's connected.
To send data to the controller, publish messages using the topic nControl/Alias for you messages, where Alias is the name for the controller you specified during configuration in nControl™. To receive messages from the controller subscribe to the topic nControl/Alias.
The information on this page is intended for personal, non-commercial, use only. Commercial use without prior written approval by 4DBrix LLC is prohibited.

Battery Power
bat
Requests the current battery power.

Auxiliary Device Commands
cmd,2,data
Send data using a serial transmission over the auxiliary device port 2. Before sending data you first need to configure the port with the prt command.
  • data the information that is transmitted over the serial port.

Motor Commands
mot,b,power
Move the train in the reverse direction.
  • power specifies the motor power and ranges from 0 (no power) to 1023 (full power).
mot,f,power
Move the train in the forward direction.
  • power specifies the motor power and ranges from 0 (no power) to 1023 (full power).
mot,s
Makes the train stop by simply turning off the motor power.
mot,s,reverse_power,delay
Makes the train stop using a reverse power pulse.
  • reverse_power specifies the reverse power as a value between 0 (no power) to 1023 (full power).
  • delay specifies the duration of the reverse power pulse in milliseconds. The controller accepts integer values ranging from 0 to 5000 ms.

Port Configuration
prt,2,digout
Configures the auxiliary device port (port #2) as a digital out port.
prt,2,serwri,baud
Configures the auxiliary device port (port #2) as a serial transmission port.
  • baud specifies the baud rate of the serial communication. The follow rates are supported: 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400 and 250000.

Digital Output
set,2,high
Sets the output level of the auxiliary device port to high.
set,2,low
Sets the output level of the auxiliary device port to low.
set,2,value
Sets the output level of the auxiliary device port to the specified value using PWM.
  • value specifies the PWM value. The controller accepts integer values ranging from 0 to 1023.
Troubleshooting
nControl™ cannot connect to the controller with USB:
  • Check whether you're using a USB data cable. Some cables, typically the ones that are designed to charge mobile devices, only have power lines; they don't have any data lines. With a Power Only USB cable nControl™ will not be able to connect to / communicate with your WiFi controller.
  • Make sure the WiFi controller is not connected to be battery box when you plug the USB cable. The WiFi controller can start-up in two different ways: WiFi mode and USB mode. When the controller sees the 9V power of the battery box when it boots it will start up in WiFi mode and not attempt to make a USB connection. So make sure the controller is not powered when plugging the USB cable.
nControl™ cannot connect to the controller with WiFi:
  • Make sure the MQTT broker is running.
  • Check the MQTT broker dialog window for warning or error messages. They might provide clues on how to resolve the problem.
  • Make sure the WiFi controller has the correct settings: WiFi network, password, MQTT broker IP, etc.
  • Check the batteries of your PF battery box.
  • Make sure there are no firewalls blocking the MQTT signals. You can use our online MQTT test app to check whether you can communicate with MQTT broker over your network.
The controller does not respond to the instructions:
  • Make sure the alias of the controller is the same as the label of the train control tile. The system is designed to control multiple trains so the controller will only respond to the instructions coming from a control tile with the same name as the alias of the controller.