Welcome to the Azure IoT Central Basic Bootcamp and Hand On Lab. We will be settign up and end to end scenario using the Raspberry Pi as our IoT "Device" and connect all the way through to IoT Central to demostrate the power of Azure IoT Central Telemetry, Programming, Data Modeling and Data Export and Integration.
- IoT Central Basic Bootcamp
- Contents
- Bill of Materials for IoT Central Bootcamp
- Components
- Tools
- Optional
- Raspberry Pi Model 4 B
- AM2315 Temperature and Humidity Sensor
- Ultra Compact RS232 to TTL Converter with Female DB9
- Screw Terminal Block Breakout Module for Raspberry Pi
- SanDisk Ultra microSD Card
- USB to RS232 Serial Cable with Prolific PL2303 Chip
- RGB LED 10mm (Optional Status Indicator)
- Assembling the Raspberry Pi and the Components
- Setting up your Raspberry Pi OS
- Setting up the Development Toolchain for your Workstation
- Connecting to the the Raspberry Pi (SSH)
- Modules
- Module 01 - Setting up your Raspberry Pi
- Module 02 - Getting to Know the Raspberry Pi
- Module 03 - Setting up your Development Toolchain
- Module 04 - Enabling Capabilities on the Raspberry Pi
- Module 05 - Connecting using SSH to your Raspberry Pi
- Module 06 - Introduction to Breadboarding)
- Module 07 - Setting up the Raspberry Pi for Running Python Applications
- Module 08 - Communicating with Sensors, LED, etc
- Module 09 - Create your Azure IoT Central Application
- Module 10 - Connecting to Azure IoT Central (Python SDK)
The following are needed for this workshop...
- One(1) Raspberry Pi Board (version 4) Canakit
- One(1) Breadboard Kit
- One(1) Network Cable
- Monitor or Raspberry Pi Touchscreen
- HDMI Mini to HDMI Standard Cable
- Keyboard
- Mouse
The speed and performance of the new Raspberry Pi 4 is a step up from earlier models. For the first time, we've built a complete desktop experience. Whether you're editing documents, browsing the web with a bunch of tabs open, juggling spreadsheets or drafting a presentation, you'll find the experience smooth and very recognisable — but on a smaller, more energy-efficient and much more cost-effective machine.
This is the SD card you will load the Raspberry Pi operating system onto and place into the Raspberry Pi board.
It is now time to set up the Raspbian image on the SD card that you load will into the MicroSD cart slot on the Raspberry Pi. Recently the Raspberry Pi Organization published an Operating System imaging tool that is excellent.
Let's get started with the Raspberry Pi Imaging Tool. First watch the short video on using the tool...
LINK: How to use Raspberry Pi Imager | Install Raspberry Pi OS to your Raspberry Pi (Raspbian)
Install the Imager tool for your Desktop operating system...
LINK: Raspberry Pi OS Installation Page
Scroll the section, "Install Raspberry Pi OS using Raspberry Pi Imager" and install the software.
Install the Raspbian OS Image on the SD card.
Install the MicroSD card into the SD writer connected to your desktop or Laptop.
Choose the "Raspberry Pi OS (32 Bit)" to install the whole OS and Desktop.
Choose the SD card connected to your computer.
Click on the "WRITE" button and allow the process to copy, verify and complete.
Right-click on boot (on your desktop or File Explorer) and select the Eject option.
Note: Turn off your Raspberry Pi!
Looking from the top of the RPi, install the SD card (the slot is on the bottom of the board) as shown in the picture below...
CONGRATULATIONS You have installed the Raspbian Operating System for the Raspberry Pi and are now ready to start setting things up for our ColdPack Monitoring Device.
Now that we have our SD card loaded with the Raspbian Operating System, we need to boot the Raspberry Pi and using the touchscreen, configure the system and the interfaces. After setting these things up we will be able to log into the Raspbery Pi from another computer and make it easier to program and run applications.
We are going to configure the Raspberry Pi using a keyboard and mouse and this is the easiest way to get everything working well and verified.
Open "References->Raspberry Pi Configuration"....
On the initial screen, set you password and the name of the instance. I like to use some numbering for my ColdHub pi's so that I can keep track as I test multiple devices...
Next, click the "Interfaces" tab and I set all of these to "Enable"...
Click "OK" and respond with "Yes" to reboot the Raspberry Pi and apply the configuration...
In this step we will clone the code and configuration scripts to the Raspberry Pi. The code and scripts make setting up the Pi for communication, reading sensors and device provisioning in IoT Central... a fully automated process.
What the scripts and code enable...
- Bring all of the needed application code and configuration scripts to the Pi
- Installation of the Raspberry Pi to use the latest version of Python
- Installation of the Azure IoT SDK for Python
- Installation of the applications that support provisioing of the device and monotoring with telemetry to Azure IoT Central
Let's get started by opening up a terminal window on the Raspberry Pi by clicking the terminal window icon (outlined in the red box at the top menu bar) and then typing "ls" followed by Enter to see list of files and directories.
Before we can pull the files from GitHub we need to setup our profile. Type the following commands into the terminal window to configure our Git Profile...
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
# Verify
git config --global --list
Type the following commands into the terminal window to clone the repository...
mkdir Projects
cd Projects
git clone https://github.com/Larouex/iot-central-raspberrypi-hol.git
Now we have all we need to configure the Pi for the sessions. Next we will run a setup script and it will automatically confgure everything. Type the following commands into the terminal window...
I used the generic term "Workstation" as a way to differentiate that this is the main computer (workstation, laptop, etc.) that you use to do your primary development work. We assume it exists on the same network (if using an ethernet connection) and you can install the tools that will allow you to connect and develop code remotely on the Raspberry Pi.
Git is the tool we use for version control and management of software assets. Our workshop will use it to clone the modules and also to save anything if you want
This is the IDE we will use to write code, deploy to the RPi, etc.
LINK: Visual Studio Code Installation Page
Pyhon is the language we will use to build applications for the Raspberry Pi
From the Python Org:
- Python is powerful... and fast;
- plays well with others;
- runs everywhere;
- is friendly & easy to learn;
- is Open.
LINK: Python 3 Installation Page
Pip is the package manager we will use to download packages
On Linux or macOS (Open Terminal):
pip install -U pip
On Windows (from a CMD window or Powershell):
python -m pip install -U pip
These are a set of tools we will use to develop our apps on the Raspberry Pi. You can open the Extensions sidebar with "Shift+Ctrl+X) or click the icon in the side navigator bar.
The requirement in order to connect to your Pi from your computer can be accomplished via Wireless or with an ethernet cable connected to the RPi ethernet port.
If you boot to the command line instead of the desktop, your IP address should be shown in the last few messages before the login prompt.
Using the terminal (boot to the command line or open a Terminal window from the desktop), simply type ...
hostname -I
Which will reveal your Pi's IP address.
This is the documentation from the Raspberry Pi Foundation and you have a number of options... https://www.raspberrypi.org/documentation/remote-access/ip-address.md
We will be connecting to the Raspberry Pi using the remote SSH capability of Visual Studio Code that we installed as part of our development toolchain. When you set the RPi up, we enabled the device to connect to our Wifi network.
Now we want to find the IP address of our RPi and connect to via VS Code's Remote SSH tools. This will let us develop our code and test our application working remotely connected to the device.
Here is the documetnation on the extension for VS Code... LINK: Remote Development
Here is how we will connect to the Raspberry Pi... LINK: Remote development over SSH
Let's get started by making sure our Raspberry Pi (Operating System) is up to date...
sudo apt-get update
sudo apt-get upgrade
sudo pip3 install --upgrade setuptools
LINK: Module 01 - Setting up your Raspberry Pi
LINK: Module 02 - Getting to Know the Raspberry Pi
LINK: Module 03 - Setting up your Development Toolchain
LINK: Module 04 - Enabling Capabilities on the RPi
LINK: Module 05 - Connecting using SSH to your Raspberry Pi
LINK: Module 06 - Introduction to Breadboarding
LINK: Module 07 - Setting up the Raspberry Pi for Running Python Applications
LINK: Module 08 - Communicating with Sensors, LED, etc
LINK: Module 09 - Create your Azure IoT Central Application
LINK: Module 10 - Connecting to Azure IoT Central (Python SDK)