CloudAcademy
  1. Home
  2. Training Library
  3. Microsoft Azure
  4. Courses
  5. Developing For The Raspberry Pi and Azure IoT Hub

Course Intro

Contents

keyboard_tab
Intro
Summary
8
play-arrow
Start course
Overview
DifficultyIntermediate
Duration50m
Students198

Description

Developing For The Raspberry Pi and Azure IoT Hub

When it comes to IoT there are multiple layers. It’s not just an application deployed out on virtual machines, where the users interact with a web browser. In this course we’ll go through the process of setting up both the cloud and device side of an IoT solution.

This course focuses on how to implement a basic IoT solution. We’re going to setup a Raspberry Pi 3 B, with the Raspbian operating system. We’ll use a breadboard to wire up a DS18B20 temperature sensor, and 2 LEDs. And we’ll use a Node.js application to interact with the sensor, LEDs, and IoT Hub.

We’ll check the temperature every second, and if it’s changed since the last read, we’ll send a message to IoT Hub. Any time we send a message, we’ll make the green LED blink. And if the temperature hits 70 degrees or higher, we’ll turn the red LED on, as a warning light that it’s getting too warm; the only way to disable the warning light is to use an IoT Hub device-method.

So that’s what we’re going to build on the device side of things. On the cloud side of things, we’re going to use IoT Hub to hold the messages in its queue. We’ll implement an Azure Function to listen for messages, and then it’s going to take the message and save it in Document DB.

Here’s what you’ll need to build this for yourself.

First, you’ll need an Azure Subscription, because we’re going to use 3 Azure Services as our cloud back-end. We’ll use IoT Hub, Azure Functions and DocumentDB. You’ll also need a Raspberry Pi. I’m using a Raspberry Pi 3 B, for this demo. Since the pin layout may be different for different versions, you may need to adjust things for your implementation. You’ll also need an SD card for the Pi and a power supply. Most kits come with these. You’ll need a mouse, keyboard and HDMI compatible display for the initial OS setup. You’re going to need a breadboard. You’ll need two LEDs, ideally two different colors. You’ll need a temperature sensor, in particular, if you want to follow along and use the code I’ve prepared, you’ll want to use a DS18B20. When it comes to wiring up this project, you could use some male-to-female wires and connect to the pins on the Raspberry Pi directly. Or, you can use a breakout board, with male-to-male wires, which is what I’ll be using. You’ll also need some resistors, I’m using a 10k resistor with the sensor, and then a 220 ohm resistor with each LED.

Raspberry Pi Kits / Sensors

CanaKit Ultimate
Azure IoT Starter Kit
DS18B20 Sensor
Kuman Sensor Kit

Here’s some recommended reading if you’re new to IoT.

How to use a breadboard
Raspberry Pi documentation
IoT Hub getting started with Node.js
Azure Node.js SDK samples
Pin Layout

 

Developing For The Raspberry Pi and Azure IoT Hub: What You'll Learn

Lecture What you'll learn
Course Intro What to expect from this course
Service Setup Creating the services
Configuring The Services Configuring the services and testing them
Preparing The Raspberry Pi Getting the OS installed and configured
Preparing The Breadboard Wiring up the solution
Reviewing The Code Reviewing the application
Running The Code Testing the solution out
Next Steps What's next

 

Transcript

Welcome to Developing For The Raspberry Pi and Azure IoT Hub!

I’m Ben Lambert, and I’ll be your instructor for this course. A little about me, I’m a full time instructor here at Cloud Academy. Working as a full time instructor, for me, is fantastic, because it allows me to build on my experiences as a DevOps engineer, and keep learning all kinds of new things. And then, I get to teach these things to you!

I had a lot of fun making this course, because I got to work with some very cool technologies. This course takes you through the process of setting up a Raspberry Pi to use a temperature sensor, and then it sends the temperature data to IoT Hub.

This is a pretty hands on course, however if you don’t have a Raspberry Pi to follow along with, you can still learn a lot about how to get a physical device to interact with IoT Hub.

So, what exactly will we be building in this course? We’re going to setup a Raspberry Pi 3 B, with the Raspbian operating system. We’ll use a breadboard to wire up a temperature sensor, and 2 LEDs. And we’ll use a Node.js application to interact with the sensor, LEDs, and IoT Hub.

