esp-mqtt-skill

Generates ESP-IDF firmware code for MQTT client connections over TCP, TLS, and WebSocket.

28|3|Updated Jun 24, 2026
One-click install
npx skills add https://github.com/JasonYANG170/esp-dev-skill --skill esp-mqtt-skill-jasonyang170
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: esp-mqtt-skill
Source: https://github.com/JasonYANG170/esp-dev-skill/tree/main/repos/esp-mqtt
Command: npx skills add https://github.com/JasonYANG170/esp-dev-skill --skill esp-mqtt-skill-jasonyang170

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing correct ESP-MQTT client code for ESP32 firmware requires knowing exact API signatures, initialization order, Kconfig options, and TLS certificate handling, and mistakes cause deadlocks, memory leaks, or failed handshakes. This Skill grounds all generated code in the real esp-mqtt repository source and documentation. ## Core Features & Use Cases - Scenario Recipes: 12 step-by-step recipes covering TCP connect, event handling, publish/subscribe with QoS, mutual TLS, server CA validation, PSK, digital signature peripheral, WebSocket/WSS, MQTT 5.0, last will, outbox management, and custom outbox. - API and Config Reference: Complete esp_mqtt_client_* and esp_mqtt5_* signatures, the full esp_mqtt_client_config_t field table, and all Kconfig options with defaults. - Pitfall Prevention: 30 documented traps with wrong/correct code pairs, such as calling stop inside event callbacks or printing non-null-terminated topics with %s. - Use Case: Ask for an mqtts:// client with mutual TLS on ESP32-S3 and receive compilable code with embedded certificates, correct init sequence, and build commands. ## Quick Start Ask the agent to create an ESP-IDF MQTT client that connects to your broker over TLS and subscribes to a topic, and it will produce the full app_main.c with build steps.

Frequently Asked Questions about esp-mqtt-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect an ESP32 MQTT client to a broker over TLS?

Use the mqtts:// URI scheme and configure broker.verification with a CA certificate embedded via EMBED_TXTFILES, or set use_global_ca_store or crt_bundle_attach. Initialize with esp_mqtt_client_init, register the event handler, then call esp_mqtt_client_start.

How do I use MQTT 5.0 features on ESP-IDF?

Enable CONFIG_MQTT_PROTOCOL_5 in menuconfig and set session.protocol_ver to MQTT_PROTOCOL_V_5. Then use the esp_mqtt5_client_set_*_property APIs for connect, publish, subscribe, and disconnect properties, and always free user properties after setting them.

Why does esp_mqtt_client_publish return -2?

Return value -2 means the outbox is full, which happens when QoS 1 or 2 messages accumulate faster than the broker acknowledges them. Set outbox.limit, monitor esp_mqtt_client_get_outbox_size, reduce publish rate, or drop to QoS 0.

Can I call esp_mqtt_client_stop inside the MQTT event callback?

No, calling esp_mqtt_client_stop or esp_mqtt_client_destroy inside an event handler causes a deadlock and is explicitly forbidden. Signal a separate task from the callback and stop the client from that task context instead.

Which ESP32 chips support the digital signature peripheral for MQTT TLS?

The DS peripheral workflow works on ESP32-S2, S3, C3, C5, C6, H2, and P4, but not the original ESP32. It requires the esp_secure_cert_mgr component, a provisioned esp_secure_cert partition, and setting credentials.authentication.ds_data instead of a private key.

Why does my MQTT event handler print garbage for topic and data?

The topic and data fields in esp_mqtt_event_t are not null-terminated strings, so printing with %s reads out of bounds. Use %.*s with event->topic_len and event->data_len, and handle large messages split across multiple MQTT_EVENT_DATA events.