Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 2.47 KB

python-run-sample.md

File metadata and controls

75 lines (53 loc) · 2.47 KB
platform device language
debian, Linux, raspbian, Ubuntu, windows
any
Python

Run a simple Python sample on device


Table of Contents

Introduction

About this document

This document describes how to run the iothub_client_sample_amqp.py Python sample application. This multi-step process includes:

  • Configuring Azure IoT Hub
  • Registering your IoT device
  • Build and deploy Azure IoT SDK on device

Step 1: Prerequisites

You should have the following items ready before beginning the process:

Step 2: Prepare your Device

Step 3: Run the sample

  • Navigate to the folder python/device/samples in your local copy of the repository.

  • Open the file iothub_client_sample_amqp.py in a text editor.

  • Locate the following code in the file:

    connectionString = "[device connection string]"	
    
  • Replace [device connection string] with the connection string for your device. Save the changes.

  • Run the sample application using the following command:

    python iothub_client_sample_amqp.py
    
  • The sample application will send messages to your IoT hub. The iothub-explorer utility will display the messages as your IoT hub receives them.

Experimenting with various transport protocols

There is a sample to test each of the AMQP, HTTP and MQTT protocols. It is also possible to simply change the transport in the sample.

Debugging the samples (and/or your code)

Visual Studio Code provides an excellent environment to write and debug Python code: