Using the Arduino IDE, create an .ino sketch that creates an MQTT broker for the MKR WIFI 1010
system
Arduino IDE kaa upyog karte hue, ek .ino sketch banaaen jo MKR wifai 1010 ke liye ek MQTT brokar banaata he
user
yahan code he jo Arduino MKR WIFI 1010 kaa upyog karke MQTT brokar banaata he:

#include <wifinina.h>
#include <pubsubclient.h>

// apane vaai-faai network credentials ke saath inhen apadet karen
const char* ssid = "your_ssid";
const char* password = "your_password";

// MQTT brokar vivaran apadet karen
const char* mqttserver = "your_mqtt_broker_ip";
const int mqttport = 1883;

// vaai-faai client kaa ek udhaaharan banaaen
Wificlient wificlient;

// MQTT client kaa ek udhaaharan banaaen
Pubsubclient mqttclient (wificlient);

vyarth vyavastha() {
  // serial communication inishilise karen
  serial.bin (9600);
  
  // vaai-faai network se conect karen
  Wifi.begin (SSID, password);
  
  jabaki (wifi.status ()! = wl_connected) {
    deree (500);
    serial.print (".");
  }
  
  Serial.println ("\ _ vaai-faai ke liye nconnected");
  
  // MQTT brokar se conect karen
  mqttclient.setserver (mqttserver, mqttport);
  
  jabaki (mqttclient.connected ()) {
    if (mqttclient.connect ("mkr-wifi-1010")) {
      Serial.println ("MQTT brokar se judaa hua he");
      mqttclient.subscribe ("vishay/udhaaharan");
    } anya {
      Serial.print ("MQTT brokar, rc =" se conect karne main vifal rahaa);
      Serial.print (mqttclient.state ());
      Serial.Println ("5 second main retrig ...");
      deree (5000);
    }
  }
}

shunya loop () {
  // MQTT conection banaae rakhen
  if (!
    pun: conect ();
  }
  mqttclient.loop ();
}

shunya pun: joden () {
  // MQTT brokar ko phir se judane kaa prayaas karen
  jabaki (mqttclient.connected ()) {
    if (mqttclient.connect ("mkr-wifi-1010")) {
      Serial.println ("MQTT brokar se judaa hua he");
      mqttclient.subscribe ("vishay/udhaaharan");
    } anya {
      Serial.print ("MQTT brokar, rc =" se conect karne main vifal rahaa);
      Serial.print (mqttclient.state ());
      Serial.Println ("5 second main retrig ...");
      deree (5000);
    }
  }
}

shunya colbach (chaar* vishay, bite* pelod, ahastakshrit int lambaai) {
  // aane vaale MQTT sandeshon ko sanbhaalein
  serial.print ("praapt sandesh [");
  serial.print (vishay);
  serial.print ("]:");
  for (int i = 0; i <lambaai; i ++) {
    serial.print ((chaar) pelod [i]);
  }
  Serial.println ();
}
assistant
<|system|>
</s>
<|user|>
Arduino IDE kaa upyog karte hue, ek .ino sketch banaaen jo MKR wifai 1010 ke liye ek MQTT brokar banaata he</s>
<|assistant|>
yahan code he jo Arduino MKR WIFI 1010 kaa upyog karke MQTT brokar banaata he:

#include <wifinina.h>
#include <pubsubclient.h>

// apane vaai-faai network credentials ke saath inhen apadet karen
const char* ssid = "your_ssid";
const char* password = "your_password";

// MQTT brokar vivaran apadet karen
const char* mqttserver = "your_mqtt_broker_ip";
const int mqttport = 1883;

// vaai-faai client kaa ek udhaaharan banaaen
Wificlient wificlient;

// MQTT client kaa ek udhaaharan banaaen
Pubsubclient mqttclient (wificlient);

vyarth vyavastha() {
  // serial communication inishilise karen
  serial.bin (9600);
  
  // vaai-faai network se conect karen
  Wifi.begin (SSID, password);
  
  jabaki (wifi.status ()! = wl_connected) {
    deree (500);
    serial.print (".");
  }
  
  Serial.println ("\ _ vaai-faai ke liye nconnected");
  
  // MQTT brokar se conect karen
  mqttclient.setserver (mqttserver, mqttport);
  
  jabaki (mqttclient.connected ()) {
    if (mqttclient.connect ("mkr-wifi-1010")) {
      Serial.println ("MQTT brokar se judaa hua he");
      mqttclient.subscribe ("vishay/udhaaharan");
    } anya {
      Serial.print ("MQTT brokar, rc =" se conect karne main vifal rahaa);
      Serial.print (mqttclient.state ());
      Serial.Println ("5 second main retrig ...");
      deree (5000);
    }
  }
}

shunya loop () {
  // MQTT conection banaae rakhen
  if (!
    pun: conect ();
  }
  mqttclient.loop ();
}

shunya pun: joden () {
  // MQTT brokar ko phir se judane kaa prayaas karen
  jabaki (mqttclient.connected ()) {
    if (mqttclient.connect ("mkr-wifi-1010")) {
      Serial.println ("MQTT brokar se judaa hua he");
      mqttclient.subscribe ("vishay/udhaaharan");
    } anya {
      Serial.print ("MQTT brokar, rc =" se conect karne main vifal rahaa);
      Serial.print (mqttclient.state ());
      Serial.Println ("5 second main retrig ...");
      deree (5000);
    }
  }
}

shunya colbach (chaar* vishay, bite* pelod, ahastakshrit int lambaai) {
  // aane vaale MQTT sandeshon ko sanbhaalein
  serial.print ("praapt sandesh [");
  serial.print (vishay);
  serial.print ("]:");
  for (int i = 0; i <lambaai; i ++) {
    serial.print ((chaar) pelod [i]);
  }
  Serial.println ();
}</s>
