#RaspberryPi – Update or setup Wifi configuration in Ubuntu

Buy Me A Coffee

Hi !

This is not a Raspberry Pi specific post, however I always forget how to this in Ubuntu, and I’m so used to raspi-config in Raspberry OS, that I may write this down.

Ok, so let’s setup the Wifi in Ubuntu. 1st let’s change the 50-cloud-init.yaml file.

 sudo nano /etc/netplan/50-cloud-init.yaml

Let’s edit the file and add the Wifi information.

 network:
     version: 2
     wifis:
         wlan0:
             dhcp4: true
             dhcp6: true
             optional: true
             access-points:
                 "<Wifi name>":
                     password: "<Wifi password>"

Important: use spaces, not tabs. That’s it!

Close, save and reboot !

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware
Azure IoT


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#AzureIoT – ☁ Azure IoT Explorer, in preview and awesome

Buy Me A Coffee

Hi !

I found this tool sometime ago, and it was a great moment. The Azure IoT explorer is a graphical tool for interacting with and devices connected to your IoT hub. You can check references for the official installation process.

And just in case, here is a small preview of the tool showing the live telemetry events on a specific device. At the right there is a console app sending messages to a Azure IoT Device. The device processes the messages and send some specific telemetry.

The app is very straight forward. First, just add an IoTHub using a Connection String.

Once connected, we can inspect the devices on the Hub

And in each device we have some actions available. During my current days, Telemetry and Direct method are the 2 most useful ones !

Again, it was a great surprise find this tool. !

Bonus: supports dark theme !

Happy coding!

Greetings

El Bruno


References


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – Install ☁ Azure IoT Edge in a Raspberry Pi with Ubuntu 18.04, lessons learned and some tips

Buy Me A Coffee

Hi !

With the new Raspberry Pi Imager, the installation of an OS for a Raspberry Pi is much more easier than earlier days. We even have the chance to install several different Ubuntu versions, Desktop, Server and Core.

raspberry pi imager with ubuntu versions

This is cool, however it does not fit with the Azure IoT Edge prerequisites for an Ubuntu/Linux installation. I make some tests with Ubuntu Server 20.10 and Azure IoT, and they didn’t work. The current supported version is Ubuntu Server 18.04.

Install Ubuntu 18.04.5

After a quick search I found a working version in the Ubuntu repository:

Ubuntu 18.04.5 LTS (Bionic Beaver) (see references)

After the version is installed, it comes out of the box with SSH enabled. So, once I detected the device IP in my network, I SSHed with this device.

Note: there is no raspi-config here. So simple actions like Wifi configuration are tricky. Lucky us, internet have answers for almost everything.

The command [] also works to display current OS information.

ubuntu@ubuntu:~$ hostnamectl
   Static hostname: ubuntu
         Icon name: computer
        Machine ID: 6fcd625f39104d699f50b8de729f34ba
           Boot ID: 712910e5c2df43969db5384756225408
  Operating System: Ubuntu 18.04.5 LTS
            Kernel: Linux 5.4.0-1028-raspi
      Architecture: arm64

Finally, as a GUI person, a cooler option is to use [neofetch]. You may need to install it with

sudo apt install neofetch

And later, some magic !

Update Ubuntu

Now it was time to update the OS. Standard command

sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'

and it took a lot !

And now all the steps from the official Install Azure IoT Edge for Linux works!

References

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware
Azure IoT


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – Connect to ☁ Azure Blob Storage on IoT Edge using Microsoft Azure Storage Explorer

Buy Me A Coffee

Hi !

This is an easy one, however I may write these down to complete the series of posts on Azure Storage Blob on IoT Edge.

Azure Storage Explorer is a free tool to easily manage your Azure cloud storage resources anywhere, from Windows, macOS, or Linux (see references).

You can add your Azure Credentials to access to your cloud resources, and if you are using a Storage in the Edge, you can create a connection string based on this template

DefaultEndpointsProtocol=http;BlobEndpoint=http://<device IP>:11002/<account name>;AccountName=<account name>;AccountKey=<account key>;

Where the 2 of 3 main values comes from the Azure Storage Blob on IoT Edge configuration (See previous post)

  • Device IP
  • Account Name
  • Account Key

Once you created your connection string, you can add a new connection in the tool. Right click on [Local and Attached // Storage Accounts], select [Connect to Azure Storage] and select the use Connection String option.

In the previous image we can see the access to 2 edge devices a Raspbian and an Ubuntu device. The 2nd one deserves a new post, there are some know errors here.

References

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware
Azure IoT


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#Podcast – NTN 78 – Hey Alexa 👋 , cómo funciona el mundo de desarrollo de tus Alexa Skills ? 🥣

Buy Me A Coffee

Buenas!

Que pasa cuando hablas con alguien que es un Alexa Champion? Pues que pasas un buen rato y aprendes mucho. Vicente ha publicado un libro en español sobre este tema: “La Revolución de Alexa: Desarrollo de Alexa Skills” y claro, fue la excusa perfecta para hablar un rato sobre el desarrollo de skills para Alexa.

En la charla hablamos de muchos escenarios. Por ejemplo, como desarrollar apps, perdón skills, sin la necesidad de programar ni una línea de código: y también hablamos de escenarios más complejos como híbridos entre Azure y Amazon. O inclusive sobre como monetizar los skills !

Happy Coding !

Speakers

  • Vicente Guzmán es Lead Project Manager en Deintec (LinkedIn)
  • Juan Carlos Quijano Abad es Microsoft Certified Trainer, Arquitecto de Soluciones en Azure, Consultor independiente en implantación de DevOps (LinkedIn)
  • Bruno Capuano es Canada Innovation Lead at Avanade and Microsoft AI MVP (LinkedIn)

Ir a descargar

Happy coding!

Greetings

El Bruno



¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – Deploy Azure Blob Storage on IoT Edge, lessons learned #AzureIoT

Buy Me A Coffee

Hi !

I’ve been using Azure Blob Storage for a very long time. I won’t share details so you won’t laugh a lot. And now, in the amazing Azure IoT world, we have the chance to use a custom module in out Edge devices. As the documentation mention, this module is useful in scenarios:

  • where data needs to be stored locally until it can be processed or transferred to the cloud. This data can be videos, images, finance data, hospital data, or any other unstructured data.
  • when devices are located in a place with limited connectivity.
  • when you want to efficiently process the data locally to get low latency access to the data, such that you can respond to emergencies as quickly as possible.
  • when you want to reduce bandwidth costs and avoid transferring terabytes of data to the cloud. You can process the data locally and send only the processed data to the cloud.

In the references section I shared the official documentation. So, while you are reading the doc and following the steps, I’ll share some insights.

Install module from the Marketplace

As usual, we can deploy the module using a custom JSON definition. For 1-to-1 devices, install the module from the market place is a quick option. Just go your IoT Edge device panel, select [Set Modules], and in the IoT Edge Modules section, select [+ Marketplace Module].

azure iot install module from marketplace

On the search panel, search for “storage” and check the results.

azure iot install module from marketplace azure blob storage on Iot edge

2 clicks later, the module is in your definition. However, some config is needed. I’ll go on this for next section.

Settings / Config for the Azure Blob Storage on IoT Edge module

Time for module configuration. In the official documentation describes the 2 main sections to work on.

The main values that we will need are these ones, so you may need to create / define them in advance.

  • Storage account name. Account names should be 3 to 24 characters long, with lowercase letters and numbers. No spaces.
  • Storage account key. Replace with a 64-byte base64 key. You can generate a key with tools like GeneratePlus. You’ll use these credentials to access the blob storage from other modules.

Environment Variables

You need to complete these values in the [Environment Variables] section.

azure iot azure blob storage set environment variables

Module Name needs to be lowecase

At some point the documentation mention / suggest to change the name to lowercase. Please do this, I had several issues on my Raspberry Pi, and somehow a lowercase name fixed some deployment issues.

Container Create Options

This section is mostly straight forward. I used the Account Name and Account Key defined in previous steps and I also created a specific folder to store the blob [/home/pi/azurestorageiot]. Again, here the documentation makes everything easy to configure.

{
  "Env":[
    "LOCAL_STORAGE_ACCOUNT_NAME=<your storage account name>",
    "LOCAL_STORAGE_ACCOUNT_KEY=<your storage account key>"
  ],
  "HostConfig":{
    "Binds":[
            "/home/pi/azurestorageiot"
    ],
    "PortBindings":{
      "11002/tcp":[{"HostPort":"11002"}]
    }
  }
}

Module Twin Settings options

Main remark here: while you are in testing mode, set the uploadOn to false (line 8). Otherwise the module will

  • be installed with default options and no containers
  • Search for a local container [cont1] and will log tons of errors, because the container does not exist

And the lines 11 to 15 were also tricky to understand. I was a expecting a source / target pair to define source and target containers, however the definition works different.

For each source container (the ones in our IoT Edge device), we need to create a section (lines 12 to 14) with the name of the IoT Edge container (cont1), and the target definition with the name of the Azure container (line 13).

Again, I spend sometime here, mostly because I was with a different mindset before understanding how this works.

And that’s it! I deployed and tested this module in a Raspberry Pi and it works like a charm!

References

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware
Azure IoT


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#Event – @netcoreconf “NTN Podcast” emisión en directo desde el evento !

Buy Me A Coffee

Buenas !

Siguiendo con la tradición de uno de los eventos mas importantes de habla hispana, esta vez también participaré en la NetCoreConf. Sin embargo, esta vez probando un formato nuevo;

Grabación del Podcast en directo desde NetCoreConf

La agenda todavía es secreta y si bien estoy lejos de los organizadores, me han prometido que me cortan las manos si revelo algo. Lo que si puedo comentar es que tendremos un [Bar Virtual] donde podremos encontrarnos entre sesiones, y desde allí podremos pasar a la [Sala de Grabación] para hablar con los asistentes, ponentes y demás personas.

netcoreconf podcast en directo

Más información dentro de pocos días. Entre tanto los 2 mejores recursos para estar al tanto de las novedades son

Los esperamos !

Happy coding!

Greetings

El Bruno



¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – Build #docker 🐳 images from Visual Studio @Code remotely using a Raspberry Pi. #AzureIoT

Buy Me A Coffee

Hi !

The post title is very descriptive, however let me share some more context on why I needed this scenario.

I’m currently working in an Azure IoT custom module. I got installed the Azure IoT extensions on Visual Studio Code, so everything works great on the Hello World mode. Once I wrote my code logic in C#, I can easily build my IoT Edge Solution.

My default configuration focus to an amd64 platform. I got this defined in my settings.json

{
    "azure-iot-edge.defaultPlatform": {
        "platform": "amd64",
        "alias": null
    }
}

This is a sample log output, using my local docker in Windows 10. Everything works fine.

[+] Building 0.7s (16/16) FINISHED
 => [internal] load build definition from Dockerfile.amd64                                                                                                                                                                                  0.1s
 => => transferring dockerfile: 38B                                                                                                                                                                                                         0.1s 
 => [internal] load .dockerignore                                                                                                                                                                                                           0.1s 
 => => transferring context: 34B                                                                                                                                                                                                            0.1s 
 => [internal] load metadata for mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim                                                                                                                                                      0.5s
 => [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:3.1-buster                                                                                                                                                               0.5s 
 => [build-env 1/6] FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster@sha256:0fece15a102530aa2dad9d247bc0d05db6790917696377fc56a8465604ef1aff                                                                                               0.0s
 => [internal] load build context                                                                                                                                                                                                           0.0s 
 => => transferring context: 446B                                                                                                                                                                                                           0.0s 
 => [stage-1 1/4] FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim@sha256:e84300e54209cad66611b0b483cfe8c007d3bb5450388ff58e7f15d025917817                                                                                        0.0s 
 => CACHED [stage-1 2/4] WORKDIR /app                                                                                                                                                                                                       0.0s
 => CACHED [build-env 2/6] WORKDIR /app                                                                                                                                                                                                     0.0s 
 => CACHED [build-env 3/6] COPY *.csproj ./                                                                                                                                                                                                 0.0s 
 => CACHED [build-env 4/6] RUN dotnet restore                                                                                                                                                                                               0.0s 
 => CACHED [build-env 5/6] COPY . ./                                                                                                                                                                                                        0.0s 
 => CACHED [build-env 6/6] RUN dotnet publish -c Release -o out                                                                                                                                                                             0.0s 
 => CACHED [stage-1 3/4] COPY --from=build-env /app/out ./                                                                                                                                                                                  0.0s 
 => CACHED [stage-1 4/4] RUN useradd -ms /bin/bash moduleuser                                                                                                                                                                               0.0s 
 => exporting to image                                                                                                                                                                                                                      0.0s 
 => => exporting layers                                                                                                                                                                                                                     0.0s 
 => => writing image sha256:8d38fb01640fb566e761231c1a646df35bb83f24dfbb0fdea92bc4db62576e12                                                                                                                                                0.0s 
 => => naming to <...>

If I want to change the target platform to build an arm32 image, I change my settings.json file to:

{
    "azure-iot-edge.defaultPlatform": {
        "platform": "arm32v7",
        "alias": null
    }
}

However I got this ugly error, trying to build this

=> CACHED [build-env 2/6] WORKDIR /app                                                                                                                                                                                                     0.0s 
 => CACHED [build-env 3/6] COPY *.csproj ./                                                                                                                                                                                                 0.0s 
 => ERROR [build-env 4/6] RUN dotnet restore                                                                                                                                                                                                0.5s
------
 > [build-env 4/6] RUN dotnet restore:
#10 0.450 A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders
------
executor failed running [/bin/sh -c dotnet restore]: exit code: 131

There seems to be an error here, outside of my docker knowledge.

Of course, a test path could involve the use of a remote ARM32 Docker Environment to build my Azure IoT Edge C# Module. I followed my previous posts steps to enable SSH password-less access to my Raspberry Pi and also manage docker as non-root users (see references).

Now I can define a specific DOCKER EXECUTOR to build my images. I changed my settings.json file to define this executor. Note that you must define a standard SSH connection, this may involve your device name or IP Address.

{
    "azure-iot-edge.defaultPlatform": {
        "platform": "arm32v7",
        "alias": null
    },
    "azure-iot-edge.executor.env": {
         "DOCKER_HOST": "ssh://pi@<Raspberry PI Address>"
    }
}

Important: once you changed your settings.json configuration, you need to reload your VSCode environment. You can close and open the IDE, or even better, invoke the [Reload Window] command.

visual studio code reload window

Now we can sucesfully build the Azure IoT module. the output log will be similar to this one:

Sending build context to Docker daemon  24.06kB
Step 1/12 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster-arm32v7 AS build-env
 ---> 3cdfdcca7cd6
Step 2/12 : WORKDIR /app
 ---> Using cache
 ---> 8c3252bfdefb
Step 3/12 : COPY *.csproj ./
 ---> Using cache
 ---> e6fe11cb659e
Step 4/12 : RUN dotnet restore
 ---> Using cache
 ---> 12453c83de65
Step 5/12 : COPY . ./
 ---> Using cache
 ---> 107c1dfccfa3
Step 6/12 : RUN dotnet publish -c Release -o out
 ---> Using cache
 ---> 603a93c80b0e
Step 7/12 : FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim-arm32v7
 ---> 2bb8fc093aad
Step 8/12 : WORKDIR /app
 ---> Using cache
 ---> c8a93a2a7b90
Step 9/12 : COPY --from=build-env /app/out ./
 ---> Using cache
 ---> f72a492270ad
Step 10/12 : RUN useradd -ms /bin/bash moduleuser
 ---> Using cache
 ---> 082a4568867b
Step 11/12 : USER moduleuser
 ---> Using cache
 ---> 2c5e7b562289
Step 12/12 : ENTRYPOINT ["dotnet", "UDPFwder.dll"]
 ---> Using cache
 ---> f523123332f9
Successfully built f523123332f9
Successfully tagged <...>
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

And that’s it! Using a Raspberry Pi device to build Net Azure IoT modules seems to be the fix to build ARM32 platforms.

References

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware
Azure IoT


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – Manage #docker 🐳 as a non-root user

Buy Me A Coffee

Hi !

The next step for my [use Docker in a Raspberry Pi to build and deploy images] step is to configure docker as non-root user.

Lucky us, this is officially documented and easy.

Create the docker group.

sudo groupadd docker

Add your user to the docker group.

sudo usermod -aG docker $USER

Log out and log back in so that your group membership is re-evaluated.

Run a test command for docker without sudo, in example let’s see the container list

docker container ls

And that’s it!

References

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware
Azure IoT


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

#RaspberryPi – Setup SSH passwordless access to remote work with #docker 🐳

Buy Me A Coffee

Hi !

Due to some weird configurations, I’m having issues building some .NET 5 docker images locally in my Windows 10 machine. So I decided to use a Raspberry 4 as build server, and 1st step is to setup the SSH access without the need of username / password. The main resource is an official one fro the Raspberry Pi org: Passwordless SSH access.

Once we finished these steps, we can easyly configure a TCP-enabled Docker.

I followed the next steps. First, let’s edit docker.service with the command:

sudo nano /lib/systemd/system/docker.service 

And add [-H tcp://0.0.0.0:2375] at [ExecStart] section

And restart the device or just the needed services

  • run sudo systemctl daemon-reload
  • run sudo systemctl restart docker

In next posts, how to add the needed configuration to Visual Studio Code to build the images remotely in the Raspberry Pi.

Happy coding!

Greetings

El Bruno


My posts on Raspberry Pi ⚡🐲⚡

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware
Azure IoT


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría: