Let’s focus on connecting components to the sensor shield (sensors, switch motors, IR LED modules and relay module) through servo extensions and jumpers; carefully follow the instructions contained on this page keeping an eye out for this general connections layout, just to get an idea of the result:


Fear, huh? But let’s make one step at a time:



IR LED modules – Trains control
ardutrain-wifi-led-irThe IR LED modules will replace the LEGO remote control. Each IR LED module covers an angle of 90 degrees; you can combine up to 4 modules to create an emitter that covers 360 degrees and can send commands to trains in all directions.
In the image to the right side you can see a single IR LED module and four IR LED modules joined together by the pin welding – S + on each side of the module.

The IR LED modules should be placed at the strategic points of the diorama, raised more than the IR receivers mounted on the trains; I suggest to put them at the corners of the diorama (in the case of a single module or pair of modules) while I recommend placing them centrally in the diorama (in the case of four welded modules together) to make a 360 degree emitter.

99% of the instances in which the train will not take command, will be caused by the incorrect positioning of the IR LED modules.

To connect the IR LED modules to the sensor shield, take the Y extension and connect it to the sensor shield pin A0, making sure to follow the following order with the connector:

  • The black cable of the extension goes to the row G;
  • The red cable of the extension goes to the row V;
  • The white cable of the extension goes to the row S (signal).

Now we need to plug the two connectors of the Y extension: we have to make sure that they reach the IR LED modules placed on the diorama; to do this, we can connect multiple servo extensions in series. Once you reach the IR LED modules you will notice that you can not directly connect the Y connector with the IR LED module; that’s where you will need female-female jumpers. Then connect the two Y extension connectors to the IR LED modules, via jumpers, as shown:

  • The black cable of the Y extension goes, by jumper, to GND;
  • The red cable of the Y extension goes, by jumper, to 5V;
  • The white cable of the Y extension goes, by jumper, to S.

We must be careful not to confuse the pins – S + on both sides with the 5V and S GND pins in the center of the IR LED module; here is a diagram of the connections:




4DBrix switches motor – Switches control

First of all: make shure you have left switch motor for left switch and right switch motor for right switch; remove the yellow lever and leave the switch in “turn” position, after that, put the motor instead of the yellow lever, like this picture:


After completing the mechanical connections, connect all the servomotors to the extension cables (you can connect more than one in series if needed) in this way:

  • The black cable of the extension goes to brown cable;
  • The red cable of the extension goes to red cable;
  • The white cable of the extension goes to orange cable.

After that, connect all the extensions cables of the servomotors to the sensor shield following this order:

  • Switch 1 to pin 2;ardutrain-wifi-switches-connection
  • Switch 2 to pin 3;
  • Switch 3 to pin 4;
  • Switch 4 to pin 5;
  • Switch 5 to pin 6;
  • Switch 6 to pin 7.

As for the IR LED modules, be careful to connect the black cable of the extension to the row G, the red cable to the row V and the white cable on the row S.

You can also follow this instrunctions video.



4 channel relay module – Lights, motors and electrified tracks
The relay module has 4 independent channels that can be considered as switches that open or close an electrical circuit. We can use these “switches” to turn on and off, for example, LEGO motors (such as 10247 – LEGO Ferris Wheel) or to control the LED lighting of the diorama or to give power to old electrified LEGO tracks (to stop and start the train).

We can connect the relay module to the sensor shield only with jumpers to keep it close to Arduino and Raspberry; make the following connections:

  • The relay module pin IN1 to the sensor shield pin A1 (row S);ardutrain-wifi-rele-module-connection
  • The relay module pin IN2 to the sensor shield pin A2 (row S);
  • The relay module pin IN3 to the sensor shield pin A3 (row S);
  • The relay module pin IN4 to the sensor shield pin A4 (row S);
  • The relay module pin GND to the sensor shield pin A5 (row G);
  • The relay module pin VCC to the sensor shield pin A5 (row V).

lego-cableTo connect a LEGO Power Functions motor to a relay, we need to separate the negative and positive motor cables: four wires exit from the motor, the two at the sides (right and left) are the ones we need. If we don’t want to cut the motor cables directly, we can connect a LEGO extension cable and cut that instead. In the picture to the side we can see the positive cable (9V) and the negative cable (GND).

Now cut the LEGO connector at the end of the motor cable and connect the negative cable directly to the negative of an adjustable 3 – 9Volts power supply (to choose the motor rotation speed), while the positive cable should go into the right clamp of a relay as shown in the figure below; then complete this by connecting the central clamp to the power supply (positive) with a cable.

To realize LED lighting we can buy LED kits: they are easy to install and ready to use components that consist of white LEDs with the LEGO connection, wires and connectors to multiply the outputs to which the LEDs can connect.

Here are some photos of illuminated buildings with LED kits:


To connect the lighting kits to the relay module, just like the motors, cut one of the two power cable (positive or negative) and let it pass for a relay; in this diagram we can see the control of two separate lighting lines (building and street lamp):



Finally, if we want to control old electrified tracks (and the old LEGO trains), just buy an adjustable power supply (or use the old LEGO potentiometer), pass a cable through a relay (positive or negative) and connect both of the two cables to the eletrified track (just as I explained for the motors).



4DBrix sensors – Automations
Let’s connect the sensors (up to 6) that will be used to detect the trains passing on the tracks and start any associated automation (for example: train stop, wait 10 seconds, open switch 2, set relay (light) 4 to ON, train start).

Simply connect the sensor to the extension in this way:

  • The black cable of the extension goes to brown cable;
  • The red cable of the extension goes to red cable;
  • The white cable of the extension goes to orange cable.

With the extensions (connected to the sensors) we arrive near the sensor shield (connecting even more than one extension if it is needed) and connect sensors to the sensor shield as follows:

  • Sensor 1 to sensor shield pin 8;ardutrain-wifi-sensors-connection
  • Sensor 2 to sensor shield pin 9;
  • Sensor 3 to sensor shield pin 10;
  • Sensor 4 to sensor shield pin 11;
  • Sensor 5 to sensor shield pin 12;
  • Sensor 6 to sensor shield pin 13.





Webcam, audio and final connection

If you want to add video streaming to your ArduTrain WiFi system, simply connect a USB webcam to the Raspberry USB; and if you want to play audio files on automations simply connect normal PC speakers to the audio jack on Raspberry.

Finally, connect Arduino to Raspberry via USB cable.



Since Raspberry can not power Arduino, sensor shield, and all components via the USB cable; we need to power everything separately; take the cable with the DC socket and the two wires (red and black) and connect them to the sensor shield terminals following this order (like in the picture):

  • The red cable of the DC socket goes to VCC terminal;sensor-shield-alimentazione
  • The black cable of the DC socket goes to GND terminal.

The Arduino power supply will then be connected to this socket (do not connect it yet); so, in total, we have two power supplies for ArduTrain WiFi: one for Raspberry and one for Arduino, sensor shield and all components.


Now that we have connected all components to the sensor shield and our diorama has become a jungle of cables (LOL), we can install the Software on Raspberry.




Previous page Next page