IoT Edge on the Jetson Nano

[Reading Time: 8 minutes]

In combination with machine learning and embedded, the topic of the right hardware often comes up. In my perception, the Jetson family is mentioned immediately afterward (well, it’s just a selective perception 😊). The little one in the family is the Jetson Nano. Which I use in this series. As a “maker” hardware, it has a decisive advantage over, for example, the RasPi; the Nano is equipped with a GPU from NVidia, which is why it is a good way to implement ML projects.

The ecosystem around the nano is good – not too much of everything, but not too little either. There are SDKs that lay the foundations for ML projects and give access to GPU power, even a dedicated NVidia Cloud (NGC) is available, which you should also try out. In terms of hardware, there is also a lot to upgrade for the Nano. From fans to WiFi cards to self-printed cases (I let the case out), there’s actually everything you need. Also, the countless tutorials that you can get either via the well-run NVidia page to get started with ML, or numerous videos on Youtube are available.

3D printed case

For a basic setup of the Jetson Nano, I strongly recommend that you visit the “Getting Started” page at the manufacturer. There is a very well and detailed description of how to make the hardware breathe. To get your Jetson Nano set up for IoT Edge and thus for the Postbus project, you should now consider the following.

First steps

Jetson Power

In order to work more intensively with the GPU, you should first check the Power setting (NVP Model). Your Jetson Nano has four modes that can be “powered”. Via MicroUSB cable, via the power supply, PoE (Power over Ethernet) and also via GPIO plug-in connection. In general, however, I would leave it at the two variants MicroUSB and power supply.

To get the maximum for your Jetson Nano, you should connect a power supply. While only 2A @ 5V is available when power is supplied via USB, you can feed in 4A @ 5V with the power supply (if you use the right power). However, you should be careful to jumper beforehand. To do this, set a jumper as marked with “1” at the bottom of the picture, then you can insert the power supply and set it off.

Marking of the jumper and the connection/cutout of NVidia
The jumper on my board (marked in green)

After connecting with the appropriate power supply, you should also check whether your nano is also running in maximum mode. To do this, you can put an SSH on your device and type the following into the console:

sudo nvpmodel -q
NV Power Mode: MAXN

If your output looks like this, then you don’t need to worry about it.
Otherwise (instead of MAXN there is maybe 5 W) type the following one; with this, you unlock the full power:

sudo nvpmodel -m 0
NV Power Mode: MAXN

In Mode 0 (MAXN), all four CPUs are operated, whereas in Mode 1 (5W operation) two CPUs are switched off.

At this point, I advise you to build you on/off switch. It is practical, believe me! Otherwise, you always have to type on it and sudo reboot. Just don’t remove the power supply. The hardware can suffer from this. At least the OS or the SDCard can get something (I experienced!!).

If you bridge the first pins of J40 (see diagram above), the nano goes down (ordinary).

In addition, you should add a fan to it. The Jetson Nano can get very hot (60/70°C and loosely more). For this you can buy one directly from the listening trade, or, if you still have a lot of fans from old computers around, to use one. Now the hardware should be ready for IoT Edge Setup.

Connected fan to cool the CPU/GPU

Setup IoT Edge

Installing IoT Edge is relatively simple when you go through the guide to it from Microsoft.
As a side note: IoT Edge is not yet GA for devices with ARM64 architecture (generally available / preview – my booth: 1.0.9-rc5). I.e. you can expect one or the other problem – but in the end, these are small because the level of development is already very advanced.

However, before you start installing, you should check before you want to check whether the Container Runtime on the Jetson Nano is compatible. This has the effect that the actual installation fails with the Moby engine or only throws warnings – but does not want to work afterward. I had problems with it, so I had to uninstall Docker CE completely. Probably it was because of my JetPack version. If you follow Microsoft’s IoT Edge installation, you’ll install the Moby-based Engine – then everything is fine again. To be on the safe side, compare the JetPack version number with the one on the homepage and make it if necessary. an update.

To complete setup, you need to complete several steps.
1) You’ve created an IoT Hub and set up a Device Identity in it.
2) You installed the IoT Edge on the Jetson Nano and assigned it to the device identity created in the IoT Hub.
The two components are now connected to each other. The details of setting up can be found in the aforementioned Microsoft documentary (don’t have to give a post repeating what’s better written where else 🙂 ).

1) Create virtual identity 2) Transfer it to the IoT Edge Device

Once you’ve installed IoT Edge, I’d like to share a few tips that can help you with analysis and monitoring.

This command is very helpful to observe the “working” of IoT Edge – and thus always to check that images are updated, as well as modules that are properly started or stopped.

journalctl -f -u iotedge | grep -v mgmt

It displays all the last log entries continuously. The -f parameter ensures that new entries are waiting. With -u, you limit the log output to everything that has to do with IoT Edge. The following grep command helps you to filter away even the annoying management entries.

Issue of the Journal for IoT Edge after deploying a new module version

Because you probably need to start and stop IoT Edge during your tests. Maybe you should think about shortcuts like aliases. I set up a stop IoT and start IoT.

alias start-iot="sudo service iotedge start"
alias stop-iot="sudo service iotedge stop"

You can also store these lines in your .bashrc or whatever you use so that you have them permanently.

If you’re having problems with the Docker containers, you can quickly free your system from them with the following aliases

alias rmi-yolo="sudo docker images --format='{{.Repository}} {{.ID}}' | grep 'yolo' | \
cut -d' ' -f2 | sudo xargs docker rmi"

alias rmi-postcar="sudo docker images --format='{{.Repository}} {{.ID}}' | \
grep 'postcar' | cut -d' ' -f2 | sudo xargs docker rmi"

The first alias deletes the Yolo* images, the second deletes all postcar* images from the system (of course you can expand this). So if you stop-iot && rmi-yolo && rmi-postcar && start-iot as commands, you stop IoT Edge, remove the images and start again. The IoT Edge Runtime will then pull the missing images again. With the journal command above, you can watch the whole thing in parallel in a second terminal.

Now you have everything you need to start with IoT Edge on the Nano. If you liked this post, please leave a comment or write me an email. I’m looking forward to receiving feedback.

By Thomas

As Chief Technology Officer at Xpirit Germany. I am responsible for driving productivity for our customers by a full stack of dev and technology in modern times. But I not only care for technologies from Microsofts stack like Azure, AI, and IoT, but also for delivering quality and expertise with DevOps

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.