Skip to content

Init-io/InitMQTT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 InitMQTT β€” Just MQTT, But Smartβ„’

Simpler than your ex, smarter than PubSubClient.

InitMQTT is a πŸ”₯ firestarter MQTT wrapper for ESP8266/ESP32 that gets rid of the boring boilerplate. No more client.setCallback(...), loop(), reconnect(), and what-do-I-even-do-with-this-payload[]. We've done the heavy lifting, so you can vibe and code.


πŸš€ Features

  • βœ… connect(server, port, user, pass) β€” dead simple
  • βœ… put(topic, value) β€” for String, int, float
  • βœ… putRetain(...) β€” because memory is good
  • βœ… get(topic) β€” cached last message like your browser tabs
  • βœ… subscribe(topic) β€” easy, no drama
  • βœ… setCallback(fn) β€” get your messages without stress
  • βœ… onReconnect(fn) β€” auto-sync like a king
  • βœ… refresh() β€” your new loop(), but cooler
  • πŸ”’ Uses SSL by default (yes, we care about your security)
  • πŸ’‘ Works with HiveMQ, Mosquitto, AWS β€” anything MQTT

❗ Built over PubSubClient, but we made it feel like you're using an API from 2025.


πŸ§ͺ Example: LED Control Vibe Check


#include <InitMQTT.h>
InitMQTT mqtt;

void onMsg(const char* topic, const char* msg) {
  if (String(topic) == "device/led") {
    digitalWrite(LED_BUILTIN, String(msg) == "1" ? LOW : HIGH);
  }
}

void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  WiFi.begin("YourSSID", "YourPassword");
  while (WiFi.status() != WL_CONNECTED) delay(500);

  mqtt.setCallback(onMsg);
  mqtt.connect("broker.hivemq.com", 1883);
  mqtt.subscribe("device/led");
}

void loop() {
  mqtt.refresh();
}

🀑 Why Not PubSubClient?

Yeah, we use it under the hood β€” but:

  • ❌ Setting up callbacks is messy
  • ❌ You have to track subscriptions manually
  • ❌ You keep copy-pasting reconnect boilerplate
  • ❌ You lose retained messages on reboot (unless you fight it)

We fixed that. Like an adult.


πŸ› οΈ Usage Playground

Check out examples/usages/ for:

  • BasicConnect.ino β€” Hello MQTT
  • ControlLED.ino β€” LED dance party
  • PutRetain.ino β€” Because state matters
  • GetLatestMessage.ino β€” Read last message like your chat logs
  • WithAuth.ino β€” Secure like your password manager
  • OnReconnect.ino β€” Sync up when MQTT ghosted you

πŸ‘¨β€πŸ’» Author

Siam Rayhan instagram.com/thesiamrayhan

  • πŸ’¬ DM friendly
  • πŸ’» Built it for my own projects, open-sourcing for the homies
  • ☁️ Future-ready IoT libraries are coming πŸ”œ

⚑ License

MIT β€” Use it, fork it, make millions with it. Just don’t sell it back to me πŸ™ƒ


πŸ“’ Final Thoughts

This ain't just another wrapper. This is InitMQTT β€” where your ESP talks like it knows what it's doing.

🧠 Less code, more control. You're welcome.


About

πŸ”Œ Dead-simple MQTT wrapper for ESP8266/ESP32. Retained messages, reconnects, callbacks β€” all in one line. Built over PubSubClient, but 100x smoother.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages