Major Alvega

Major Alvega is a fictional hero from my childhood favorite comic magazine, “O Falcão”.

My real name is Jorge.

I am an Electrical Engineer by formation but systems administrator by chance.

Married, owl father of 2.

Recently returned from the LEGO’ Dark Night thanks to a LEGO Mindstorms EV3 set that my wife gave me us a birthdat present. Then discovered the Raspberry Pi, the Portuguese LEGO community, the ev3dev project, the LEGO MCP and not even God knows what more will come…

I don’t really have a focus in a particular area but I do like to demonstrate STEM concepts to my kids and I like to use to use LEGO as a framework or a tool for that purpose. So usually my “LEGO things” are more focused on showing some kind of functionality instead of looking nice. That also means that I fall to the Dark Side quite often, cutting some LEGO wires, soldering, gluing or painting something – hey, not my fault that LEGO doesn’t make LASER or UV bricks 🙂

Also quite often my small proof of concepts tend to grow too much and too fast. My first “Raspberry Pi and LEGO” project, an escalator, wasn’t tall enough for my older kid… trying to find more liftarms I soon found that there is a large online market of second hand LEGO… I was doomed!

When I started this blog, I often stated that I am not a programmer. I used some programming languages at university but I really never learned how to program so most of my coding is in fact a lucky mix of googling, copy&past and try&error iterations. Nevertheless, after some experiments with Bluetooth Low Energy protocol, I found myself doing something that might resemble real code thanks to the generosity of lots of people that opened their source to the world. Some even directly helped me!

So yes, I strongly support openness. Not just open source but open idea – science evolves “on the shoulders of giants” but also on the shoulders of lots of anonymous people who keep pushing it a bit further every day. That’s one of the reasons I like so much to use ev3dev with the LEGO MINDSTORMS EV3 – the possibilities are truly amazing.

Strong coffee, dark beer, apple-cinnamon, Xutos&Pontapés and Martini complete the whole pack.

You might also find me at:

14 comentários em “Major Alvega”

  1. Hello Fellow Scratch/LEGO Hacker:

    A project got started on the LEGO Education Community forums to create a set of “open” (OER) lessons that would teach Scratch Programming and LEGO WeDo Mechanics/Robotics together. If this project interests you, please take a look at the discussion so far at [https://community.education.lego.com/t5/WeDo/A-book-for-Middle-School-Age-Students/m-p/11741#U11741].

  2. Hi,

    I’m currently working on a project where I have the new lego train and I want it to be controlled from a raspberry pi. I’ve been looking through your posts and trying some of the stuff you’ve tried. My main issue at the moment is connecting the pi to the powered up hub via Bluetooth – I can never establish a connection. I was wondering if you could give me some pointers either on what to do or where to look to find answers. Thanks

    1. Hi!
      If you have a recent RPi it should have a BLE 4.0 compatible hci device.
      I suppose you are using Raspbian linux.
      Check for the presence of the hci device with “hciconfig -a” and if is “up” the scan for your Powered Up hub with “hcitool lescan”, you should see the BT address of your hub (don’t connect your app, it will lock it).
      Then it’s really just a matter of using the same gatttool commands I use, just changing my BT addresses for yours.
      If / when that works, then you can try python later but for now bash / command line is better (and faster).

  3. Hi,
    I am programming an app for powered up and I know you have some experience with PU HEX codes.
    My question: Do you know the command for getting the battery value, so I mean the remaining power of the battery and the command for changing the name of the hub? Thanks in advance;)

    1. Hi!
      To change the name you should send a “Hub Property Message” (0x01) for the “Hub Property Reference” of the “Advertising Name” (0x01) using the “Hub Property Operation” SET (0x01) and then the payload. So if you want to rename to “ABC” (0x41 0x42 0x42 ASCII chars) you should send an 8-byte message:
      08 00 01 01 01 41 42 43

  4. Hi,
    I am working on an android app for PU.
    My question is: What is the command to change the name and the command for reading the battery value? It would be very nice, if you would help me to answer this question;)

    P.S. I have read the PU documentation on GitHUB, but I still don t understand it:(

    1. Hi.
      You should send a “Hub Property Message” (0x01) including as “Hub Property Reference” the Battery Voltage (0x06) and as “Hub Property Operation” the command (0x02 for “enable updates” or perhaps 0x05 for “request update”). Since these commands have no extra payload they are 5-byte long messages:
      05 00 01 06 02/05
      I used Nordic nRF Connect on my Android phone and connected to a PUp hub, enabled notifications (tap the right icon with 3 arrows pointing down) and then sent “0500010602” (the middle icon with the single arrow pointing up) and got “060001060664”, that means I got back a 6-byte long “Hub Property Message” returning an update of the “Battery Voltage [%]” with the payload on the last byte so 0x64 = 100% Battery.

  5. Hi! Could I ask you about MicroPython + EV3? Does USBport work correctly for webcam? If it’s ok can we use OpenCV framework? Is computational power (for vision data processing) of EV3brick going to be enough?
    Thank you in advance)

    1. Micropython cannot use directly the webcam. Not because it doesn’t work but because micropython has no modules for that purpose (AFAIK). Same for OpenCV. But python (regular python 3) work, you just need to use full ev3dev environment instead of just micropython. But OpenCV is heavy… last time I installed in ev3dev took lots of time and recognizing my face (Logitecg C170 webcam) took 3 or 4 minutes.
      Better if you use OpenCV on a Raspberry Pi or a laptop and command the EV3 from there.

      1. “Better if you use OpenCV on a Raspberry Pi or a laptop and command the EV3 from there.”
        Is the connection between the RPi (laptop) and EV3 via Bluetooth? In that case, do I have to install ev3dev or micropython is Ok?

        1. Can be but I like to use Wi-Fi. When you use the micropython image on EV3 you are already using ev3dev, LEGO released micropython over a standard ev3dev image. But if you use OpenCV on the RPi you need to run linux, can be standard Raspbian image from the Raspberry Pi Foundation or ev3dev custom image. If you choose a laptop, can be any operating system you like and feel confortable with, as long as it supports OpenCV. If you are going to control the EV3 from a laptop, you don’t need micropython/ev3dev/linux on the EV3 side, native firmware (I mean no microSD card at all) is enough as long as your code can talk with your robot (through USB, Bluetooth, Wi-Fi…)

Responder a Major Alvega Cancelar resposta

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