0 Comments

Following is a guidance how to set up Raspberry PI from the scratch to working Azure IoT Edge device.

There is a three step-by-step articles.

Lets do it together step-by-step.

Installing Linux (Rasbian) on Raspberry PI

This is the article about supported Azure IoT Edge systems. Only Raspbian Debian 11 (bullseye) is currently fully supported.

Step 1. Download Raspbian-bullseye image

  1. Download the Raspbian-bullseye lite image from the archive here: https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-09-26/
  2. Downloadthe latest and greatest version of Raspbian Bullseye.
  3. Unpack the image to your hard drive.


Step 2. Burn the image to the SD card

For this step I am using Win32 Disk Imager which can be downloaded here: https://sourceforge.net/projects/win32diskimager/

  1. Download Disk Imager and install it to your PC.
  2. Run the Disk Imager
  3. Select image file you just downloaded and unpacked from Raspbian
  4. Select SD card as your device (use at least8Gb or bigger SD card)
  5. Click Write!Disk Imager

When the process complete you may see some prompts that the drive is not ready would you like format it etc.

Don't do this! Don’t format!

Don't format the disk

There is just one partition named boot which can read. Do not touch other partitions.


Step 3. Enable SSH

SSH is used to access remotely to your Raspberry. You definitely need this so don’t think this is unnecessary step.

  1. Open boot drive from the SD card
  2. Create empty file named ssh on that drive (without any extension). No content, nothing, just 0 byte file.

Step 3.1 Add user

For security reason Debian 11 has removed the default user for Raspberry. This mean that after installation you cannot log in remotely through SSH as you dont have any user.

  1. Open boot drive from the SD card
  2. Create empty file named userconf.txton that drive.
  3. Add the following content. This content will create a username piwith password password.
pi:$6$38HiUnLhwlE1DRdL$MHHb6/OsyAlZNqmW7igj333g/CRwG/g5nls7ylTEqZZg9rOIM/cUvE962.5x6M0ONMz/r6OlBy/G6f4v8zrH51

Step 4. Add WiFi network

This step is makes your Raspberry PI connected into your WiFi network after booting.

  1. Open bootdrive from the SD card.
  2. Create a file named wpa_supplicant.conf
  3. Open this file with Notepad and add your WiFi network information.

Btw, my favorite notepad is Notepad++.

ctrl_interface=/run/wpa_supplicant
update_config=1
country=US
network={
	ssid="NETWORK-NAME"
	psk="NETWORK-PASSWORD"
}

Step 5. Enable I2C and SPI protocols

This step will make I2C and SPI connections available. By default they are disabled but many modern sensors are using especially I2C protocol.

  1. Open bootdrive from the SD card
  2. Open existing file config.txt
  3. Find the lines and uncomment all three lines
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on

config.txt I2C, SPI I2S


Step 6. Take the SD card and boot your Raspberry

Now is finally time to take out the SD card from your PC and start the Raspberry from it.

  1. Remove SD card from your PC
  2. Put it into Raspberry
  3. Plug the power cable
  4. Let the Raspberry boot, up to 2 minutes


Step 7. Login to your Raspberry PI through ssh

Now we will log in into the Raspberry to make some additional changes. For this step we need additional software for example PuTTY.

  1. Downloadand installPuTTY
  2. OpenPuTTY
  3. Connect to your Raspberry,
    1. the name of your fresh Raspberry is just raspberrypi
    2. Open PuTTY and connect to Raspberry
    3. First time PuTTY asks security question, Correct answer is Yes
    4. Answer Yes for this security question
  4. Loginto your Raspberry
      1. Username: pi
      2. Password: raspberry
  5. You are in!

Logged in into Raspberry


Step 8. Change your Raspberry name!

You can’t have many devices with the same name. It will be mesh. So better to change the name right now.

  1. Run the following command on your Raspberry:
sudo raspi-config

2. Go to Network Options

Raspberry network options

3. Go to HostnameRaspberry Hostname

4. Enter new name for this Raspberry, for example testpi and press OKRaspberry name

5. Press Finishand let the Raspberry boot

FinishReboot


Step 9. Login with the new name testpi

Login to your Raspberry with the new name


Step 10. Get the updates

To get the important updates run the command:

sudo apt-get update

Get the important updates


Congratulation: Your Raspberry PI setup is done. Please follow the next article to make this Raspberry as an IoT Edge capable device.

Next step: #2 Installing IoT Edge functionality into Raspberry