Reputation: 21
I have a problema that I have a correctly connection to my mobile hotspot wifi, but when I try to connect MQTT to upload some sensor data to my PC ip (I did it with mosquitto broker), I always have the same problem.
esp_mqtt_client_config_t mqtt_cfg = {
.uri = "mqtt://192.168.166.66:1883",
//.host = "192.168.166.66",
//.port = 1883,
.buffer_size = 1024,
.client_id = "ESP-TFG-FRAN",
.lwt_qos = 1,
//.transport = MQTT_TRANSPORT_OVER_TCP,
.protocol_ver = MQTT_PROTOCOL_V_3_1_1,
};
client = esp_mqtt_client_init(&mqtt_cfg);
vTaskDelay(100/portTICK_RATE_MS);
esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, client);
ret = esp_mqtt_client_start(client);
if(ret != ESP_OK) {
printf("ERROR in first connecting of MQTT: %x\n", ret);
esp_mqtt_client_reconnect(client);
}
Could someone help me to solve it?
This is my error code that I always have:
I will think it is probably a problem with the sdk and the idf.py menuconfig
or the TCP/IP protocol... but I can`t fine the solution of the problem...
Upvotes: 1
Views: 1676
Reputation: 59771
The error means that the ESP could not connect to the machine with the broker. This could be for a number of reasons
Upvotes: 2