Skip to the content.

MycilaMQTT

Latest Release PlatformIO Registry

License: MIT Contributor Covenant

Build GitHub latest commit Gitpod Ready-to-Code

A simple and efficient MQTT helper for Arduino / ESP32 based on Espressif MQTT Client

Usage

  Mycila::MQTT::Config config;
  config.server = "test.mosquitto.org";
  config.port = 1884;
  config.username = "rw";
  config.password = "readwrite";
  config.clientId = "my-app-1234";
  config.willTopic = "foo/status";

  mqtt.onConnect([]() {
    Serial.println("MQTT connected");
  });

  mqtt.subscribe("my-app/value/set", [](const String& topic, const String& payload) {
    Serial.printf("MQTT message received: %s -> %s\r\n", topic.c_str(), payload.c_str());
  });

  mqtt.begin(config);
  mqtt.publish("my-app/value", "Hello World!");

SSL / TLS

Please see the examples to see how to use server certificates or CA certificate bundles.

Alternatives

PsychicMqttClient is also an MQTT library based on ESP-IDF written by @theelims that you might want to consider, which is more feature rich and has better support for CA bundles.