1 Create the leJOS bootable SD card
By default the EV3 bricks starts the Lego menu application. To get access to the Linux file system and execute Python scripts or Java byte code, it is necessary to configure a special SD card and insert it into the SD card slot. If the card present, the EV3 boots the leJOS menu application instead of the Lego menu. If you remove the card, the brick starts again with the Lego menu. Proceed as follows to create the leJOS SD card:
- Provide an empty Micro SD card with minimum 4 GB and maximum 32 GB. It is highly recommended to use the fast class 10 type.
- Insert the card into a card reader
- Download the card image from here (ev3sdcard.zip, approx 400 MB) and unpack it in any directory using an unzipper that supports large zip archive (e.g. WinRAR). You get a single file with .img extension. Start an USB Image Utility to burn the image to the SD card. Recommandationunder Windows: USB Image Tool, under Mac/Linux: ddutility. Be very careful to select the SD card drive and not something else, otherwise you destroy your data.
- Insert the SD card into the EV3 card slot and press the turn-on button
2 Boot EV3 with leJOS
3 Connect to the EV3
All connections to the EV3 use the TCP/IP protocol, but the physical transport channel may be USB, Bluetooth or WLAN. When booted with leJOS, a Linux Secure Shell (SSH) server with Secure Copy (SCP) is started (but no SFTP server). The EV3 replies also to ping requests. Ping is the easiest way to check if the IP link to the EV3 is working. The default IP address (for Bluetooth and USB) is 10.0.1.1 as seen on the leJOS start screen.
You may connect your PC via USB, Bluetooth or WLAN. Bluetooth is the recommended connection method because you don't need a cable nor a WLAN adapter. (Consult the APLU site to get information how to connect via USB or WLAN)
The Bluetooth Personal Area Network (PAN) protocol is used to establish an IP connection via Bluetooth. The EV3 acts as IP access point like a smartphone or PC based access point (Bluetooth tethering).
On the remote PC/smartphone/tablet you must pair the EV3 like you do it with any other Bluetooth device. Proceed as usual and perform a Bluetooth search. When the EV3 is seen, add the new device. If a security code is shown, confirm it ; if a code is required, enter 1234.
To enable IP over Bluetooth, the EV3 must act as PAN server. Proceed as follows:
Bluetooth PAN under Windows:
- After the pairing is performed (and each time the EV3 is turned on), the EV3 must be made active as IP Access Point. In Devices and Printers right click the EV3 symbol and select "Connect using > Access point".
Bluetooth PAN with a Smartphone/Tablet (Android):
- Perform a Bluetooth search and pair the EV3 while ignoring the passkey. If a passkey is requested, enter 1234.
- Enable Internet Access (or something similar) for the paired Bluetooth device (with Android only available since version 4.0+)
Bluetooth PAN under Linux (Ubuntu):
- In the Bluetooth Setting you must enable the checkbox "Use your mobile phone as a network device (PAN/NAP)"
- After the pairing is performed (and each time the EV3 is turned on), the EV3 must be made active as IP Access Point. In the Network Icon Menu click the EV3 Network. After a while a confirmation box is shown.
Bluetooth PAN under MacOS:
- Click the Bluetooth icon and perform a Bluetooth device search. Pair the EV3 while ignoring the passkey (if a key is required, enter 1234). In the Bluetooth control panel the EV* will be shown as not connected.
- Click the Bluetooth icon and move the cursor to the EV3 entry. Select the "Connect to network" option.
You can change the robots friendly Bluetooth name in the EV3 menu under System - Change name. To enter a new name, move the cursor block using the cursor keys. Confirm each letter by pressing Enter. The new name is displayed at the bottom of the screen. (The letter U stands for uppercase, l for lowercase, X for delete and D for done.) To finish the modification, move to D and press Enter. Then reboot the EV3 to make the name active. There is no other action needed on the EV3 to establish the IP connectivity over Bluetooth.
4 Start/Update the BrickGate server
Python scripts executed on the remote PC or locally under the EV3 Python interpreter access the Lego hardware via BrickGate, a TCP/IP gateway running on the EV3. BrickGate is started from the leJOS menu like any other leJOS program. It's main purpose is to interpret commands from a Python client, but it also displays a menu to start Python scripts autonomously.BrickGate is part of the SD card distribution. If you make it the Default Program, it can be started with one click each time the EV3 boots.
If accidently you delete the BrickGate program or you want update it, download the latest version from our Webserver and install/replace it automatically by clicking the following link. Make sure that your PC is connected to the Internet and the Bluetooth link to the EV3 is established.
The WebStart displays a security warning. It is signed by Comodo for ACE information technology AG, (Switzerland) and does not pose a risk.
5 Write you first program and execute it in direct and autonomous mode
The script is now stored in the Brick's Linux file system (in /home/python/scripts) and you see it immediately in the the BrickGate menu. Move the arrow with the Up-Down buttons, so it point to the script name you want to execute. Then press the Enter button. The script executes again, even if the brick is disconnect from the PC.
Because no error messages are shown in autonomous mode, you better test your script in direct mode first. But if a local script causes your EV3 to block or lasts too long, you may stop it any time by pressing the Down+Enter key combination. This will stop the BrickGate server too and you must restart BrickGate (but not the EV3!) to execute another script.
(If you want to explore your EV3 Linux operating system and use the Python interpreter (or Java) in a SSH shell, you find more information here).