/legoirc-server

Server side of the LEGO IR Controller system.

Primary LanguageCMIT LicenseMIT

LEGO IR Controller Server

Description

This is the server side of the LEGO IR Controller system which is trying to provide an alternative to the original IR controller by using a smartphone application. The smartphone application communicates with the IR receiver on the vehicle (e.g. 9398 4x4 Crawler) through an IR transmitter controlled by a Raspberry Pi installed on the vehicle. The smartphone communicates with the Raspberry Pi through Wifi signal which allows to extend the operation range and makes the control of the vehicle less prone to signal loss which is often experienced with the original IR controller. This solution also allows to use the Raspberry Pi Camera to stream realtime video from the vehicle and display it on the screen of the smartphone. The installation is non-invasive and doesn't require any modification of the vehicle.

9398 4x4 Crawler with Raspberry Pi

Requirements

To make this project working with your LEGO Technic vehicle, you should have the following:

Total cost: £89.11

Installation

The installation is described for the 9398 4x4 Crawler). Similar setup can be applied with small modifications to any other vehicles.

The IR transmitter should be connected to the Raspberry Pi on the PIN 17 (VCC), 18 (DAT) and 19 (GND) as shown on the following image:

IR Transmittor pinout

The IR transmitter can be installed on the top of the roof facing towards the IR receiver. Because even sunlight can interrupt the IR communication, it's recommended to cover both the IR transmitter and the receiver.

IR Transmittor installation

The Raspberry Pi itself fits nicely into the rear cargo area of the car. It only requires to remove the site bars and install them in horizontal position above the Raspberry Pi.

Raspberry Pi installation

The battery for the Raspberry Pi should be installed above the front axle to balance the weight.

External battery installation

Raspberry Pi Camera can be installed either on the bar above the IR receiver or in the from of the car (requires longer flex cable).

Raspberry Pi Camera installation

Raspberry PI configuration

The installation of the legoirc-server on the Raspberry Pi is described for Arch Linux ARM. For other distributions it's necessary to compile it manually. In general, the legoirc-server depends on bcm2835 library which must be installed before the compilation. If your distribution is not using systemd then you have to write your own init.d scripts or run the legoirc-server manually every time you start up the Raspberry Pi.

The installation procedure on the Arch Linux ARM, including the installation of systemd services, is as follows:

pacman -S base-devel
curl -o PKGBUILD https://aur.archlinux.org/packages/le/legoirc-server/PKGBUILD
makepkg --asroot --install --syncdeps

Protocol

Each command sent to the server should be terminated by a newline (\n). If the command consists only of a newline, the connection will be closed. The commands can be sent by a specially created Android application or by the legoirc-client which is part of this project:

legoirc-client -s <IP_of_your_RPi>

Even easier is to use telnet:

telnet <IP_of_your_RPi> 8160

The direction commands correspond with the layout of the keys on the numeric keyboard:

Commands

The only non-directional command implemented so far is the command "X" which shuts down the Raspberry Pi server.

Known issues

The video stream has about 1 second delay due to the transport through the network and the encoding/decoding of the video.

The control can be delayed due to the network communication.

Only the control channel 1 works.

Only the "Combo PWM mode" is implemented.

There might be other issues. Please report them on the project site.

License

This software is licensed by the MIT License which can be found in the file LICENSE.