Skip to content

A demo Arduino project showing how to use Azure IoT Hub with the Wio Terminal. Built using PlatformIO, but can be implemented using the Arduino IDE.

License

Notifications You must be signed in to change notification settings

jimbobbennett/wio-terminal-azure-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wio Terminal Azure IoT sample

This repo shows sample code for connecting the Wio Terminal to Azure IoT Hub. This uses the Azure Arduino SDK.

This code connects to IoT Hub, then sends telemetry in the loop function. It also listens to direct method requests.

The IoT Hub code runs single-threaded, so you need to call IoTHubDeviceClient_LL_DoWork(_device_ll_handle) to process messages from IoT Hub. Instead of a long delay in the loop function, this code shows how to implement a long delay as lots of short delays with calls to IoTHubDeviceClient_LL_DoWork.

When your device connects, part of the internal connection logic uses the current time to build a key. This means the device time has to be correct, and this is implemented in the ntp.h file, with code to get the current time from an NTP server and set it on the Wio Terminals RTC.

Instructions

  1. Create an Azure IoT Hub
  2. Create a device and get the connection string
  3. Open this folder in VS Code using the PlatformIO extension
  4. Set the CONNECTION_STRING constant in config.h in the src folder to the device connection string
  5. Set the SSID and PASSWORD constants in config.h in the src folder to the relevant values for your WiFi
  6. Build and deploy to your Wio Terminal using PlatformIO

If you are using the Arduino IDE, you can copy the main.cpp code into your sketch file, and add the other files in the src folder into your sketch folder. You will need to choose the Wio Terminal in the board manager and add the following libraries using the library manager:

  • bblanchon/ArduinoJson
  • seeed-studio/Seeed Arduino rpcWiFi
  • seeed-studio/Seeed Arduino FS
  • seeed-studio/Seeed Arduino SFUD
  • seeed-studio/Seeed Arduino rpcUnified
  • seeed-studio/Seeed_Arduino_mbedtls
  • seeed-studio/Seeed Arduino RTC
  • arduino-libraries/AzureIoTHub
  • azure/AzureIoTUtility
  • azure/AzureIoTProtocol_MQTT
  • azure/AzureIoTProtocol_HTTP
  • azure/AzureIoTSocket_WiFi

About

A demo Arduino project showing how to use Azure IoT Hub with the Wio Terminal. Built using PlatformIO, but can be implemented using the Arduino IDE.

Topics

Resources

License

Stars

Watchers

Forks