Both MINDSTORMS EV3 and SPIKE Prime have an onboard BlueTooth chip. It turns out that it isn’t too hard to make them talk to each other. In this article, you’ll learn how you can do it with a little MicroPython script. After following this tutorial you will be able to design your own remote control devices with a SPIKE Hub. You can make any design that fits the EV3 robot you want to control.
The fun thing about the setup I’m describing here is that you only need a script on the EV3 brick. A script on the SPIKE Prime hub is entirely optional. You can use the matrix or run a script that auto-centres motors and it will not interfere with the BlueTooth stream!
For those of you who don’t like to read, I have explained it all in a YouTube video. The SPIKE Prime hub connection is near the end of the video. While you watch, you can like and subscribe to be notified of cool new ideas!
How to connect a SPIKE Prime hub to EV3 for remote control
Time Needed : 5 minutes
How to connect a SPIKE Prime hub to a MINDSTORMS EV3 brick over Bluetooth
- Boot your EV3 brick into a recent ev3dev
You can use either the official Python release from LEGO or use the latest ev3dev image. Burn either of those to a MicroSD card, insert it in the MINDSTORMS brick and boot it. Wait until the boot completes and you see a menu.
- Start scanning for Bluetooth devices
Go to Wireless and Networks > Bluetooth. In that screen enable Bluetooth and set Visible to enabled. Select the 'Start Scan' option.
- Enable BlueTooth on the SPIKE Prime hub
Turn on your SPIKE Prime hub and press the little BlueTooth button until the led ring around it starts blinking blue.
- Select the SPIKE Prime hub in the Devices list on your EV3 brick
Scroll down until the SPIKE Prime hub appears. It could take a few seconds. I named my hub “Antons Second Hub” because I have two SPIKE Prime hubs.
- Write down the MAC address you see
The address is made up of 6 hexadecimal numbers. In my case, it was 40:BD:32:42:EB:54. I press the Pair button here just to be sure. But I'm not 100% sure this is necessary. I haven't tested the script without pairing. Maybe let me know in the comments?
- Run a MicroPython script on your EV3 brick that listens to the SPIKE Prime hub
Now you can run any script on your EV3 and start remote controlling. The SPIKE Prime hub is spewing telemetry data over BlueTooth all the time, so no need to run any scripts there!
Further down in this article I have an example script for a LEGO MINDSTORMS Rubber Band Cannon omnibot. You can tweak that code to fit your robot design. Remember to replace the MAC Address in the script with the MAC Address of your specific hub!
I have a separate VS Code tutorial where I explain more in-depth how you can run scripts on the EV3 brick.
- A PC or Mac with MS Visual Studio Code
- MicroSD Card
- SPIKE Prime hub
- MINDSTORMS EV3 brick
Here’s a video of the result. Remember to like and subscribe if you haven’t done so yet.
The MicroPython script for a SPIKE Prime remote control
Below you will find the script I used in my video. It is based on a Pybricks project. Credits to them for reverse-engineering the telemetry stream and writing a class around that. The easiest way to use it is with the LEGO MINDSTORMS VS Code extension. In VS Code, click the MINDSTORMS icon in the very left toolbar. Create a new project. Add a file called ‘connection.py’ and copy the respective script in there. Finally, replace the contents of the main.py file with the other script.
The Omnibot as shown in the video demo
You can download full code and building instructions from the digital downloads section.
Rubber band cannon omnibot Building Instructions – PDF
Strafe, aim and drive in every direction with this gun platform for a double-barrel rubber band cannon. Rain down terror on your housemates in Video conferences. To build this, you need three LEGO MINDSTORMS EV3 medium motors and a Large Motor. You need a bunch of Technic parts too, but they are pretty common. Here the full part lists:
With some tweaks the could also control a regular drift car.
VR Drift Car Building Instructions
With these building instructions, you can build a LEGO MINDSTORMS Drift Car. It has an optional camera mount so you can race in VR with your FPV goggles. This car is great for use with a PS3 controller, a <a href="https://antonsmindstorms.com/2020/02/14/how-to-connect-a-ps4-dualshoc…