Language: EN

m5stack-unit-v2-un-mini-pc-con-camara-para-aplicaciones-de-ia

M5Stack Unit V2, a mini PC with a camera for AI applications

The M5Stack Unit V2 is a device that combines a mini computer with Linux and a full HD camera, designed to perform artificial vision and machine learning applications.

We have already seen several devices from the M5Stack family on the blog. Most members of the manufacturer are based on our well-known ESP32 SoC, including the Timer X Camera.

However, the M5Stack Unit V2 is something different from most of M5Stack’s products. In this case, we are dealing with a complete mini computer running Linux.

The core of the M5Stack Unit V2 is a Sigmstar SSD202D, a dual-core Cortex A7 processor at 1.2Ghz. This is accompanied by a 128MB DDR3 memory and a 512MB NAND Flash memory.

m5stack-unit-v2-schematic

The device includes a 2mpx resolution camera (Full HD 1920×1080), with a 68º FOV and a 60cm - infinity DOF. The designation is GC2145, but not much more information is available about the camera or its manufacturer.

In addition to this, the Unit V2 has 2.4 GHz WiFI, USB Type C, integrated microphone, SD card reader, and a groove type connector for UART. It also has LAN interface through the USB Type C. It even has its own cooling fan.

m5stack-unit-v2-open

All this in an impressive size of only 48*18.5*24mm and a weight of 62g. Really, you can’t imagine how small it is, just a little thicker than an M5Stick.

The M5Stack Unit v2 has a plastic case, which includes an LED and a button. The set is completed with two supports, just like with the Timer Camera X. One with a thread, for example, to use on a tripod, and one to use with Lego pieces.

2021-07-28-21_10_50-window

Finally, the module is powered at 5V. The maximum consumption is as low as 500mA, again quite impressive for a mini PC.

Logically, we cannot expect a particularly powerful mini PC. Its dual-core ARM 1.2Ghz processor performs well, but it “only” has 128MB of RAM.

In comparison, a Raspberry Pi Zero W has a single-core ARM11 processor at 1Ghz, much more modest. On the other hand, it has 512MB of RAM, shared with the GPU.

As for the price, we can purchase it for 70-80€ (with the current chip-shortage situation, I can’t specify much more). Quite high, if we compare it to a Raspberry Pi Zero W 2 for example. But, it’s the price of having a mini-PC + Full HD camera in such a small device.

Testing the M5Stack Unit V2

Updating the M5Stack Unit V2

The first thing when using the M5Stack Unit V2 is to update its firmware. This is because the early versions had a bug in the WiFi operation. Later versions fixed this error.

Therefore, it is best to update to the latest version, which we can download from here. Next, we copy the ‘M5UnitV2UpdPackage.img’ file we just downloaded to the SD card.

With the Unit V2 turned off, we insert the SD card. We press the Unit V2 button and connect it to power (to the USB). The LED should blink, and then we release the button and wait for the button to turn off.

In my case, the LED did not blink. So I crossed my fingers, and waited a few minutes for the LED to turn off. And it worked correctly.

Built-in applications

The M5Stack Unit V2, like all products in the family, comes with a pre-installed demo. Let’s review these built-in functionalities.

Access the video stream

First, we can directly access the camera stream through a web browser. To do this, we connect the Unit V2 to a computer, and it will recognize the device as a LAN network.

Now, we can access using the following URL

http://10.254.239.1/video_feed

If we have configured the WiFi (we will see it later), we must access without the need to have it connected to a computer (only powered, with a USB charger, for example), replacing the IP with the one assigned by the Router.

Factory demo

The Unit V2 comes with a pre-installed Factory Demo, in order to illustrate different functionalities of the device.

This application is quite impressive and complete. It is developed in C++, and its code is available at https://github.com/m5stack/UnitV2Framework.

To access it, we simply connect from a web browser to the device’s IP.

http://10.254.239.1

Again, if we have already configured the WiFi, we will have to replace the default IP with the one assigned by the router.

The factory demo includes fully functional applications for Audio FFT, face detection or recognition, line tracking, motion detection, shape classifier, or object recognition, among others.

m5stack-unit-v2-builtin

All the examples provide a UART output of a JSON file, indicating the relevant events of the same. For example, motion detection, or recognizing an object. Detailed information of each example at this address.

This means that they can be connected to another device, such as an Arduino or an ESP32. This allows us to even integrate these factory demo examples into real projects.

