Skip to content

s-gregorini003/azure-iot-arduino-nano-33-iot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Send Large JSON Data to IoT Hub Using MQTT

This project is to demonstrate how to send JSON documents larger than 256 Bytes from an Arduino Nano 33 IoT board to Azure IoT Hub.

Prerequisites

To compile the code, you need the following libraries:

  • ArduinoJson - To encapsulate my data in a JSON message, one of the formats accepted by IoT Hub;

  • WiFiNINA - To connect the board to the WiFi;

  • ArduinoMqttClient - Client that allows to send and receive MQTT messages;

  • ArduinoBearSSL - Port of BearSSL to Arduino, to implement the SSL/TLS protocol;

  • ArduinoECCX08 - Library for the Atmel/Microchip ECC508 and ECC608 crypto chips, used for authentication with IoT Hub with a SelfSigned X.509 certificate;

All libraries must be installed on your system before compiling the code (instructions on how to install Arduino libraries can be found here).

X.509 Self-Signed Certificate

Before uploading the code of this repo to your board, you need to generate a self-signed X.509 certificate to authenticate to the hub. To do that, compile and upload the example from ArduinoECCX08 named ECCX08SelfSignedCert (you can find it in File -> Examples -> ArduinoECCX08 -> Tools -> ECCX08SelfSignedCert. When the upload is complete, open the serial monitor and follow the instructions to create a certificate. At the end of the procedure, the board should print a SHA1 fingerprint that you have to copy and store for a later step. More information on this process can be found here.

Azure IoT Hub Deployment

If you don't know how to create an Iot Hub and register a new device, use the following resources:

  1. Create an IoT hub
  2. Register a new device

Important

When registering a new device, don't forget to select X.509 Self-Signed in the Authentication type field, and paste the SHA1 key that you copied before in both the Primary Thumbprint and Secondary Thumbprint fields.

Register a device

Configuration

To connect the device to IoT Hub you need to copy some values in the arduino_secrets.h tab. Specifically, fill in SECRET_WIFI_SSID and SECRET_WIFI_PASS with your WiFi SSID and password respectively. From the IoT Hub "Overview" page, copy the hub hostname and paste it in SECRET_BROKER. Then, from the "IoT devices" page, copy your device ID in SECRET_DEVICE_ID.

#define SECRET_WIFI_SSID   " " 
#define SECRET_WIFI_PASS   " "
#define SECRET_BROKER " "
#define SECRET_DEVICE_ID " "

Other Resources

If you want to know more about this topic, check out the related article.

About

Example code to send large JSON data from Arduino Nano 33 IoT to Azure IoT Hub

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published