This repo contains all the code and details you need to get your MKR NB 1500 board connected to Azure.
You'll be able to connect directly into two Azure IoT Services:
- Azure IoT Hub, where you can piece together every detail of your IoT architecture
- Azure IoT Central, a fully-managed software-as-a-service offering where you can spend less time coding, and more time on your solution
As mentioned above, you have two options for where to send your data. Below are guides for setting up each of the resources.
If you're brand-new to Azure, or even Cloud technologies, check out these guides on What is Cloud Computing? and What is Azure?.
Before you get started, make sure you've created your free Azure account.
IoT Hub is Azure's dedicated IoT gateway. It handles data ingestion, device management, cloud-to-device messaging, security, and much more! All of the Microsoft IoT reference architectures recommend IoT Hub as the best way to ingest data from IoT devices. Even IoT Central uses IoT Hub under the hood!
- Follow this guide for Creating an IoT Hub
- Note: You can use the Free Tier of IoT Hub for this walkthrough
- Once you've created your Hub, add a new device and copy the connection string using this guide for Registering a device
IoT Central is a fully-managed Software-as-a-Service offering from Microsoft. It's the quickest way to get up-and-running with your IoT use cases and requires almost no coding to get started. The best part? IoT Central is completely free for the first 5 devices!
- You'll need to Create an IoT Central Application
- TODO: Complete IoT Central Guide
Before you get started with your device, there's a few things you'll need to install to make sure you're ready to program your board
- Install the Arduino IDE
- Open the Arduino IDE and add the following board in the Board Manager:
- Go to Tools > Boards > Boards Manager ...
- Install the latest version of Arduino SAMD Boards (32-bits ARM Cortex-M0+) by Arduino
- Next, you'll need to include some libraries:
- Go to Sketch > Include Library > Manage Libraries...
- Install the latest version of the following libraries:
- MKRNB by Arduino
- ArduinoMQTTClient by Arduino -> Note: This library is in Beta
- Now you're good to go!
- Clone or download the MKRNB1500-Azure_IoT folder from this repo
- Open the MKRNB1500-Azure_IoT.ino file in the Arduino IDE.
- You should see several tabs open in the window. These libraries and dependencies for the code.
- Click on the arduino_secrets.h tab
- This file holds sensitive information that you may not want to share (or push to GitHub!). It's easier to hold the seceret values in this file rather than disperse it through your code.
- Copy the device connection string from your chosen service:
- IoT Hub - This can easily be found in the Azure Portal:
- IoT Central - This requires a few additional steps:
- Go to your IoT Central app and select the device you created previously:
- Click Connect to get the parameters
- From this screen, you'll need the Scope ID, Device ID, and the Primary Key for the next step
- Open a new tab in your browser and head to https://dpscstrgen.azurewebsites.net/. Copy in the required parameters from your IoT Central page and select Submit
- A new connection string should be generated for your device!
- Paste into the CONN_STRING field in your arduino_secrets.h file. You should also copy the Hub Name from your connection string into the SECRET_BROKER field.
- That's it! You can now connect your device and transmit values to your IoT service.