Forum Discussion

VPavlov's avatar
VPavlov
Copper Contributor
Aug 19, 2022

Connecting Arduino MKR 1010 WiFi to Azure IoT Hub Device

Hi Community fam,

I am facing some issues connecting my Arduino MKR 1010 to Azure IoT Hub and I do not have any other options than open a discussion here. I really hope that someone will be able to help. So, what I did is:
1. Create CA signed certificate, using ECC algorithm for signing, following this guide - https://github.com/Azure/azure-iot-sdk-c/blob/main/tools/CACertificates/CACertificateOverview.md
2. Then, generated leaf certificate for my IoT Hub Device, again using the CACertificates scripts.
3. I create IoT Hub where I created a device with authentication type: X509 CA Signed certificate.
4. Afterwards, I created the Device Provisioning Service that is connect to the create IoT Hub.
5. I added the Root certificate that was generated in the first step.

6. Then, I used the following code: https://github.com/Vitomir2/Digital-Twins-Azure-IoT-Hub/blob/main/source/auth-x509-certs-arduino-sketches/authentication-x509-certificates-2/authentication-x509-certificates-2.ino
7. After uploading the code on the board, it returns me: Connect Error: -2. I know this error comes from the MQTT and not exactly from the Azure, but I hope someone will have experience with that.

Just tell me if you need more information about my setup, but basically, in summary that is it.

Any help will be appreciated and also I am in a hurry a lot, because I have deadline to finish some measurements when connect successfully to the IoT Hub device.

#iot-hub, #x509-certificate #arduino

Best regards,

Vitomir

5 Replies

  • mgungor's avatar
    mgungor
    Copper Contributor

    VPavlov Have you found a solution for that?

    Have you seen this post: https://paul-bruffett.medium.com/iot-azure-pipeline-9725ac2b6a00

     

    • VPavlov's avatar
      VPavlov
      Copper Contributor

      mgungor I have not, but I decided to proceed with just a self-signed X509 certificate just to finish my project, because my deadline was 30th of August.

      About the post you forwarded, I think I have seen it before, but it uses SAS token for the authentication, however, I had to use X509 CA signed certificate. Thanks for the highlight.

      I plan to create my own example and to push it to an Arduino Library, but not sure if I am going to have time for this. If you also need this, but you have time to wait, I raised a ticket on github for sample how the https://github.com/Azure/azure-sdk-for-c/issues/2319.

      BR,
      Vitomir

      • henderjl's avatar
        henderjl
        Copper Contributor

        VPavlov Do you still need help with this? I have numerous Arduino devices connected to my Azure IOT Hub and I can show you an easy way to do this.

Resources