First cmmit
This commit is contained in:
32
examples/simple-broker/simple-broker.ino
Normal file
32
examples/simple-broker/simple-broker.ino
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include "TinyMqtt.h" // https://github.com/hsaturn/TinyMqtt
|
||||
#include <Streaming.h> // https://github.com/janelia-arduino/Streaming
|
||||
|
||||
const char *ssid = ; // Put here your wifi SSID ("ssid")
|
||||
const char *password = ; // Put here your Wifi password ("pwd")
|
||||
|
||||
#define PORT 1883
|
||||
MqttBroker broker(PORT);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial << '.';
|
||||
delay(500);
|
||||
}
|
||||
Serial << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl;
|
||||
|
||||
broker.begin();
|
||||
Serial << "Broker ready : " << WiFi.localIP() << " on port " << PORT << endl;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
broker.loop();
|
||||
}
|
||||
Reference in New Issue
Block a user