Main Content

Connect Android Device to LEGO MINDSTORMS EV3

This example shows how to connect an Android® device to a LEGO® MINDSTORMS® EV3 brick.

Introduction

Android phones and tablets provide wireless access and a user interface. LEGO MINDSTORMS EV3 is a programmable robotics construction set. The EV3 Brick is a programmable intelligent Brick that acts as the brain of your robot, controls motors and sensors, and also provides wireless communication through Wi-Fi® and Bluetooth®. Using these two, you can, for example, control an EV3 robot using an Android device by connecting them wirelessly.

This example provides two Simulink models:

  • In the Android model, the value selected using the Slider is sent to the EV3. Data received from the EV3 is shown on the Android device screen.

  • In the EV3 model, data received from the Android device is displayed on the EV3 and used to control the status light. The press state of the Up button on the EV3 is sent to the Android device.

With these models, you will:

  • Set up a network connection between an Android device and an EV3.

  • Configure and run a Simulink model for the Android device to send and receive TCP/IP packets from the EV3.

  • Configure and run a Simulink model for the EV3 to receive and send TCP/IP packets to the Android device.

Prerequisites

Required Hardware

Task 1 - Configure Network Connection

Set up a network connection between an Android device and an EV3. The communication protocol used in this example is TCP/IP.

1. Connect your Android device to your Wi-Fi network.

2. Check Settings > About phone/device > Status > IP address to find the IP address of your Android device (Note: The location of the IP address under Settings might differ based on your device manufacturer or Android version).

3. Plug the EV3 Wi-Fi Dongle into EV3 Host USB Port.

4. On the EV3 screen, navigate to Settings > Wi-Fi.

5. Enable Wi-Fi, and search and connect to the same Wi-Fi network to which Android device is connected.

6. Navigate to Settings > Brick Info. Find the IP address under IP address.

Task 2 - Configure and Run Models on Android Device and LEGO MINDSTORMS EV3

1. Open the androidev3getconnected Simulink model.

2. Double-click the TCP/IP Send block and change the Remote address to the IP Address of the EV3 brick.

3. Open the ev3_android_getconnected Simulink model.

4. Double-click the TCP/IP Send block and change the Remote address to the IP address of the Android device.

5. On the Hardware tab of the Android Simulink model, in the Mode section, select Run on board and then click Build, Deploy & Start to run this model on your Android device.

6. On the Hardware tab of the EV3 Simulink model, click Build, Deploy & Start to run this model on your EV3 hardware.

7. On the Android device, change the Slider value to control the status light on the EV3.

8. On the EV3 hardware, click the Up button. The state of the button displays on the Android device.

For more information on configuring Simulink models on Android devices and EV3 Hardware, see Run Model on Android Devices and Run Model on EV3 Hardware.

Other Things to Try