Linux and the LEGO Powered Up MINDSTORMS

Nothing new here, just my personal notes with the LEGO Hub from 51515 MINDSTORMS Robot Inventor Set.

Most of it based on this post by Jason Jurotich.

I have a LEGO 51515 set, thanks to the ROBOTMAK3RS community (and still not sure yet if I am willing to pay so much money for this set).
I have an Android Lenovo tablet and an Android Samsung phone. Installed LEGO MINDSTORMS App on both but only can managed to use it on the phone – the tablet doesn’t get Activities so I could not even make Charlie play the drums.

I also have a Ubuntu Linux laptop. It will have to work – last time I revived a Windows 10 virtual machine it took me a whole night just to update it in order to install LEGO App. No way!!

So tanks to Jason post I can connect my laptop to the Hub:

sudo rfcomm connect hci0 A8:E2:C1:96:5B:9A

this gives me a ‘/dev/rfcomm0’ serial device and I can access the REPL environment in 2 different ways:

directly through a terminal client like ‘picocom’:

picocom /dev/rfcomm0 -b 115200

with a more proper tool like ‘rshell‘:

rshell -p /dev/rfcomm0 repl

When accessing the REPL, the hub is sending values so we need to Ctrl+C to get the prompt.

I found out that accessing the REPL through ‘picocom’ lead to strange behaviors afer a while (like commands being executed but not returning to the prompt and after a while not being able to access again, like if the Hub was rebooting immediately after accessing it) so I am now using ‘rshell’.

I also installed Adafruit ‘ampy’ from pypi. This way I can send and execute a micropython script from my laptop without accessing the REPL:

ampy --port /dev/rfcomm0 run

But since I know nothing about LEGO micropython environment I will use REPL a while more (before flashing Pybricks on it and probably forgetting LEGO firmware like I did with MINDTORMS EV3 original application once I discovered ev3dev).

When accessing the REPL environment this is the welcome message:

Welcome to MicroPython!
 For online help please visit
 Quick overview of commands for the board:    -- print some general information
   hub.status()  -- print sensor data
 Control commands:
   CTRL-A        -- on a blank line, enter raw REPL mode
   CTRL-B        -- on a blank line, enter normal REPL mode
   CTRL-C        -- interrupt a running program
   CTRL-D        -- on a blank line, do a soft reset of the board
   CTRL-E        -- on a blank line, enter paste mode
   CTRL-F        -- on a blank line, enter filetransfer mode

of course ‘’ and ‘hub.status()’ only work after we ‘import hub’ library – something probably obvious for someone used to (micro)python and REPL but not so obvious for newcomers.

Other important methods in this library


{'temperature': 23.8, 'charge_voltage': 7591, 'charge_current': 251, 'charge_voltage_filtered': 7583, 'error_state': [0], 'charger_state': 0, 'battery_capacity_left': 80}         

‘hub.repl_restart()’ – I had used this method a few times today… and I hate reboots!


So lets find out if I can make Charlie play the drum with micropython.

2 comentários em “Linux and the LEGO Powered Up MINDSTORMS”

  1. Hi, have you managed to connect your ubuntu machine and work with LEGO 51515?
    I’m trying to prepare for the delivery of the set and I can’t see how to use it with Linux. I must get something like Scratch to work if I’m to give it to my family to play with.

    Any finding are much appreciated.

    1. Hi
      I did… but I don’t like it. I am now using Pybricks firmware with the 51515 hub so I use Chrome IDE and the very same micropython I use with EV3 and the Technic hub.
      If you really want something Scratch-like I am sorry but your only options are Windows/Apple/Android.
      This new “paradigm” isn’t as open source friendly as the EV3 was.

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *