Create-a-talking-image-recognition-solution-with-Azure-IoT-Edge-Azure-Cognitive-Services

This project is maintained by gloveboxes

Module 2: Install Azure IoT Edge on your Raspberry Pi


Index


Hardware requirements

  1. Raspberry Pi 4 recommended, 2GB or better
  2. USB Camera
  3. Speaker

Booting from high speed USB3 storage

As we will be building Docker images on the Raspberry Pi 4 so I would recommend a fast SD Card or a high speed USB3 Flash or SSD drive.


Raspberry Pi set up

Create the Raspberry Pi OS Image

This project depends on ARM64 support and the recommended platform is Ubuntu Server 20.04 or 20.10 for Raspberry Pi. See How to install Ubuntu Server on your Raspberry Pi.

Start Raspberry Pi and update

  1. Update and reboot

     sudo apt update && sudo apt full-upgrade && sudo reboot
    
  2. Optionally overclock the Raspberry Pi 4.

    Though not a requirement, the machine learning inference times will be improved by overclocking the Raspberry Pi 4. You will need a Raspberry Pi heat sink if you overclock. See the How to overclock Raspberry Pi 4 article for more information.

    I use the following settings in the /boot/firware/config.txt.

     over_voltage=6
     arm_freq=2000
     gpu_freq=700
    

    and reboot.


Install Azure IoT Edge on the Raspberry Pi

Follow the steps outlined in the Install or uninstall Azure IoT Edge for Linux guide. Follow the guidance for Ubuntu 18.04.

Configure the Azure IoT Edge device

You need to configure the Azure IoT Edge connection string.

  1. Open the Azure IoT Edge config file.

     sudo nano /etc/iotedge/config.yaml
    
  2. Scroll down to the Manual provisioning configuration section.

     # Manual provisioning configuration
     provisioning:
         source: "manual"
         device_connection_string: "<ADD DEVICE CONNECTION STRING HERE>"
    
  3. Update the device_connection_string property with the Azure IoT Edge Connection string you saved to Notepad.

  4. Press ctrl + X, then y to confirm you wish to save the config.
  5. Press Enter to confirm the file name

  6. Reboot the Raspberry Pi

     sudo reboot
    

Install the Docker Registry on the Raspberry Pi

Azure IoT Edge relies on Docker images being distributed from a Docker Registry. In production you would deploy Docker images from a registry such as Azure Container Registry.

When you are developing an Azure Iot Edge module it is faster to install a local container registry on the Raspberry Pi and deploy Docker images from the local registry to Azure IoT Edge.

  1. Log into your Raspberry Pi

  2. From the SSH session, run the following command.

     docker run -d -p 5000:5000 --restart=always --name registry registry:2
    
  3. Do NOT close the SSH session.


Clone the image recognition solution to the Raspberry Pi

  1. Log into your Raspberry Pi

     ssh pi@raspberrypi.local
    
  2. From the SSH session, install the git client.

     sudo apt install -y git
    
  3. From the SSH session, clone the solution repository to the Raspberry Pi

     git clone --depth 1 https://github.com/gloveboxes/Create-a-talking-image-recognition-solution-with-Azure-IoT-Edge-Azure-Cognitive-Services.git
    

NEXT