wolfMQTT – Now Available as an Espressif Managed Component Includes AWS IoT MQTT Example

Not long ago, we announced preview support for new Espressif Managed Components in addition to the core wolfssl managed component. Today you can add MQTT capabilities to your toolbox by visiting this link:

https://components.espressif.com/components/wolfssl/wolfmqtt

If the ESP Registry page does not fully load with all the text, try holding down the “ctrl” key when pressing the refresh button in your browser. The CDN seems to occasionally cache incomplete web content.

Getting started with wolfSSL and wolfMQTT has never been easier! You can add wolfMQTT to your project with this command:

idf.py add-dependency “wolfssl/wolfmqtt”

We’ve also included a complete example project to connect to the AWS IoT MQTT. Just click the little “copy” icon and paste into a command prompt after the ESP-IDF has been installed:

Try it

Here’s an example of how the example can be created, built, and flashed onto your ESP32:

# Setup the ESP-IDF Environment (your actual path may vary)
. ~/esp/esp-idf/export.sh

# Download and create the example
idf.py create-project-from-example “wolfssl/wolfmqtt:AWS_IoT_MQTT”
cd AWS_IoT_MQTT

# Set your SSID and wifi Password in Example Connection Configuration
idf.py menuconfig

# Flash the code to your ESP32
idf.py -p /dev/ttyS9 -b 115200 flash monitor

Tada! You have your very own sample MQTT AWS IoT device! Upon a successful connection, output similar to this should be displayed on the serial port being monitored:

I (17096) wolfmqtt main: Initial Stack Used (before wolfSSL Server): 2244 bytes
I (17104) wolfmqtt main: Starting awsiot_main...

AwsIoT Client: QoS 1, Use TLS 1
MQTT Net Init: Success (0)
MQTT Init: Success (0)
NetConnect: Host a2dujmi05ideo2-ats.iot.us-west-2.amazonaws.com, Port 8883, Timeout 5000 ms, Use TLS 1
MQTT TLS Setup (1)
MQTT TLS Verify Callback: PreVerify 0, Error -188 (ASN no signer error to confirm failure)
  Subject's domain name is Starfield Services Root Certificate Authority - G2
  Allowing cert anyways
MQTT Socket Connect: Success (0)
MQTT Connect: Proto (v3.1.1), Success (0)
MQTT Connect Ack: Return Code 0, Session Present 0
MQTT Subscribe: Success (0)
  Topic $aws/things/demoDevice/shadow/update, Qos 1, Return Code 1
MQTT Publish: Topic $aws/things/demoDevice/shadow/update, ID 2, Success (0)
MQTT Waiting for message...
MQTT Message: Topic $aws/things/demoDevice/shadow/update, Qos 1, Len 92
Payload (0 - 92) printing 80 bytes:
{"state":{"reported":{"hardware":{"type":"wolf_aws_iot_demo","firmware_version":
MQTT Message: Done

The full wolfSSL repository for wolfMQTT contains even more examples for not only this Espressif AWS example, but many other target platforms as well.

Get Started with wolfSSL

Additional information on getting Started with wolfSSL on the Espressif environment is available on the wolfSSL GitHub repository as well as this YouTube recording:

If you have questions about any of the above, please contact us at facts@wolfSSL.com or call us at +1 425 245 8247.

Download wolfSSL Now