Hi there,


Have you ever come across Lego? Lego Technic? Maybe as well Lego Mindstorms? If you have never seen Lego Mindstorms - it is like toys for Engineers. Just go on Youtube and see what others have built with it - Guitar Player, Packaging Line and much more cool stuff.


We are currently at Hannover Messe presenting integration of IIoT and Industry 4.0 to the PI System. My idea was - have a nice and sweet demo using some equipment which is highlighting this message. So I used a Lego Mindstorms Education Kit to build a small color sorter line. However, Lego Mindstorms EV3 also offers a lot of sensoring like ultrasonic distance, temperature, position, power consumptions of equipment, color detection etc. So this data shall be collected to the PI System.


My first approach was - just create a small programm which collects data for the runtime of the program and sends it to the PI System. The EV3 brick has a lot of connectivity options like USB, Bluetooth or WiFi. So I thought it would be a great idea to collect data, send it over one of these options to a PI Interface or Connector and push it up to a PI System. Since we are presenting at HMI as a partner of SAP, there was also the idea to have that data later in the SAP HANA Database - using our PI Integrator for SAP HANA.

So how do we get data from a Lego Mindstorms EV3 robot into SAP HANA? Exactly! Through the PI System infrastructure.


What I did in the first place was to find a sponsor who is paying the toys (thanks to our marketing department ). Then I built the robot - I felt again like a kid following the instructions in the documentation to assemble it. You may never think that if you see a bunch of Lego bricks in front of you that this is getting something conveniant.


Once the device is assembled you have something like this:


Once the "Brick" (which is the central control unit of the robot - quite powerful hardware) is connected to the computer via Bluetooth, WiFi or USB you can transfer the data directly to the NI LabView to see the data. You can also collect that data and export it into a flat/excel file. This is not really straight forward because I wanted to automate processes. Since Lego Mindstorms has a really huge community around the world (similar to PI Square), you can find solutions for nearly everything. So this helped me a lot to come closer to a solution of my problem. I was looking for a way how to capture the data online from the robot via an online connection directly to my computer. On GitHub I found a very nice project which has solved my little problem. It is a kind of messenger app which can send and receive bluetooth messages (GitHub - jovabel/EV3Messenger: The EV3 Messenger is a C# program for exchanging messages with a Lego Mindstorms EV3 robo… ).


The next step is the programming. Thanks to the Educational version of Lego Mindstorms, you have a Lego branded version of National Instruments Labview which makes it rather simple and intuitive to program the EV3 brick. Since the color sorter is a pre-defined program, I just decided to have my own program built and just collect data but let the equipment move a little bit. I ended up with a small program which runs for a minute, moves the feed line with the motor from the start to the end and collects data from temperature, ultrasonic, color detection and motor power usage to PI. My program is just resetting the robot at the start of the program, moving the motor of the feed line by 10 degrees and collects the data once a second for a 60 seconds period. The data gets written to both a flat file on the brick (which I used as a first approach using PI Connector for UFL to write the data to PI) and to a paired bluetooth device. This device is actually my laptop where the slightly modified EV3Messenger is collecting the data and sending it to my PI Server hosted in the Microsoft Azure Cloud.


My program for the robot was built using the intuitive UI of the Lego LabView. So it is pretty straight forward. You have different building blocks which can be tied together and finally you have the robot singing and dancing .



So when you run the program it sends out bluetooth messages and also writes the data to the brick in a flat file - very simple.

Now, how gets data into PI? As said, my first approach was using the flat file and have that thrown in front of the PI Connector for UFL. But that was a very manual process. Since the bluetooth connection with my Dell E7440 was not stable at all, this was the only solution but pretty manual because I had to use the software to do the manual data download. Thanks God, I received a new laptop Dell E7470 where the Bluetooth runs rock solid and I can make use of the EV3 Messenger. So now I can have a direct connection to collect data online and have it written to PI. My modified tool looks like this:

2017-04-26 (1).png

So now if I start the program at the robot the EV3-to-PI Interface listenes on the bluetooth messages which come in and send them using AF SDK directly to associated PI tags. You can see that writing the data to only six PI tags tags takes some time. It is due to that I only had my mobile phone as an internet hot spot - and you know Hannover Messe is a busy place (and the PI Server sits in Azure Cloud).


Finally, if data is sent to PI, it gets simultaneously dashboarded using PI Vision. When I do a data logging, I also create an Event Frame and also in addition a Notification - and using the PI Integrator for SAP HANA we have data available within the HANA database.


Down below some more screenshots:

2017-04-26 (2).png 2017-04-26 (3).png

2017-04-26 (4).png notification.png

sap hana.png lego mindstorms experiment.jpg


The bottom line: Data from an autonomous device captured into PI and shipped into SAP HANA. If this is not an IoT scenario...