In addition, M5Stack provides a web service at this link, which allows us to train the learning models and then introduce them into the Unit V2. It is a simple platform, although not particularly practical (it requires too much manual labeling work).

Regarding the performance of these computer vision and machine learning applications, I must say that it is quite good. The dual-core Cortex A7 processor is noticeable, and the applications run quite smoothly even in FullHD.

Jupyter notebook

The other built-in functionality included in the M5Stack Unit V2 is the Jupyter notebook. For those of you who don’t know, Jupyter is an application that is gaining some fame, focused on Python training.

Jupyter allows you to create “notebooks”, understood as a file containing text and code blocks. The code blocks can be executed independently, or all at once sequentially.

m5stack-unit-v2-jupyter

Therefore, it is an interesting tool to create instructions or tutorials, where the student can check the results as they progress through the text.

In the case of the Unit V2, it includes a few examples that include control of the LED, microphone, UART, and camera, available at https://docs.m5stack.com/en/quick_start/unitv2/jupyter_notebook

Accessing the Linux system

The built-in and demo applications of the Unit V2 are quite striking. But, knowing us, we are going to want to access Linux, in order to unleash the full potential of the device.

However, it must be taken into account that the Linux distro used by the M5Stack is, in fact, a very limited and restricted function. We are not talking about Debian, or Lubuntu, or even ArchLinux.

Here we do not have a package manager, nor much possibility to install software, not even a C++ compiler (something inexplicable, when its own factory demo is written in C++).

This is, in my opinion, the biggest flaw of the device. As if that were not enough, the documentation also does not help particularly in this regard.

However, there are certain operations that we can perform. Let’s see some of them.

Connect via SSH

First, we can connect via SSH to the M5Stack Unit V2. To do this, we can use a terminal console (Linux or WSL on Windows).

ssh m5stack@10.254.239.1 

Although I recommend using mRemotenG that we saw in this post, and WinSCP to manage files as we saw in this post.

The user and password of the device are as follows.

user: m5stack
pwd: 12345678

user: root
pwd: 7d219bec161177ba75689e71edc1835422b87be17bf92c3ff527b35052bf7d1f

Configure WiFi

To configure the WiFi of the M5Stack Unit V2, first we must generate a password for the ssid and password of our network. To do this, we run the following command, replacing the data with our network

sudo wpa_passphrase ssid password

It will give us a result like the following,

network={
        ssid="ssid"
        #psk="password"
        psk=44116ea881531996d8a23af58b376d70f196057429c258f529577a26e727ec1b
}

After this, we edit the wpa_supplicant.conf file

sudo nano /etc/wpa_supplicant.conf

Here we copy the data we obtained in the previous step, leaving the file as follows,

network={
    ssid="ssid"
    psk=44116ea881531996d8a23af58b376d70f196057429c258f529577a26e727ec1b
}

Ready, we have the device connected to our WiFi network.

Run C++ applications

Of course, we can run C++ compiled applications on the M5Stack Unit V2. Unfortunately, as we have commented, it does not include any compiler by default.

However, we can compile an application from another computer, as we saw in How to cross compile for ARM from x86/x65. Then, we move the file to the device, change the permissions to allow execution, and we can run our program.

Run Python applications

The distro of the M5Stack Unit V2 comes with the Python interpreter pre-installed, as well as with the OpenCV library. In fact, it is necessary for Jupyter to work, which we saw earlier.

Therefore, it is possible to run Python scripts directly on the Unit V2. I take this opportunity to remind you of the post Our first program in Arduino and How to use Arduino and the PySerial library.

Conclusion

The M5Stick Unit V2 is a real hit by M5Stack. It’s amazing to have a complete computer with Linux in a device of that size, and also with a Full HD camera and UART output.

It is often said of something “it’s so small it fits in your pocket.” But in this case, it’s that two or three can fit, depending on the pocket. It’s impressive what they have achieved at the hardware level.

The main purpose of the Unit V2 is computer vision and machine learning. However, even without these two components, it would still be an interesting product in itself.

The only “but” is that, and I’m sorry to say it, this time the software and documentation are not at the level that M5Stack usually provides.

A real shame, because with a better distro, or if the bootloader allowed booting an OS from the card, we would be facing one of the most interesting machines of the moment.

Nevertheless, the Unit V2 is a very interesting machine for computer vision and machine learning training, or for domestic or #maker projects.

For example, we can think of incorporating it into a robot to follow lines or recognize markers, in a robotic arm to grab a ball, and many other projects that require a camera.