We’ll check the temperature every second, and if it’s changed since the last read, we’ll send a message to IoT Hub. Any time we send a message, we’ll make the green LED blink.
And if the temperature hits 70 degrees or higher, we’ll turn the red LED on, as a warning light that it’s getting too warm; the only way to disable the warning light is to use an IoT Hub device-method.

So that’s what we’re going to build on the device side of things. On the cloud side of things, we’re going to use IoT Hub to hold the messages in its queue. We’ll implement an Azure Function to listen for messages, and then it’s going to take the message and save it in Document DB.


Here’s what you’ll need to build this for yourself.

First, you’ll need an Azure Subscription, because we’re going to use 3 Azure Services as our cloud back-end. We’ll use IoT Hub, Azure Functions and DocumentDB.

You’ll also need a Raspberry Pi. I’m using a Raspberry Pi 3 B, for this demo. Since the pin layout may be different for different versions, you may need to adjust things for your implementation.
You’ll also need an SD card for the Pi and a power supply. Most kits come with these. You’ll need a mouse, keyboard and HDMI compatible display for the initial OS setup.

You’re going to need a breadboard. You’ll need two LEDs, ideally two different colors. You’ll need a temperature sensor, in particular, if you want to follow along and use the code I’ve prepared, you’ll want to use a DS18B20.

When it comes to wiring up this project, you could use some male-to-female wires and connect to the pins on the Raspberry Pi directly. Or, you can use a breakout board, with male-to-male wires, which is what I’ll be using. You’ll also need some resistors, I’m using a 10k resistor with the sensor, and then a 220 ohm resistor with each LED.

There are a lot places to buy all of this stuff, and I’ll leave links to the kits I’m using in the course description. Though, to show them here, I’m using a Canakit Ultimate Starter Kit, from Amazon.
https://www.amazon.com/CanaKit-Raspberry-Ultimate-Starter-Kit/dp/B01C6Q4GLE/

And you can pick up an individual sensor from Adafruit’s website for 4 dollars.
https://www.adafruit.com/product/374

However, the one I’m using came from the Kuman sensor kit, also available on Amazon
https://www.amazon.com/Arduino-Raspberry-Kuman-Projects-Tutorials/dp/B016D5L5KE/


So...now that you know what we’ll be building, and what we’ll need to build it, who is this course intended for?

I made some assumptions when putting this course together. First, I assume that you’re already familiar with the Azure Portal. I’m going to walk you through setting up the services we’ll need, however familiarity with the portal will help.
There are 3 services we’ll use as I mentioned. So if you want to get up-to-speed on IoT Hub, Azure Functions and DocumentDB, check out the existing courses on the site.


I also assume that you’re familiar with software development. While we’ll be using Node.js, you don’t need to be proficient with JavaScript, however, you’ll want to at least know how to program in some language.

You’ll need to be comfortable using the command line. A lot of what we’ll do with the Raspberry Pi is going to be done on the command line.

Finally, you’ll want to be comfortable working with hardware, because you could irreparably damage your Raspberry Pi, and or the sensors by wiring things up incorrectly.
If you’re interested in IoT but you’re not yet comfortable implementing hardware solutions yourself, then check out the recommended reading in the course description.

https://learn.sparkfun.com/tutorials/how-to-use-a-breadboard
https://www.raspberrypi.org/documentation/setup/


Here’s the agenda?

First up we’re going to setup the Azure services
Then we’ll configure the services, and use a device simulator to test that it’s working correctly.
After that, we’ll prepare the Raspberry Pi by getting the OS installed and configured
Then we’ll wire our sensors and LEDs up into the breadboard
We’ll then take a look at the code
And then we’ll get the code deployed onto the Raspberry Pi and we’ll test out the complete process
We’ll then end the course by wrapping up with a glimpse into the decisions involved in making this course, and some recommended next steps.

Admittedly, I’m a bit biased, however, I think this course will be a lot of fun for you. I know it was for me to create; so I hope you enjoy it!

If you’re ready to dive in, then let’s get started with the first lesson!

About the Author

Students31542
Courses29
Learning paths18

Ben Lambert is the Director of Engineering and was previously the lead author for DevOps and Microsoft Azure training content at Cloud Academy. His courses and learning paths covered Cloud Ecosystem technologies such as DC/OS, configuration management tools, and containers. As a software engineer, Ben’s experience includes building highly available web and mobile apps.

When he’s not building the first platform to run and measure enterprise transformation initiatives at Cloud Academy, he’s hiking, camping, or creating video games.