RA FSP MQTT/TLS Azure Cloud Connectivity Solution Application
Total Page:16
File Type:pdf, Size:1020Kb
Application Note Renesas RA FSP™ Platform RA FSP MQTT/TLS Azure Cloud Connectivity Solution Introduction This application note describes IoT Cloud connectivity solutions in general and introduces you briefly to the IoT Cloud provider Microsoft Azure. It covers the RA FSP MQTT/TLS module along with the Azure IoT SDK for embedded C. This application project is built with the integrated “Azure IoT SDK for Embedded C” package which allows small embedded (IoT) devices like Renesas RA family of MCUs RA6M3/4/5 to communicate with Azure services. The application example uses Azure IoT DPS (Device Provisioning Service ) to provision, register the IoT device, and send and receive data to and from the development kit. This application note enables you to effectively use the RA FSP modules in your own design with the Azure IoT SDK. Upon completion of this guide, you will be able to add the FSP modules to your own design, configure it correctly with Azure IoT SDK for the target application, and write code using the included application example code as a reference and efficient starting point. References to more detailed API descriptions, and sample code that demonstrates advanced usage of FSP modules are available in the RA FSP Software Package (FSP) User’s Manual (see Next Steps section) and serve as valuable resources in creating more complex designs. Explaining the underlying operation of Azure IoT SDK for Embedded C is beyond the scope of this document. Users are recommended to refer to the documentation from Microsoft for education on topics related to Azure IoT SDK section https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub- devguide-sdks In this release, the EK-RA6M5 kit is used for the application project. Required Resources To build and run the MQTT/TLS application example, you need: Development Tools and Software • e2 studio ISDE v2021-04 or later • RA FSP Software Package (FSP) v3.0.0 or later • SEGGER J-Link® RTT viewer • Azure IoT explorer 0.14.2.0 or later (PC tool for validating the Cloud side) • Azure CLI 2.24 or later (Azure command-line interface is a set of commands used to create and manage Azure resources) • Access to Azure Cloud Connectivity Portal (https://portal.azure.com/#home) to create IoT Devices (If you are new to Azure IoT) Hardware • Renesas RA FSP™ EK-RA6M5 kit • PC running Windows® 10; Tera Term console or similar application, and an installed web browser (Google Chrome, Internet Explorer, Microsoft Edge, Mozilla Firefox, or Safari). • Micro USB cables • Ethernet cable (CAT5/6) • Router with ethernet port or ethernet switch to connecting to the router for Internet connectivity Prerequisites and Intended Audience This application note assumes that you have some experience with the Renesas e2 studio ISDE and RA FSP Software Package (FSP). Before you perform the procedures in this application note, follow the procedure in the FSP User Manual to build and run the Blinky project. Doing so enables you to become familiar with the e2 studio and the FSP, and also validates that the debug connection to your board functions properly. In R11AN0531EU0100 Rev.1.00 Page 1 of 41 Jul.19.21 Renesas RA FSP™ Platform RA FSP MQTT/TLS Azure Cloud Connectivity Solution addition, this application note assumes you have some knowledge of MQTT/TLS and its communication protocols. The intended audience are users who want to connect to Azure Cloud using the Azure IoT SDK for Embedded C on the Renesas RA RA6 MCU Series. Note: If you are a first-time user of e2 studio and FSP, we highly recommend you install e2 studio and FSP on your system in order to run the Blinky Project and to get familiar with the e2 studio and FSP development environment before proceeding to the next sections. Note: If you are new to Azure Internet of Things, we recommend you get started with Introduction the Azure IoT https://docs.microsoft.com/en-us/azure/iot-fundamentals/iot-introduction Prerequisites 1. Access to online documentation available in the Cloud Connectivity References section 2. Access to latest documentation for identified Renesas Flexible Software Package 3. Prior knowledge of operating e2 studio and built-in (or standalone) RA Configurator 4. Access to associated hardware documentation such as User Manuals and Schematics. Using this Application Note Section 1 of this document covers the General Overview of the Cloud Connectivity, Azure IoT Solution using IoT Central, and Azure DPS. MQTT and TLS Protocols and Device certificates and Keys used in the Cloud Connectivity. Section 2 covers the modules provided by RA FSP to establish connectivity to Cloud service providers and the features supported by the module. Section 3 covers the Architecture of the reference application project, an overview of the software components included, and step-by-step guidelines for recreation using the FSP configurator. Section 4 covers the setup of the Azure Cloud required for the application. Sections 5 covers the building and running the Application project for quick validation. Note: We recommend that you operate with your own Microsoft Azure Cloud credentials and use your created Cloud configurations to run the application. The default sample configuration detailed in this project is for reference only, and may have access issues to Azure since the application is communicating with a test account. Note: For a quick validation using the provided application project, you can skip the above sections 1 to 3 and go to section 5 for instructions on importing, building, and running the application project on the EK board. You are still required to provide necessary user credentials for the application as described in section 4. R11AN0531EU0100 Rev.1.00 Page 2 of 41 Jul.19.21 Renesas RA FSP™ Platform RA FSP MQTT/TLS Azure Cloud Connectivity Solution Contents 1. Introduction to Cloud Connectivity ........................................................................................... 5 1.1 Cloud Connectivity Overview .................................................................................................................. 5 1.2 Microsoft Azure IoT Solution ................................................................................................................... 6 1.2.1 Overview ................................................................................................................................................ 6 1.2.2 IoT Hub and Device Provisioning Service ............................................................................................. 6 1.3 MQTT Protocol Overview ........................................................................................................................ 7 1.4 TLS Protocol Overview ............................................................................................................................ 8 1.4.1 Device Certificates and Keys ................................................................................................................ 9 1.4.2 Device Security Recommendations ...................................................................................................... 9 2. RA FSP MQTT/TLS Cloud Solution ....................................................................................... 10 2.1 MQTT Client Module Introduction ......................................................................................................... 10 2.1.1 Design Considerations ........................................................................................................................ 10 2.1.2 Supported Features ............................................................................................................................. 10 2.2 TLS Session Module Introduction ......................................................................................................... 10 2.2.1 Design Considerations ........................................................................................................................ 11 2.2.2 Supported Features ............................................................................................................................. 11 2.3 Azure IoT Device SDK Module Introduction .......................................................................................... 11 2.3.1 Design Considerations ........................................................................................................................ 11 2.3.2 Supported Features ............................................................................................................................. 12 3. MQTT/TLS Application Example ............................................................................................ 12 3.1 Application Overview ............................................................................................................................. 12 3.2 Creating the Application Project using the FSP configurator ................................................................ 15 4. Prepare Azure Resources...................................................................................................... 20 4.1 Install Azure CLI .................................................................................................................................... 20 4.2 Create an IoT Hub ................................................................................................................................. 20 4.3 Register an IoT Hub device ..................................................................................................................