A minimal MQTT broker + Arduino library for IoT boards. Publish a sensor reading from an ESP32 or ESP8266 in about five lines, with real TLS and no topic-path bookkeeping.
This is the whole program on the sending side - connect WiFi, trust the broker's certificate, publish:
#include <WiFiClientSecure.h>
#include <NirvanaMQTT.h>
#include <NirvanaMQTT_RootCA.h>
WiFiClientSecure secureClient;
NirvanaMQTT nirvana(secureClient, "demo", "YOUR_ACCOUNT_PASSWORD");
void setup() {
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) delay(250);
secureClient.setCACert(NIRVANA_ROOT_CA);
nirvana.begin();
}
void loop() {
nirvana.loop();
nirvana.publish("temperature", "25.3");
}
You never type the full topic path. publish("temperature", ...) actually sends to accounts/demo/temperature - the library adds that prefix for you, and the broker enforces that your account can only touch its own accounts/<username>/ namespace.
Accounts are provisioned manually for now - get in touch for a username/password. There's also a public demo account for trying things out before you have your own.
| Call | What it does |
|---|---|
NirvanaMQTT(Client& client, const char* username, const char* password) | Construct with any TLS-capable Client (WiFiClientSecure, BearSSL, etc.) and your account credentials. |
begin(host, port) | Connects to the broker. Defaults to api.nirvanatechnologies.in:8883. |
loop() | Call every loop() iteration - pumps the connection and auto-reconnects if it drops. |
connected() | Returns whether the broker connection is currently up. |
publish(topic, payload, retained=false) | Sends payload to accounts/<username>/<topic>. |
subscribe(topic) | Subscribes to accounts/<username>/<topic>. |
onMessage(callback) | Registers void callback(const char* topic, const char* payload), called for every subscribed topic with the plain (un-prefixed) topic name. |
| Host | api.nirvanatechnologies.in |
|---|---|
| Port | 8883 (TLS only - there is no unencrypted port) |
| Auth | MQTT username/password, one account per set of credentials |
| Topic scope | accounts/<your-username>/# - your account cannot read or write outside this |
NirvanaMQTT_RootCA.h ships the broker's actual root CA (ISRG Root X1, valid until 2035), so examples use real certificate verification instead of setInsecure().MQTT_MAX_PACKET_SIZE and NIRVANA_MQTT_MAX_PAYLOAD together if you need more.setCACert() vs BearSSL's setTrustAnchors()) - that's why there are two examples instead of one.