NirvanaMQTT

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.

Download NirvanaMQTT.zip Install instructions

Quickstart

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.

Install

  1. Install the PubSubClient library (by Nick O'Leary) via Arduino IDE's Library Manager - NirvanaMQTT is a thin wrapper around it.
  2. Download NirvanaMQTT.zip above, then in the Arduino IDE: Sketch → Include Library → Add .ZIP Library... and select the file.
  3. Open File → Examples → NirvanaMQTT for a working ESP32 or ESP8266 sketch.

Getting an account

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.

API reference

CallWhat 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.

Broker connection details

Hostapi.nirvanatechnologies.in
Port8883 (TLS only - there is no unencrypted port)
AuthMQTT username/password, one account per set of credentials
Topic scopeaccounts/<your-username>/# - your account cannot read or write outside this

Notes