How can I connect an esp32 programming it with Arduino IDE to IoT Hub?

Matías Liñán García 25 Reputation points
2023-08-18T08:24:53.6366667+00:00

Hi, I'm trying to connect an esp32 to IoT Hub, I'm programming it with Arduino IDE and I get an error. I attach both the code and the error.

Monitor Serial:

Error: Time:Fri Aug 18 08:16:28 2023 File:C:\Program Files (x86)\Arduino\libraries\ESP32_AzureIoT_Arduino-master\src\az_iot\c-utility\pal\src\tlsio_openssl_compact.c Func:tlsio_openssl_send_async Line:758 tlsio_openssl_send_async without a prior successful open

Error: Time:Fri Aug 18 08:16:28 2023 File:C:\Program Files (x86)\Arduino\libraries\ESP32_AzureIoT_Arduino-master\src\az_iot\umqtt\src\mqtt_client.c Func:sendPacketItem Line:332 757: Failure sending control packet data

Error: Time:Fri Aug 18 08:16:28 2023 File:C:\Program Files (x86)\Arduino\libraries\ESP32_AzureIoT_Arduino-master\src\az_iot\umqtt\src\mqtt_client.c Func:mqtt_client_disconnect Line:1176 Error: mqtt_client_disconnect send failed

Info: >>>Confirmation[0] received for message tracking id = 0 with result = IOTHUB_CLIENT_CONFIRMATION_BECAUSE_DESTROY

Info: Initializing SNTP

Info: SNTP initialization complete

Info: IoT Hub SDK for C, version 1.1.23

Error: Time:Fri Aug 18 08:16:29 2023 File:C:\Program Files (x86)\Arduino\libraries\ESP32_AzureIoT_Arduino-master\src\az_iot\c-utility\pal\socket_async.c Func:socket_async_create Line:35 create socket failed

Info: Could not open the socket

Info: >>>Connection status: disconnected

Info: >>>Connection status: disconnected

Info: tlsio_openssl_close has been called when in neither TLSIO_STATE_OPEN nor TLSIO_STATE_ERROR.

Error: Time:Fri Aug 18 08:16:30 2023 File:C:\Program Files (x86)\Arduino\libraries\ESP32_AzureIoT_Arduino-master\src\az_iot\c-utility\pal\socket_async.c Func:socket_async_create Line:35 create socket failed

Info: Could not open the socket

Info: >>>Connection status: disconnected

Info: >>>Connection status: disconnected

Info: tlsio_openssl_close has been called when in neither TLSIO_STATE_OPEN nor TLSIO_STATE_ERROR.

Error: Time:Fri Aug 18 08:16:32 2023 File:C:\Program Files (x86)\Arduino\libraries\ESP32_AzureIoT_Arduino-master\src\az_iot\c-utility\pal\socket_async.c Func:socket_async_create Line:35 create socket failed

Info: Could not open the socket

Info: >>>Connection status: disconnected

Info: >>>Connection status: disconnected

Info: tlsio_openssl_close has been called when in neither TLSIO_STATE_OPEN nor TLSIO_STATE_ERROR.

Error: Time:Fri Aug 18 08:16:36 2023 File:C:\Program Files (x86)\Arduino\libraries\ESP32_AzureIoT_Arduino-master\src\az_iot\c-utility\pal\socket_async.c Func:socket_async_create Line:35 create socket failed

Info: Could not open the socket

Info: >>>Connection status: disconnected

Info: >>>Connection status: disconnected

Info: tlsio_openssl_close has been called when in neither TLSIO_STATE_OPEN nor TLSIO_STATE_ERROR.

Error: Time:Fri Aug 18 08:16:44 2023 File:C:\Program Files (x86)\Arduino\libraries\ESP32_AzureIoT_Arduino-master\src\az_iot\c-utility\pal\socket_async.c Func:socket_async_create Line:35 create socket failed

Info: Could not open the socket

Info: >>>Connection status: disconnected

Info: >>>Connection status: disconnected

Info: tlsio_openssl_close has been called when in neither TLSIO_STATE_OPEN nor TLSIO_STATE_ERROR.

Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub.

Error: Time:Fri Aug 18 08:16:59 2023 File:C:\Program Files (x86)\Arduino\libraries\ESP32_AzureIoT_Arduino-master\src\Esp32MQTTClient.cpp Func:SendEventOnce Line:316 Waiting for send confirmation, time is up 31538

Datos recibidos: hola

hola

Datos recibidos: hola

hola

{"temperature":28.6,"roll":4.300000}

Info: >>>Re-connect.

#include 
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,258 questions
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.