1 #include <ESP8266WiFi.h>
4 #include <PubSubClient.h>
5 const char* mqtt_server = "chrome";
6 const char* input = "inTopic" ;
7 const char* output = "outTopic" ;
9 WiFiClient espClient; // WiFi connection obj
10 PubSubClient client(espClient); // MQTT client obj
12 const byte ledPin = 2; // GPIO2 on LoLin Nodemcu
18 pinMode(ledPin, OUTPUT);
19 digitalWrite(ledPin, HIGH); // OnBoard LED is inverted
22 client.setServer(mqtt_server, 1883);
27 if (!client.connected()) { // Keep MQTT connection on
33 snprintf (msg, 75, "Test message @millis: %ld", millis());
34 client.publish(output, msg);