MQTT Broker Free

RosarIoT MQTT Broker  is a free service for R&D with Eclipse Mosquitto, an open source message broker that implements versions 5.0, 3.1.1 and 3.1 of the MQTT protocol.

Free without TLS

  • Broker: mqtt.rosariot.com
  • Port: 1883
  • Persistence: NO
  • Backups: NO

Free with TLS

  • Broker: mqtt.rosariot.com
  • Port: 8883
  • Certificate:  Download
  • Persistence: NO
  • Backups: NO
#include <ESP8266Wifi.h>
#include <PubSubClient.h>

const char *ssid = "ssid-wifi";
const char *pass = "password-wifi";
WiFiClientSecure wifi_client;

const char* mqtt_server = "mqtt.rosariot.com";
const int mqtt_port = 8883;
const char* mqtt_fingerprint = "DD:D5:C7:31:54:2F:31:DE:DF:88:E3:85:91:2F:12:50:AA:90:06:FF";
//const char* mqtt_pass = "mqtt-user";
//const char* mqtt_user = "mqtt-pass";
PubSubClient mqtt_client(mqtt_server, mqtt_port, wifi_client);

void setup()
{
  Serial.begin(115200);
  delay(100);
  Serial.println("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
  	delay(500);
  	Serial.print(".");
	}
  Serial.println("");
  Serial.println("WiFi connected");
  wifi_client.setFingerprint(mqtt_fingerprint);
}
void loop()
{
  wifi_client.connect(mqtt_server,mqtt_port); 					//CONNETION TCP/IP TO SERVER
  if(wifi_client.verify(mqtt_server,mqtt_fingerprint)) { 			//VERIFICATION TLS
  	Serial.println("SECURE TLS OK");
  	wifi_client.stop();
  	if(mqtt_client.connect(“mqtt_id”)) { 		//CONNETION TO MQTT BROKER
  		Serial.println("MQTTS OK");
//-----------------------YOUR CODE------------------------------//
  	} else {
                wifi_client.stop();         Serial.print(" --> ERROR WHEN TRYING CONNECT TO BROKER MQTT, "); Serial.print("rc= "); Serial.println(mqtt_client.state()); } } else {           wifi_client.stop();   Serial.println(" --> ERROR SECURE TLS"); } delay(5000); }