Skip to content

jimbobbennett/AzureIoTArduinoSample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure IoT Hub and Arduino Sample

This repo contains sample code for using Azure IoT Hub with Arduino boards.

The sample

This code is written using PlatformIO in Visual Studio Code. It targets an ESP32-Azure IoT Kit, an ESP32-based board with build in sensors and designed for Azure. You can use other boards, just update the platformio.ini file.

The sample demonstrates connecting to WiFi and setting the time, then connecting to IoT Hub and sending telemetry every few seconds. It will also respond to device twin updates and direct methods.

At the time of writing this, handling cloud to device messages is not supported as it appears to be broken in the core SDK.

Building and running the sample

At the time of writing, all the necessary Arduino libraries for Azure are not available from the Arduino library manager. Watch this issue to see when the last library is available and they can all be installed from the library manager.

This means that you need to install the libraries manually.

  1. Ensure you have Python, Visual Studio Code and the PlatformIO VS Code extension installed

  2. Clone the Azure Arduino IoT Pal GitHub repo

  3. Open a terminal or command prompt and navigate to the build_all folder in that repo

  4. Run the following command to build the libraries:

    python3 make_sdk.py -o build
  5. This will compile the libraries and put them in the build folder

  6. Clone this repo

  7. Copy the 5 AzureIoT* folders from the new build folder in the pal repo into the lib folder in the clone of this repo

  8. Open this repo in VS Code, plug in an ESP32 board and upload the code using PlatformIO by launching the command palette and selecting PlatformIO: Upload. You may need to hold the boot button on your ESP32 device during the code upload to successfully copy the code over depending on your board.

Releases

No releases published

Packages

No packages published