Giter Club home page Giter Club logo

azure-iot's Introduction

Sample: AzureIoT

This sample demonstrates how to use the Azure IoT SDK C APIs in an Azure Sphere application to communicate with Azure IoT Central or Azure IoT Hub.

IMPORTANT: This sample application requires customization before it will compile and run. Follow the instructions in this README and in IoTCentral.md and/or IoTHub.md to perform the necessary steps.

This application does the following:

  • Sends simulated temperature telemetry to Azure IoT Central or an Azure IoT Hub at regular intervals.
  • Sends a button-press event to Azure IoT Central or an Azure IoT Hub when you press button A on the MT3620 development board.
  • Sends simulated orientation state to Azure IoT Central or an Azure IoT Hub when you press button B on the MT3620 development board.
  • Controls one of the LEDs on the MT3620 development board when you change a toggle setting on Azure IoT Central or edit the device twin on Azure IoT Hub.

Before you can run the sample, you must configure either an Azure IoT Central application or an Azure IoT Hub, and modify the sample's application manifest to enable it to connect to the Azure IoT resources that you configured.

By default, this sample runs over a Wi-Fi connection to the internet. To use Ethernet instead, make the following changes:

  1. Configure Azure Sphere as described in Connect Azure Sphere to Ethernet.

  2. Add an Ethernet adapter to your hardware. If you are using an MT3620 RDB, see the wiring instructions.

  3. Add the following line to the Capabilities section of the app_manifest.json file:

    "NetworkConfig" : true

  4. In main.c, add the following lines before any other networking calls:

     int err = Networking_SetInterfaceState("eth0", true);
     if (err == -1) {
           Log_Debug("Error setting interface state %d\n",errno);
           return -1;
       }
  5. In the Project Properties, set the Target API Set to 4.

The sample uses these Azure Sphere application libraries.

Library Purpose
log Displays messages in the Visual Studio Device Output window during debugging
networking Determines whether the device is connected to the internet
gpio Manages buttons A and B and LED 4 on the device
storage Gets the path to the certificate file that is used to authenticate the server
EventLoop Invoke handlers for timer events

Prerequisites

The sample requires the following software:

  • Azure Sphere SDK version 20.04 or later. At the command prompt, run azsphere show-version to check. Install the Azure Sphere SDK if necessary.
  • An Azure subscription. If your organization does not already have one, you can set up a free trial subscription.

Preparation

Note: By default, this sample targets MT3620 reference development board (RDB) hardware, such as the MT3620 development kit from Seeed Studios. To build the sample for different Azure Sphere hardware, change the Target Hardware Definition Directory in the project properties. For detailed instructions, see the README file in the Hardware folder.

  1. Set up your Azure Sphere device and development environment as described in the Azure Sphere documentation.

  2. Clone the Azure Sphere Samples repository on GitHub and navigate to the AzureIoT folder.

  3. Connect your Azure Sphere device to your computer by USB.

  4. Enable a network interface on your Azure Sphere device and verify that it is connected to the internet.

  5. Open an Azure Sphere Developer Command Prompt and enable application development on your device if you have not already done so:

    azsphere device enable-development

Run the sample

azure-iot's People

Contributors

johnpmill5 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.