Connect Android Device to LEGO MINDSTORMS EV3
This example shows how to connect an Android™ device to a LEGO® MINDSTROMS® EV3
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.
- Download and Install Simulink Support Package for Android Devices (required)
- Download and Install Simulink Support Package for LEGO MINDSTORMS EV3 (required)
- Complete the Getting Started with Android Devices example.(recommended)
- Complete the Getting Started with LEGO MINDSTORMS EV3 Hardware example.(recommended)
- EV3 Brick
- Android phone or tablet
- EV3 Wi-Fi Dongle
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 Android 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 LEGO MINDSTORMS EV3 model.
4. Double-click the TCP/IP Send block and change the Remote address to the IP address of the Android device.
5. In the Android model, click Deploy to Hardware button of Android model to run this model on your Android device.
6. In the EV3 model, click Deploy to Hardware 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.
Other Things to Try
- On the EV3 model, change the Button block to left, right, and center. Instead of the Slider block, use the Location block and try sending location data from the Android device to EV3.
- Complete the Control LEGO MINDSTORMS EV3 Robot Using Android Device example.
This example showed you how to:
- Wirelessly connect an Android smartphone to an EV3 using TCP/IP.
- Remotely control the status light on the EV3 using the Android Slider block.