Azure IoT Central and ESP32 #367
Unanswered
sanderdb01vf
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hello @sanderdb01vf! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am having an issue with connecting my ESP32 to my Azure IoT Central. Here are the steps that I followed. Please note that any names, device ids, etc are changed in this post:
created an Azure IoT Central App using the following Guides: https://learn.microsoft.com/en-us/azure/iot-develop/quickstart-send-telemetry-central?pivots=programming-language-ansi-c
Then under Devices, I clicked new and created a new device. I then made the device name ESP32_IOT, the device ID is mydevice1, I created a template called esp-template and assigned that device to that template.
I then clicked the device to bring up the device menu and clicked connect so that I could retrieve the scope ID (myScopeID), set the device ID (mydevice1), and retrieve the SAS primary Key (G9uCt7k=).
I then went under setting->application and set the certification authority to DigiCert Global G2 Root (based on the article at the following url: https://techcommunity.microsoft.com/t5/internet-of-things-blog/azure-iot-tls-critical-changes-are-almost-here-and-why-you/ba-p/2393169
after all of this was set, I then began to work on the esp32 code. I followed the guide at this url: https://github.com/Azure-Samples/iot-middleware-freertos-samples/tree/main/demos/projects/ESPRESSIF/esp32
basically, i cloned the project, initialized the repo, opened the esp sample folder in Visual Studio code, set the WiFi SSID and password, and then set the rest of the configuration parameters:
Copy
Azure IoT middleware for FreeRTOS Main Task Configuration
CONFIG_AZURE_SAMPLE_USE_PLUG_AND_PLAY=y
CONFIG_AZURE_IOT_HUB_FQDN=""
CONFIG_AZURE_IOT_DEVICE_ID="mydevice1"
CONFIG_AZURE_IOT_AUTH_METHOD_SYMMETRIC_KEY=y
// CONFIG_AZURE_IOT_AUTH_METHOD_X509 is not set
CONFIG_AZURE_IOT_DEVICE_SYMMETRIC_KEY="G9uCt7k="
CONFIG_AZURE_IOT_MODULE_ID=""
CONFIG_ENABLE_DPS_SAMPLE=y
CONFIG_AZURE_DPS_ID_SCOPE="myScopeID"
CONFIG_AZURE_DPS_REGISTRATION_ID=""
CONFIG_AZURE_TASK_STACKSIZE=4096
CONFIG_NETWORK_BUFFER_SIZE=5120
After all of this, I then cleaned, built, and flashed the project. However, I got the following error:
I (10258) sample_azureiot: Notification of a time synchronization event
I (10478) AZ IOT: Creating a TLS connection to global.azure-devices-provisioning.net:8883.
E (10698) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x2700
I (10698) esp-tls-mbedtls: Failed to verify peer certificate!
E (10698) esp-tls: Failed to open new connection E (10698) transport_base: Failed to open a new connection
E (10718) tls_freertos: Failed establishing TLS connection (esp_transport_connect failed)
W (10718) AZ IOT: Connection to the IoT Hub failed [6]. Retrying connection with backoff and jitter [0]ms.
Based on the rest of the terminal output, the device connects to the internet just fine, but has an issue with the provisioning. I have tried adding the device ID to the CONFIG_AZURE_DPS_REGISTRATION_ID parameter in the configuration, verifying that the time sync was correct, I have tried creating my own IoT Hub and IoT provisioning service (instead of connecting to a central), and I have tried other central apps to connect to, and I always get the same error. However, in the article at https://techcommunity.microsoft.com/t5/internet-of-things-blog/azure-iot-tls-critical-changes-are-almost-here-and-why-you/ba-p/2393169 under the section Valdation, they offer a testing environment to test devices that have to be updated for the new TLS changes.
IoT Hub endpoint: g2cert.azure-devices.net
Connection String: HostName=g2cert.azure-devices.net;DeviceId=TestDevice1;SharedAccessKey=iNULmN6ja++HvY6wXvYW9RQyby0nQYZB+0IUiUPpfec=
Device Provisioning Service (DPS):
Global Service Endpoint: g2-cert-dps.azure-devices-provisioning.net
ID SCOPE: 0ne002B1DF7
Registration ID: abc
When I enter these parameters into my esp32 configuration, the device connects just fine (I also have to update the democonfigENDPOINT in demo_config.h to "g2-cert-dps.azure-devices-provisioning.net").
I have been at this for days and cannot seem to gain any traction outside of being able to connect it to the test environment. I finally decided to move out of the VS Code/esp-idf environment, and tried testing it with Arduino. When using the Arduino azure central example, I was immediately able to connect to my central app.
When reviewing the REAMDME for the esp32 example I mentioned above, I realized that it said it was for IoT Hub. However, because Azure IoT Central is built on top of Azure IoT Hub, and the sample provided connects to the IoT Hub underlying the IoT Central application, I thought it would still be suitable for sending telemetry data to the IoT Central application? I am beginning to think that this was a wrong assumption. I then tried the azure iotkit sample project, but that would not even build because of a bunch of errors. I tried to fix them all, but could not get any headway. Also, with the IoTKit example, even if I was able to get it to work, it was bloated with so much extra code for additional peripherals and functionality, it would have been difficult to modify it for my humble application.
So, my main questions are:
All of the guides that I have been finding online make this seem very easy and straight forward, so there doesn't seem to be an answer that I have been able to find. I will admit, I am just learning about Azure (and a bit of a novice with VS Code and esp-idf), so I am sure that I have missed something, but for the life of me I cannot find it. I also gave the condensed version of my troubleshooting above, but wanted to give the most concise information that I thought would be helpful to finding a solution. Thank you for any help that you can provide.
Beta Was this translation helpful? Give feedback.
All reactions