How I connect a ESP32 directly to a LOSANT Device using MQTT, skipping the broker

I want to make a direct connection to LOSANT using MQTT, I heard it is possible. I would like to know how, as I can’t find any topic about it.

Hey @Ary_Luz,

The ESP32 can connect directly to Losant over MQTT.

skipping the broker

An MQTT broker is a required component for any MQTT connection. The ESP32 acts as an MQTT client which can connect to Losant’s MQTT broker: broker.losant.com.

Losant supports special topics that, when published to, record telemetry data directly to your Losant device attributes. The full details on our MQTT spec is here:

As for programming the ESP32, we recommend using the official ESP-IDF, which has a built-in MQTT client.

You can see an example usage of that MQTT client here:

The above code has lots of extra stuff in it required to implement our Embedded Edge Agent. If your goal is a basic MQTT connection, much of that code can be removed. It’s still a good example of how to get the client initialized.

Learn hands-on how to make a MQTT connection to Losant in 15 minutes at
IoT Simulator: Testing / Proof of concept / Training for the Internet of Things or watch a video in 2 minutes

Brandon, this helped me! Thanks.

I would like to congratulate you, I was developing a project in which I found myself with some doubts along the way, several topics that “solved” my problem, there was an answer from you. Thank you for your services!

1 Like